⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sip_extra.c

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 C
📖 第 1 页 / 共 3 页
字号:
/* ====================================================================== *//**@SIP_HEADER sip_priority Priority Header *  * The Priority request-header field indicates the urgency of the request as * perceived by the client. Its syntax is defined in @RFC3261 as follows: *  * @code *    Priority        =  "Priority" HCOLON priority-value *    priority-value  =  "emergency" / "urgent" / "normal" *                       / "non-urgent" / other-priority *    other-priority  =  token * @endcode *  * * The parsed Priority header is stored in #sip_priority_t structure. *//**@ingroup sip_priority * @typedef struct msg_generic_s sip_priority_t;  * * The structure #sip_priority_t contains representation of a SIP  * @Priority header. * * The #sip_priority_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Dummy link to next header *   char const    *g_string;	    // Priority token * } sip_priority_t; * @endcode */msg_hclass_t sip_priority_class[] = SIP_HEADER_CLASS_G(priority, "Priority", "", single);issize_t sip_priority_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_priority_t *priority = (sip_priority_t *)h;    if (msg_token_d(&s, &priority->g_string) < 0)    return -1;  if (*s && !IS_LWS(*s))	/* Something extra after priority token? */    return -1;  return 0;}issize_t sip_priority_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  assert(sip_priority_p(h));  return sip_generic_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_server Server Header *  * The Server response-header field contains information about the software * used by the user agent server to handle the request. Its syntax is * defined in @RFC2616 section 14.38 and @RFC3261 as follows: *  * @code *    Server           =  "Server" HCOLON server-val *(LWS server-val) *    server-val       =  product / comment *    product          =  token [SLASH product-version] *    product-version  =  token * @endcode * * The parsed Server header is stored in #sip_server_t structure. *//**@ingroup sip_server * @typedef struct msg_generic_s sip_server_t;  * * The structure #sip_server_t contains representation of a SIP  * @Server header. * * The #sip_server_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // Server tokens * } sip_server_t; * @endcode */msg_hclass_t sip_server_class[] = SIP_HEADER_CLASS_G(server, "Server", "", single);issize_t sip_server_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  return sip_generic_d(home, h, s, slen);}issize_t sip_server_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  assert(sip_server_p(h));  return sip_generic_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_subject Subject Header *  * The Subject header provides a summary or indicates the nature of the * request. Its syntax is defined in @RFC3261 as follows: *  * @code *    Subject  =  ( "Subject" / "s" ) HCOLON [TEXT-UTF8-TRIM] * @endcode *  * The parsed Subject header is stored in #sip_subject_t structure. *//**@ingroup sip_subject * @typedef struct msg_generic_s sip_subject_t;  * * The structure #sip_subject_t contains representation of a SIP  * @Subject header. * * The #sip_subject_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // Subject text * } sip_subject_t; * @endcode */msg_hclass_t sip_subject_class[] = SIP_HEADER_CLASS_G(subject, "Subject", "s", single);issize_t sip_subject_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  return sip_generic_d(home, h, s, slen);}issize_t sip_subject_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  assert(sip_subject_p(h));  return sip_generic_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_timestamp Timestamp Header *  * The @b Timestamp header describes when the client sent the request to the * server, and it is used by the client to adjust its retransmission * intervals. Its syntax is defined in @RFC3261 as follows: *  * @code *    Timestamp  =  "Timestamp" HCOLON 1*(DIGIT) *                   [ "." *(DIGIT) ] [ LWS delay ] *    delay      =  *(DIGIT) [ "." *(DIGIT) ] * @endcode *  * The parsed Timestamp header is stored in #sip_timestamp_t structure. *//**@ingroup sip_timestamp * @typedef struct sip_timestamp_s sip_timestamp_t;  * * The structure #sip_timestamp_t contains representation of a SIP  * @Timestamp header. * * The #sip_timestamp_t is defined as follows: * @code * typedef struct sip_timestamp_s * { *   sip_common_t        ts_common[1]; // Common fragment info *   sip_error_t        *ts_next;      // Dummy link *   char const         *ts_stamp;     // Original timestamp *   char const         *ts_delay;     // Delay at UAS * } sip_timestamp_t; * @endcode */static isize_t sip_timestamp_dup_xtra(sip_header_t const *h, isize_t offset);static char *sip_timestamp_dup_one(sip_header_t *dst,				   sip_header_t const *src,				   char *b,				   isize_t xtra);#define sip_timestamp_update NULLmsg_hclass_t sip_timestamp_class[] = SIP_HEADER_CLASS(timestamp, "Timestamp", "", ts_common, single,		 timestamp);issize_t sip_timestamp_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_timestamp_t *ts = (sip_timestamp_t*)h;  ts->ts_stamp = s;  s += span_digit(s);   if (s == ts->ts_stamp)    return -1;  if (*s == '.') { s += span_digit(s + 1) + 1; }  if (IS_LWS(*s)) {    *s = '\0';    s += span_lws(s + 1) + 1;    ts->ts_delay = s;    s += span_digit(s); if (*s == '.') { s += span_digit(s + 1) + 1; }  }  if (!*s || IS_LWS(*s))    *s++ = '\0';  else    return -1;    return 0;}issize_t sip_timestamp_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  sip_timestamp_t const *ts = h->sh_timestamp;  char *end = b + bsiz, *b0 = b;  assert(sip_timestamp_p(h));  MSG_STRING_E(b, end, ts->ts_stamp);  if (ts->ts_delay) {    MSG_CHAR_E(b, end, ' ');    MSG_STRING_E(b, end, ts->ts_delay);  }  MSG_TERM_E(b, end);      return b - b0;}staticisize_t sip_timestamp_dup_xtra(sip_header_t const *h, isize_t offset){  sip_timestamp_t const *ts = h->sh_timestamp;  offset += MSG_STRING_SIZE(ts->ts_stamp);  offset += MSG_STRING_SIZE(ts->ts_delay);  return offset;}staticchar *sip_timestamp_dup_one(sip_header_t *dst,			    sip_header_t const *src,			    char *b,			    isize_t xtra){  sip_timestamp_t *ts = dst->sh_timestamp;  sip_timestamp_t const *o = src->sh_timestamp;  char *end = b + xtra;  MSG_STRING_DUP(b, ts->ts_stamp, o->ts_stamp);  MSG_STRING_DUP(b, ts->ts_delay, o->ts_delay);  assert(b <= end); (void)end;  return b;}/* ====================================================================== *//**@SIP_HEADER sip_user_agent User-Agent Header *  * The User-Agent header contains information about the client user agent * originating the request. Its syntax is defined in [H14.43, S10.45] as * follows: *  * @code *    User-Agent       =  "User-Agent" HCOLON server-val *(LWS server-val) *    server-val       =  product / comment *    product          =  token [SLASH product-version] *    product-version  =  token * @endcode *  * The parsed User-Agent header is stored in #sip_user_agent_t structure. *//**@ingroup sip_user_agent * @typedef struct msg_generic_s sip_user_agent_t;  * * The structure #sip_user_agent_t contains representation of a SIP  * @UserAgent header. * * The #sip_user_agent_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // User-Agent components * } sip_user_agent_t; * @endcode */msg_hclass_t sip_user_agent_class[] = SIP_HEADER_CLASS_G(user_agent, "User-Agent", "", single);issize_t sip_user_agent_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  return sip_generic_d(home, h, s, slen);}issize_t sip_user_agent_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  assert(sip_user_agent_p(h));  return sip_generic_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_etag SIP-ETag Header *  * The @b SIP-ETag header field identifies the published event state. Its * syntax is defined in @RFC3903 as follows: *  * @code *      SIP-ETag           = "SIP-ETag" HCOLON entity-tag *      entity-tag         = token * @endcode * * The parsed SIP-ETag header is stored in #sip_etag_t structure. *//**@ingroup sip_etag * @typedef struct msg_generic_s sip_etag_t;  * * The structure #sip_etag_t contains representation of a SIP  * @SIPETag header. * * The #sip_etag_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // entity-tag * } sip_etag_t; * @endcode */msg_hclass_t sip_etag_class[] = SIP_HEADER_CLASS_G(etag, "SIP-ETag", "", single);issize_t sip_etag_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_etag_t *etag = (sip_etag_t *)h;  return msg_token_d(&s, &etag->g_value);}issize_t sip_etag_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  return msg_generic_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_if_match SIP-If-Match Header *  * The @b SIP-If-Match header field identifies the specific entity of event * state that the request is refreshing, modifying or removing. Its syntax * is defined in @RFC3903 as follows: *  * @code *      SIP-If-Match       = "SIP-If-Match" HCOLON entity-tag *      entity-tag         = token * @endcode * * The parsed SIP-If-Match header is stored in #sip_if_match_t structure. *//**@ingroup sip_if_match * @typedef struct msg_generic_s sip_if_match_t;  * * The structure #sip_if_match_t contains representation of a SIP  * @SIPIfMatch header. * * The #sip_if_match_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // entity-tag * } sip_if_match_t; * @endcode */msg_hclass_t sip_if_match_class[] = SIP_HEADER_CLASS_G(if_match, "SIP-If-Match", "", single);issize_t sip_if_match_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  return sip_etag_d(home, h, s, slen);}issize_t sip_if_match_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  return sip_etag_e(b, bsiz, h, f);}/* ====================================================================== *//** Parsing @CallInfo, @ErrorInfo. */staticissize_t sip_info_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_call_info_t *ci = h->sh_call_info;  char *end = s + slen;  assert(h);  while (*s == ',')    s += span_lws(s + 1) + 1;  if (sip_name_addr_d(home, &s, NULL, ci->ci_url, &ci->ci_params, NULL) < 0)    return -1;  /* Recurse */  return msg_parse_next_field(home, h, s, end - s);}isize_t sip_info_dup_xtra(sip_header_t const *h, isize_t offset){  sip_call_info_t const *ci = h->sh_call_info;  return sip_name_addr_xtra(NULL,			    ci->ci_url,			    ci->ci_params,			    offset);}char *sip_info_dup_one(sip_header_t *dst,		       sip_header_t const *src,		       char *b,		       isize_t xtra){  sip_call_info_t *ci = dst->sh_call_info;  sip_call_info_t const *o = src->sh_call_info;  return sip_name_addr_dup(NULL, NULL,			   ci->ci_url, o->ci_url,			   &ci->ci_params, o->ci_params,			   b, xtra);}/* ====================================================================== */#if SU_HAVE_EXPERIMENTAL/**@SIP_HEADER sip_suppress_body_if_match Suppress-Body-If-Match Header * * The @b Suppress-Body-If-Match header field identifies a SIP event content * already known by the watcher. Its syntax is defined in * draft-niemi-sip-subnot-etags-01 as follows: * * @code *    Suppress-Body-If-Match = "Suppress-Body-If-Match" HCOLON entity-tag *    entity-tag             = token

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -