summaryrefslogtreecommitdiff
path: root/usr/src/lib/libsip/common
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libsip/common')
-rw-r--r--usr/src/lib/libsip/common/sip.h14
-rw-r--r--usr/src/lib/libsip/common/sip_add_hdrs.c12
-rw-r--r--usr/src/lib/libsip/common/sip_dialog.c47
-rw-r--r--usr/src/lib/libsip/common/sip_dialog.h9
-rw-r--r--usr/src/lib/libsip/common/sip_dialog_ui.c11
-rw-r--r--usr/src/lib/libsip/common/sip_gids.c11
-rw-r--r--usr/src/lib/libsip/common/sip_hash.c7
-rw-r--r--usr/src/lib/libsip/common/sip_hash.h4
-rw-r--r--usr/src/lib/libsip/common/sip_hdrs_ui.c11
-rw-r--r--usr/src/lib/libsip/common/sip_headers.c11
-rw-r--r--usr/src/lib/libsip/common/sip_itf.c18
-rw-r--r--usr/src/lib/libsip/common/sip_miscdefs.h5
-rw-r--r--usr/src/lib/libsip/common/sip_msg.c11
-rw-r--r--usr/src/lib/libsip/common/sip_msg.h4
-rw-r--r--usr/src/lib/libsip/common/sip_parse_generic.c13
-rw-r--r--usr/src/lib/libsip/common/sip_parse_generic.h7
-rw-r--r--usr/src/lib/libsip/common/sip_parse_hdrs.c11
-rw-r--r--usr/src/lib/libsip/common/sip_parse_uri.c4
-rw-r--r--usr/src/lib/libsip/common/sip_reass.c11
-rw-r--r--usr/src/lib/libsip/common/sip_timeout.c23
-rw-r--r--usr/src/lib/libsip/common/sip_ui.c13
-rw-r--r--usr/src/lib/libsip/common/sip_uri_ui.c4
-rw-r--r--usr/src/lib/libsip/common/sip_xaction.c8
-rw-r--r--usr/src/lib/libsip/common/sip_xaction.h11
-rw-r--r--usr/src/lib/libsip/common/sip_xaction_state_mc.c13
-rw-r--r--usr/src/lib/libsip/common/sip_xaction_ui.c11
26 files changed, 194 insertions, 110 deletions
diff --git a/usr/src/lib/libsip/common/sip.h b/usr/src/lib/libsip/common/sip.h
index 1a3b97c4bd..79969944e5 100644
--- a/usr/src/lib/libsip/common/sip.h
+++ b/usr/src/lib/libsip/common/sip.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,20 +33,8 @@
extern "C" {
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <strings.h>
-#include <assert.h>
#include <sys/types.h>
-#include <sys/socket.h>
#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <pthread.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
/* Send a SIP message statefully */
#define SIP_SEND_STATEFUL 0x0001
diff --git a/usr/src/lib/libsip/common/sip_add_hdrs.c b/usr/src/lib/libsip/common/sip_add_hdrs.c
index 3b696fd60a..6942212c9c 100644
--- a/usr/src/lib/libsip/common/sip_add_hdrs.c
+++ b/usr/src/lib/libsip/common/sip_add_hdrs.c
@@ -20,16 +20,22 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <pthread.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <sip.h>
+
#include "sip_msg.h"
#include "sip_miscdefs.h"
-#include "sip_parse_generic.h"
/*
* Returns number of digits in the given int
diff --git a/usr/src/lib/libsip/common/sip_dialog.c b/usr/src/lib/libsip/common/sip_dialog.c
index 36d268e314..402c6f32ae 100644
--- a/usr/src/lib/libsip/common/sip_dialog.c
+++ b/usr/src/lib/libsip/common/sip_dialog.c
@@ -20,16 +20,23 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <strings.h>
+#include <sip.h>
+
#include "sip_msg.h"
-#include "sip_hash.h"
#include "sip_miscdefs.h"
+#include "sip_hash.h"
#include "sip_dialog.h"
#include "sip_parse_generic.h"
@@ -961,21 +968,17 @@ sip_complete_dialog(_sip_msg_t *sip_msg, _sip_dialog_t *dialog)
sip_dup_header(chdr)) == NULL) {
(void) pthread_mutex_unlock(
&dialog->sip_dlg_mutex);
- sip_dialog_terminate(dialog,
- (sip_msg_t)sip_msg);
if (alloc_thdr)
sip_free_header(thdr);
- return (NULL);
+ goto terminate_new_dlg;
}
if (sip_dialog_get_route_set(dialog, sip_msg,
dialog->sip_dlg_type) != 0) {
(void) pthread_mutex_unlock(
&dialog->sip_dlg_mutex);
- sip_dialog_terminate(dialog,
- (sip_msg_t)sip_msg);
if (alloc_thdr)
sip_free_header(thdr);
- return (NULL);
+ goto terminate_new_dlg;
}
}
if (SIP_PROVISIONAL_RESP(resp_code)) {
@@ -993,11 +996,9 @@ sip_complete_dialog(_sip_msg_t *sip_msg, _sip_dialog_t *dialog)
sip_ulp_dlg_del_cb(dialog,
(sip_msg_t)sip_msg, NULL);
}
- sip_dialog_terminate(dialog,
- (sip_msg_t)sip_msg);
if (alloc_thdr)
sip_free_header(thdr);
- return (NULL);
+ goto terminate_new_dlg;
}
dialog->sip_dlg_state = SIP_DLG_CONFIRMED;
} else {
@@ -1006,10 +1007,9 @@ sip_complete_dialog(_sip_msg_t *sip_msg, _sip_dialog_t *dialog)
sip_ulp_dlg_del_cb(dialog, (sip_msg_t)sip_msg,
NULL);
}
- sip_dialog_terminate(dialog, (sip_msg_t)sip_msg);
if (alloc_thdr)
sip_free_header(thdr);
- return (NULL);
+ goto terminate_new_dlg;
}
if (dialog->sip_dlg_type == SIP_UAS_DIALOG) {
dialog->sip_dlg_local_uri_tag = thdr;
@@ -1018,9 +1018,7 @@ sip_complete_dialog(_sip_msg_t *sip_msg, _sip_dialog_t *dialog)
sip_dup_header(thdr)) == NULL) {
(void) pthread_mutex_unlock(
&dialog->sip_dlg_mutex);
- sip_dialog_terminate(dialog,
- (sip_msg_t)sip_msg);
- return (NULL);
+ goto terminate_new_dlg;
}
}
}
@@ -1067,17 +1065,22 @@ sip_complete_dialog(_sip_msg_t *sip_msg, _sip_dialog_t *dialog)
*/
if (sip_hash_add(sip_dialog_hash, (void *)dialog,
SIP_DIGEST_TO_HASH(dialog->sip_dlg_id)) != 0) {
+ terminate_new_dlg:
/*
* So that sip_dialog_delete() does not try to remove
* this from the hash table.
*/
(void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
if (dialog->sip_dlg_type == SIP_UAS_DIALOG) {
- sip_free_header(dialog->sip_dlg_local_uri_tag);
- dialog->sip_dlg_local_uri_tag = NULL;
+ if (dialog->sip_dlg_local_uri_tag != NULL) {
+ sip_free_header(dialog->sip_dlg_local_uri_tag);
+ dialog->sip_dlg_local_uri_tag = NULL;
+ }
} else {
- sip_free_header(dialog->sip_dlg_remote_uri_tag);
- dialog->sip_dlg_remote_uri_tag = NULL;
+ if (dialog->sip_dlg_remote_uri_tag != NULL) {
+ sip_free_header(dialog->sip_dlg_remote_uri_tag);
+ dialog->sip_dlg_remote_uri_tag = NULL;
+ }
}
(void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
sip_dialog_terminate(dialog, (sip_msg_t)sip_msg);
@@ -1630,6 +1633,8 @@ sip_update_dialog(sip_dialog_t dialog, _sip_msg_t *sip_msg)
(void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex);
if ((dialog = sip_complete_dialog(sip_msg, _dialog)) ==
NULL) {
+ if (_dialog->sip_dlg_type == SIP_UAC_DIALOG && decr_ref)
+ SIP_DLG_REFCNT_DECR(_dialog);
return (NULL);
}
if (decr_ref)
diff --git a/usr/src/lib/libsip/common/sip_dialog.h b/usr/src/lib/libsip/common/sip_dialog.h
index 7596ee9bf3..6f92f936f4 100644
--- a/usr/src/lib/libsip/common/sip_dialog.h
+++ b/usr/src/lib/libsip/common/sip_dialog.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,6 +33,13 @@
extern "C" {
#endif
+#include <pthread.h>
+#include <sip.h>
+#include <sys/types.h>
+
+#include "sip_msg.h"
+#include "sip_miscdefs.h"
+
/*
* Dialogs are linked in their own list.
*/
diff --git a/usr/src/lib/libsip/common/sip_dialog_ui.c b/usr/src/lib/libsip/common/sip_dialog_ui.c
index 698a0c8761..e48025b3c2 100644
--- a/usr/src/lib/libsip/common/sip_dialog_ui.c
+++ b/usr/src/lib/libsip/common/sip_dialog_ui.c
@@ -20,17 +20,22 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sip.h>
+
#include "sip_msg.h"
#include "sip_miscdefs.h"
+#include "sip_parse_uri.h"
#include "sip_dialog.h"
-#include "sip_xaction.h"
/*
* Create a request using the state maintained in the dialog.
diff --git a/usr/src/lib/libsip/common/sip_gids.c b/usr/src/lib/libsip/common/sip_gids.c
index f1ecfd726b..97f4b10f38 100644
--- a/usr/src/lib/libsip/common/sip_gids.c
+++ b/usr/src/lib/libsip/common/sip_gids.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -30,11 +30,9 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
+#include <pthread.h>
#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <time.h>
-#include <sys/errno.h>
+#include <sip.h>
#ifdef __linux__
#include <sasl/sasl.h>
#include <sasl/saslplug.h>
@@ -42,9 +40,8 @@
#include <sys/md5.h>
#endif
-#include "sip_parse_uri.h"
-#include "sip_msg.h"
#include "sip_miscdefs.h"
+#include "sip_msg.h"
void sip_md5_hash(char *, int, char *, int, char *, int, char *, int,
char *, int, char *, int, uchar_t *);
diff --git a/usr/src/lib/libsip/common/sip_hash.c b/usr/src/lib/libsip/common/sip_hash.c
index ee920241f0..bd047f4e09 100644
--- a/usr/src/lib/libsip/common/sip_hash.c
+++ b/usr/src/lib/libsip/common/sip_hash.c
@@ -20,18 +20,17 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
#include <pthread.h>
-#include <sip.h>
#include "sip_hash.h"
-#include "sip_miscdefs.h"
/*
* This file implements functions that add, search or remove an object
diff --git a/usr/src/lib/libsip/common/sip_hash.h b/usr/src/lib/libsip/common/sip_hash.h
index 99e2bedf38..00072201e6 100644
--- a/usr/src/lib/libsip/common/sip_hash.h
+++ b/usr/src/lib/libsip/common/sip_hash.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,9 +33,7 @@
extern "C" {
#endif
-#include <stdlib.h>
#include <pthread.h>
-#include <sip.h>
/* A prime number */
#define SIP_HASH_SZ 6037
diff --git a/usr/src/lib/libsip/common/sip_hdrs_ui.c b/usr/src/lib/libsip/common/sip_hdrs_ui.c
index a10a787fe2..bf2b416864 100644
--- a/usr/src/lib/libsip/common/sip_hdrs_ui.c
+++ b/usr/src/lib/libsip/common/sip_hdrs_ui.c
@@ -20,15 +20,20 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sip.h>
+
#include "sip_msg.h"
-#include "sip_miscdefs.h"
/*
* Generic function to get int or string value from a header
diff --git a/usr/src/lib/libsip/common/sip_headers.c b/usr/src/lib/libsip/common/sip_headers.c
index 64c41de65d..f6d90bf5b5 100644
--- a/usr/src/lib/libsip/common/sip_headers.c
+++ b/usr/src/lib/libsip/common/sip_headers.c
@@ -20,13 +20,20 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sip.h>
+
#include "sip_msg.h"
#include "sip_miscdefs.h"
#include "sip_parse_generic.h"
diff --git a/usr/src/lib/libsip/common/sip_itf.c b/usr/src/lib/libsip/common/sip_itf.c
index 40f3c955e2..db6f1098bf 100644
--- a/usr/src/lib/libsip/common/sip_itf.c
+++ b/usr/src/lib/libsip/common/sip_itf.c
@@ -20,22 +20,24 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#ifdef __linux__
-#include <stdarg.h>
-#else
-#include <sys/varargs.h>
-#endif
-#include "sip_parse_uri.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sip.h>
+
#include "sip_msg.h"
#include "sip_miscdefs.h"
#include "sip_xaction.h"
-#include "sip_hash.h"
#include "sip_dialog.h"
#include "sip_parse_generic.h"
diff --git a/usr/src/lib/libsip/common/sip_miscdefs.h b/usr/src/lib/libsip/common/sip_miscdefs.h
index bfde31527c..c3129d873b 100644
--- a/usr/src/lib/libsip/common/sip_miscdefs.h
+++ b/usr/src/lib/libsip/common/sip_miscdefs.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,8 +33,9 @@
extern "C" {
#endif
+#include <pthread.h>
#include <sys/types.h>
-#include <sip.h>
+#include <sys/time.h>
#define SIP_CR '\r'
#define SIP_SP ' '
diff --git a/usr/src/lib/libsip/common/sip_msg.c b/usr/src/lib/libsip/common/sip_msg.c
index ed1169f66c..f56ca4b70e 100644
--- a/usr/src/lib/libsip/common/sip_msg.c
+++ b/usr/src/lib/libsip/common/sip_msg.c
@@ -20,13 +20,20 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sip.h>
+
#include "sip_msg.h"
#include "sip_miscdefs.h"
#include "sip_parse_generic.h"
diff --git a/usr/src/lib/libsip/common/sip_msg.h b/usr/src/lib/libsip/common/sip_msg.h
index 3c9689257d..a600c1dfef 100644
--- a/usr/src/lib/libsip/common/sip_msg.h
+++ b/usr/src/lib/libsip/common/sip_msg.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,7 +33,9 @@
extern "C" {
#endif
+#include <pthread.h>
#include <sip.h>
+#include <sys/types.h>
#ifdef __solaris__
extern int mutex_held();
diff --git a/usr/src/lib/libsip/common/sip_parse_generic.c b/usr/src/lib/libsip/common/sip_parse_generic.c
index 782a69aa76..b8d0ba0200 100644
--- a/usr/src/lib/libsip/common/sip_parse_generic.c
+++ b/usr/src/lib/libsip/common/sip_parse_generic.c
@@ -20,15 +20,22 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
-#include "sip_msg.h"
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <strings.h>
+#include <ctype.h>
+#include <sip.h>
+
#include "sip_miscdefs.h"
+#include "sip_msg.h"
+#include "sip_parse_uri.h"
/*
* atoi function from a header
diff --git a/usr/src/lib/libsip/common/sip_parse_generic.h b/usr/src/lib/libsip/common/sip_parse_generic.h
index f7fb084f33..5792bee2b0 100644
--- a/usr/src/lib/libsip/common/sip_parse_generic.h
+++ b/usr/src/lib/libsip/common/sip_parse_generic.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,6 +33,11 @@
extern "C" {
#endif
+#include <sip.h>
+#include <sys/types.h>
+
+#include "sip_msg.h"
+
extern int sip_atoi(_sip_header_t *, int *);
extern int sip_find_token(_sip_header_t *, char);
extern int sip_find_cr(_sip_header_t *);
diff --git a/usr/src/lib/libsip/common/sip_parse_hdrs.c b/usr/src/lib/libsip/common/sip_parse_hdrs.c
index fc021678d8..aab94d6a23 100644
--- a/usr/src/lib/libsip/common/sip_parse_hdrs.c
+++ b/usr/src/lib/libsip/common/sip_parse_hdrs.c
@@ -20,16 +20,23 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <sip.h>
+
#include "sip_msg.h"
#include "sip_miscdefs.h"
#include "sip_parse_generic.h"
+#include "sip_parse_uri.h"
+
/*
* Accept = "Accept" HCOLON [ accept-range *(COMMA accept-range) ]
diff --git a/usr/src/lib/libsip/common/sip_parse_uri.c b/usr/src/lib/libsip/common/sip_parse_uri.c
index 8f44309860..15ac022526 100644
--- a/usr/src/lib/libsip/common/sip_parse_uri.c
+++ b/usr/src/lib/libsip/common/sip_parse_uri.c
@@ -20,14 +20,14 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
+#include <ctype.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include "sip_parse_uri.h"
diff --git a/usr/src/lib/libsip/common/sip_reass.c b/usr/src/lib/libsip/common/sip_reass.c
index 0957051307..404a4ec964 100644
--- a/usr/src/lib/libsip/common/sip_reass.c
+++ b/usr/src/lib/libsip/common/sip_reass.c
@@ -20,14 +20,19 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include <sys/socket.h>
-#include <netinet/in.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <ctype.h>
+#include <pthread.h>
+#include <strings.h>
+#include <sip.h>
+
#include "sip_miscdefs.h"
/*
diff --git a/usr/src/lib/libsip/common/sip_timeout.c b/usr/src/lib/libsip/common/sip_timeout.c
index b60cb0b1de..2fd526e8a8 100644
--- a/usr/src/lib/libsip/common/sip_timeout.c
+++ b/usr/src/lib/libsip/common/sip_timeout.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -29,13 +29,9 @@
/*
* Simple implementation of timeout functionality. The granuality is a sec
*/
-#include <stdio.h>
#include <pthread.h>
-#include <sys/errno.h>
#include <stdlib.h>
-#include "sip_miscdefs.h"
-
uint_t sip_timeout(void *arg, void (*callback_func)(void *),
struct timeval *timeout_time);
boolean_t sip_untimeout(uint_t);
@@ -177,7 +173,8 @@ sip_timeout(void *arg, void (*callback_func)(void *),
struct timeval *timeout_time)
{
sip_timeout_t *new_timeout;
- sip_timeout_t *current, *last;
+ sip_timeout_t *current;
+ sip_timeout_t *last;
hrtime_t future_time;
uint_t tid;
#ifdef __linux__
@@ -310,13 +307,21 @@ sip_timer_thr(void *arg)
hrtime_t current_time;
hrtime_t next_timeout;
hrtime_t delta;
+ struct timeval tim;
#ifdef __linux__
struct timespec tspec;
#endif
- to.tv_sec = time(NULL) + 5;
- to.tv_nsec = 0;
+ delta = (hrtime_t)5 * NANOSEC;
(void) pthread_mutex_lock(&timeout_mutex);
for (;;) {
+ (void) gettimeofday(&tim, NULL);
+ to.tv_sec = tim.tv_sec + (delta / NANOSEC);
+ to.tv_nsec = (hrtime_t)(tim.tv_usec * MILLISEC) +
+ (delta % NANOSEC);
+ if (to.tv_nsec > NANOSEC) {
+ to.tv_sec += (to.tv_nsec / NANOSEC);
+ to.tv_nsec %= NANOSEC;
+ }
(void) pthread_cond_timedwait(&timeout_cond_var,
&timeout_mutex, &to);
/*
@@ -336,8 +341,6 @@ again:
delta = next_timeout - current_time;
if (delta <= 0)
goto again;
- to.tv_sec = time(NULL) + (delta / NANOSEC);
- to.tv_nsec = delta % NANOSEC;
}
/* NOTREACHED */
return ((void *)0);
diff --git a/usr/src/lib/libsip/common/sip_ui.c b/usr/src/lib/libsip/common/sip_ui.c
index 20aadcfad7..44f0435490 100644
--- a/usr/src/lib/libsip/common/sip_ui.c
+++ b/usr/src/lib/libsip/common/sip_ui.c
@@ -20,15 +20,24 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_parse_uri.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <strings.h>
+#include <pthread.h>
+#include <sip.h>
+
#include "sip_msg.h"
#include "sip_miscdefs.h"
+#include "sip_parse_uri.h"
#include "sip_xaction.h"
#define SIP_BUF_SIZE 128
diff --git a/usr/src/lib/libsip/common/sip_uri_ui.c b/usr/src/lib/libsip/common/sip_uri_ui.c
index 611091c7bd..5a83f106cc 100644
--- a/usr/src/lib/libsip/common/sip_uri_ui.c
+++ b/usr/src/lib/libsip/common/sip_uri_ui.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -28,7 +28,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include <sys/errno.h>
+#include <errno.h>
#include "sip_parse_uri.h"
diff --git a/usr/src/lib/libsip/common/sip_xaction.c b/usr/src/lib/libsip/common/sip_xaction.c
index 2bc0db2c03..139c9b8402 100644
--- a/usr/src/lib/libsip/common/sip_xaction.c
+++ b/usr/src/lib/libsip/common/sip_xaction.c
@@ -20,12 +20,18 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <strings.h>
+
#include "sip_parse_uri.h"
#include "sip_msg.h"
#include "sip_miscdefs.h"
diff --git a/usr/src/lib/libsip/common/sip_xaction.h b/usr/src/lib/libsip/common/sip_xaction.h
index 441599af49..e3ccaebbae 100644
--- a/usr/src/lib/libsip/common/sip_xaction.h
+++ b/usr/src/lib/libsip/common/sip_xaction.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,9 +33,12 @@
extern "C" {
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <pthread.h>
+#include <sip.h>
+#include <sys/types.h>
+
+#include "sip_msg.h"
+#include "sip_miscdefs.h"
/* Various transaction timers */
typedef enum sip_timer_type_s {
diff --git a/usr/src/lib/libsip/common/sip_xaction_state_mc.c b/usr/src/lib/libsip/common/sip_xaction_state_mc.c
index c8a0087ddf..af991a2ba4 100644
--- a/usr/src/lib/libsip/common/sip_xaction_state_mc.c
+++ b/usr/src/lib/libsip/common/sip_xaction_state_mc.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -30,12 +30,17 @@
* SIP Client/Server Invite/Non-Invite Transaction State machine.
*/
-#include "sip_parse_uri.h"
-#include "sip_msg.h"
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sip.h>
+
#include "sip_miscdefs.h"
+#include "sip_msg.h"
#include "sip_xaction.h"
-
/*
* Some Timer related info from RFC 3261, page 265.
*
diff --git a/usr/src/lib/libsip/common/sip_xaction_ui.c b/usr/src/lib/libsip/common/sip_xaction_ui.c
index 865d13a63d..bc60dfb07d 100644
--- a/usr/src/lib/libsip/common/sip_xaction_ui.c
+++ b/usr/src/lib/libsip/common/sip_xaction_ui.c
@@ -20,14 +20,19 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
-#include "sip_hash.h"
-#include "sip_parse_uri.h"
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <strings.h>
+#include <pthread.h>
+#include <sip.h>
+
#include "sip_msg.h"
#include "sip_miscdefs.h"
#include "sip_xaction.h"