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

📄 sip_refer.c

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 C
📖 第 1 页 / 共 2 页
字号:
}static int sip_referred_by_update(msg_common_t *h, 			   char const *name, isize_t namelen,			   char const *value){  sip_referred_by_t *b = (sip_referred_by_t *)h;  if (name == NULL) {    b->b_cid = NULL;  }  else if (namelen == strlen("cid") && !strncasecmp(name, "cid", namelen)) {    b->b_cid = value;  }  return 0;}/* ====================================================================== *//**@SIP_HEADER sip_replaces Replaces Header * * The Replaces header indicates that a single dialog identified by the * header field is to be shut down and logically replaced by the incoming * INVITE in which it is contained. Its syntax is defined in * @RFC3891 section 6.1 as follows: * * @code *    Replaces        = "Replaces" HCOLON callid *(SEMI replaces-param) *    replaces-param  = to-tag / from-tag / early-flag / generic-param *    to-tag          = "to-tag" EQUAL token *    from-tag        = "from-tag" EQUAL token *    early-flag      = "early-only" * @endcode * * A Replaces header field MUST contain exactly one <to-tag> and exactly * one <from-tag>, as they are required for unique dialog matching.  For * compatibility with dialogs initiated by @RFC2543 compliant UAs, a * tag of zero ("0") matches both tags of zero and null.  A Replaces header * field MAY contain the <early-only> flag. * * The parsed Replaces header is stored in #sip_replaces_t structure. * * @sa @RFC3891, nta_leg_by_replaces(), nta_leg_make_replaces() *//**@ingroup sip_replaces * * @typedef typedef struct sip_replaces_s sip_replaces_t; * * The structure #sip_replaces_t contains representation of @Replaces * header. * * The #sip_replaces_t is defined as follows: * @code * typedef struct sip_replaces_s * { *   sip_common_t        rp_common[1];   // Common fragment info *   sip_error_t        *rp_next;	 // Dummy link to next *   char const         *rp_call_id;     // @CallID of dialog to replace  *   msg_param_t const  *rp_params;      // List of parameters  *   char const         *rp_to_tag;      // Value of "to-tag" parameter  *   char const         *rp_from_tag;    // Value of "from-tag" parameter  *   unsigned            rp_early_only;  // early-only parameter * } sip_replaces_t; * @endcode */static msg_xtra_f sip_replaces_dup_xtra;static msg_dup_f sip_replaces_dup_one;static msg_update_f sip_replaces_update;msg_hclass_t sip_replaces_class[] =SIP_HEADER_CLASS(replaces, "Replaces", "", rp_params, single, replaces);/** Decode (parse) @Replaces header */issize_t sip_replaces_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_replaces_t *rp = h->sh_replaces;  rp->rp_call_id = sip_word_at_word_d(&s);  if (!rp->rp_call_id)    return -1;  if (*s) {    if (msg_params_d(home, &s, &rp->rp_params) == -1)      return -1;    msg_header_update_params(rp->rp_common, 0);  }  return s - rp->rp_call_id;}/** Encode (print) @Replaces header */issize_t sip_replaces_e(char b[], isize_t bsiz, sip_header_t const *h, int flags){  char *b0 = b, *end = b + bsiz;  sip_replaces_t const *rp = h->sh_replaces;  assert(sip_is_replaces(h));  MSG_STRING_E(b, end, rp->rp_call_id);  MSG_PARAMS_E(b, end, rp->rp_params, flags);  MSG_TERM_E(b, end);  return b - b0;}/** Calculate extra storage used by @Replaces header field */isize_t sip_replaces_dup_xtra(sip_header_t const *h, isize_t offset){  sip_replaces_t const *rp = h->sh_replaces;  MSG_PARAMS_SIZE(offset, rp->rp_params);  offset += MSG_STRING_SIZE(rp->rp_call_id);  return offset;}/** Duplicate a @Replaces header field */char *sip_replaces_dup_one(sip_header_t *dst, sip_header_t const *src,			   char *b, isize_t xtra){  sip_replaces_t *rp_dst = dst->sh_replaces;  sip_replaces_t const *rp_src = src->sh_replaces;  char *end = b + xtra;  b = msg_params_dup(&rp_dst->rp_params, rp_src->rp_params, b, xtra);  MSG_STRING_DUP(b, rp_dst->rp_call_id, rp_src->rp_call_id);  assert(b <= end); (void)end;  return b;}/** Update parameters in @Replaces header. */static int sip_replaces_update(msg_common_t *h, 			       char const *name, isize_t namelen,			       char const *value){  sip_replaces_t *rp = (sip_replaces_t *)h;  if (name == NULL) {    rp->rp_to_tag = NULL;    rp->rp_from_tag = NULL;    rp->rp_early_only = 0;  }#define MATCH(s) (namelen == strlen(#s) && !strncasecmp(name, #s, strlen(#s)))  else if (MATCH(to-tag)) {    rp->rp_to_tag = value;  }  else if (MATCH(from-tag)) {    rp->rp_from_tag = value;  }  else if (MATCH(early-only)) {    rp->rp_early_only = value != NULL;  }#undef MATCH  return 0;}/* ====================================================================== *//**@SIP_HEADER sip_refer_sub Refer-Sub Header * * SIP header field @b Refer-Sub is meaningful and MAY be used with a REFER * request and the corresponding 2XX response only. This header field set to * "false" specifies that a REFER-Issuer requests that the REFER-Recipient * doesn't establish an implicit subscription and the resultant dialog. * *  Refer-Sub       = "Refer-Sub" HCOLON refer-sub-value *(SEMI exten) *  refer-sub-value = "true" / "false" *  exten           = generic-param * * The parsed Refer-Sub header is stored in #sip_refer_sub_t structure. *  * @NEW_1_12_5. Note that #sip_t does not contain @a sip_refer_sub field, * but sip_refer_sub() accessor function should be used for accessing @b * Refer-Sub header structure. * * @sa @RFC4488, nua_refer(), #nua_i_refer *//**@ingroup sip_refer_sub * * @typedef typedef struct sip_refer_sub_s sip_refer_sub_t; * * The structure #sip_refer_sub_t contains representation of @ReferSub * header. * * The #sip_refer_sub_t is defined as follows: * @code * typedef struct sip_refer_sub_s * { *   sip_common_t        rs_common[1];   // Common fragment info *   sip_error_t        *rs_next;	 // Dummy link to next *   char const         *rs_value;       // "true" or "false" *   msg_param_t const  *rs_params;      // List of extension parameters  * } sip_refer_sub_t; * @endcode *  * @NEW_1_12_5. */static msg_xtra_f sip_refer_sub_dup_xtra;static msg_dup_f sip_refer_sub_dup_one;#define sip_refer_sub_update NULLmsg_hclass_t sip_refer_sub_class[] =SIP_HEADER_CLASS(refer_sub, "Refer-Sub", "", rs_params, single, refer_sub);/** Decode (parse) @ReferSub header */issize_t sip_refer_sub_d(su_home_t *home,			 sip_header_t *h,			 char *s, isize_t slen){  sip_refer_sub_t *rs = (sip_refer_sub_t *)h;  if (msg_token_d(&s, &rs->rs_value) < 0)    return -1;  if (strcasecmp(rs->rs_value, "false") &&       strcasecmp(rs->rs_value, "true"))    return -1;  if (*s)    if (msg_params_d(home, &s, &rs->rs_params) == -1)      return -1;  return s - rs->rs_value;}/** Encode (print) @ReferSub header */issize_t sip_refer_sub_e(char b[], isize_t bsiz,			 sip_header_t const *h,			 int flags){  char *b0 = b, *end = b + bsiz;  sip_refer_sub_t const *rs = (sip_refer_sub_t *)h;  assert(sip_is_refer_sub(h));  MSG_STRING_E(b, end, rs->rs_value);  MSG_PARAMS_E(b, end, rs->rs_params, flags);  MSG_TERM_E(b, end);  return b - b0;}/** Calculate extra storage used by @ReferSub header field */isize_t sip_refer_sub_dup_xtra(sip_header_t const *h, isize_t offset){  sip_refer_sub_t const *rs = (sip_refer_sub_t *)h;  MSG_PARAMS_SIZE(offset, rs->rs_params);  offset += MSG_STRING_SIZE(rs->rs_value);  return offset;}/** Duplicate a @ReferSub header field */char *sip_refer_sub_dup_one(sip_header_t *dst, sip_header_t const *src,			   char *b, isize_t xtra){  sip_refer_sub_t *rs_dst = (sip_refer_sub_t *)dst;  sip_refer_sub_t const *rs_src = (sip_refer_sub_t *)src;  char *end = b + xtra;  b = msg_params_dup(&rs_dst->rs_params, rs_src->rs_params, b, xtra);  MSG_STRING_DUP(b, rs_dst->rs_value, rs_src->rs_value);  assert(b <= end); (void)end;  return b;}

⌨️ 快捷键说明

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