summaryrefslogtreecommitdiff
path: root/pjsip/include
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-06-26 00:25:11 +0000
committerBenny Prijono <bennylp@teluu.com>2007-06-26 00:25:11 +0000
commit5c5a5345ea7419e15bfdc457487f66803de5b021 (patch)
treece7655b85a613491e4d800d7a44d1ba35bfcbd74 /pjsip/include
parentdd49a84c46ef7ea0cb755bfa8e78e6395f544c4e (diff)
Ticket #342: added configuration to send compact form of SIP headers
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1389 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include')
-rw-r--r--pjsip/include/pjsip/print_util.h18
-rw-r--r--pjsip/include/pjsip/sip_config.h29
2 files changed, 45 insertions, 2 deletions
diff --git a/pjsip/include/pjsip/print_util.h b/pjsip/include/pjsip/print_util.h
index c75b6e27..d7f30a08 100644
--- a/pjsip/include/pjsip/print_util.h
+++ b/pjsip/include/pjsip/print_util.h
@@ -101,13 +101,27 @@
typedef void* (*pjsip_hdr_clone_fptr)(pj_pool_t *, const void*);
typedef int (*pjsip_hdr_print_fptr)(void *hdr, char *buf, pj_size_t len);
-extern const pj_str_t pjsip_hdr_names[];
+typedef struct pjsip_hdr_name_info_t
+{
+ char *name;
+ unsigned name_len;
+ char *sname;
+} pjsip_hdr_name_info_t;
+
+extern const pjsip_hdr_name_info_t pjsip_hdr_names[];
PJ_INLINE(void) init_hdr(void *hptr, pjsip_hdr_e htype, void *vptr)
{
pjsip_hdr *hdr = (pjsip_hdr*) hptr;
hdr->type = htype;
- hdr->name = hdr->sname = pjsip_hdr_names[htype];
+ hdr->name.ptr = pjsip_hdr_names[htype].name;
+ hdr->name.slen = pjsip_hdr_names[htype].name_len;
+ if (pjsip_hdr_names[htype].sname) {
+ hdr->sname.ptr = pjsip_hdr_names[htype].sname;
+ hdr->sname.slen = 1;
+ } else {
+ hdr->sname = hdr->name;
+ }
hdr->vptr = (pjsip_hdr_vptr*) vptr;
pj_list_init(hdr);
}
diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h
index a95a4189..315cd830 100644
--- a/pjsip/include/pjsip/sip_config.h
+++ b/pjsip/include/pjsip/sip_config.h
@@ -129,6 +129,35 @@
/**
+ * Encode SIP headers in their short forms to reduce size. By default,
+ * SIP headers in outgoing messages will be encoded in their full names.
+ * If this option is enabled, then SIP headers for outgoing messages
+ * will be encoded in their short forms, to reduce message size.
+ * Note that this does not affect the ability of PJSIP to parse incoming
+ * SIP messages, as the parser always supports parsing both the long
+ * and short version of the headers.
+ *
+ * Note that there is also an undocumented variable defined in sip_msg.c
+ * to control whether compact form should be used for encoding SIP
+ * headers. The default value of this variable is PJSIP_ENCODE_SHORT_HNAME.
+ * To change PJSIP behavior during run-time, application can use the
+ * following construct:
+ *
+ \verbatim
+ extern pj_bool_t pjsip_use_compact_form;
+
+ // enable compact form
+ pjsip_use_compact_form = PJ_TRUE;
+ \endverbatim
+ *
+ * Default is 0 (no)
+ */
+#ifndef PJSIP_ENCODE_SHORT_HNAME
+# define PJSIP_ENCODE_SHORT_HNAME 0
+#endif
+
+
+/**
* Allow SIP modules removal or insertions during operation?
* If yes, then locking will be employed when endpoint need to
* access module.