osip 修改适用于28181和35114

1、复制 osip_authorization.h  和 osip_authorization.c 

2、修改文件名称函数为osip_securityinfo 和 osip_mtnote

3、将四个文件中 authorization 替换成 securityinfo mtnote

4、在osip_parse_cfg.c 中添加osip_message_set_(securityinfo mtnote)

 pconfig[i].hname = AUTHORIZATION;
  pconfig[i].ignored_when_invalid = 1;
  pconfig[i++].setheader = (&osip_message_set_authorization);
  pconfig[i].hname = SECURITYINFO;
  pconfig[i].ignored_when_invalid = 1;
  pconfig[i++].setheader = (&osip_message_set_securityinfo);
  pconfig[i].hname = MTNOTE;
  pconfig[i].ignored_when_invalid = 1;
  pconfig[i++].setheader = (&osip_message_set_mtnote);
  pconfig[i].hname = CONTENT_TYPE_SHORT; /* "l" */
  pconfig[i].ignored_when_invalid = 0;
  pconfig[i++].setheader = (&osip_message_set_content_type);
  pconfig[i].hname = CALL_ID;
  pconfig[i].ignored_when_invalid = 0;

5、_osip_message_to_str 文件中添加字段和字符串解析 及header_list

#ifndef MINISIZE
    table[32] =
#else
    table[25] =
#endif
        {{"Via: ", 5, NULL, NULL, (int (*)(void *, char **)) & osip_via_to_str},
         {"Record-Route: ", 14, NULL, NULL, (int (*)(void *, char **)) & osip_record_route_to_str},
         {"Route: ", 7, NULL, NULL, (int (*)(void *, char **)) & osip_route_to_str},
         {"From: ", 6, NULL, NULL, (int (*)(void *, char **)) & osip_from_to_str},
         {"To: ", 4, NULL, NULL, (int (*)(void *, char **)) & osip_to_to_str},
         {"Call-ID: ", 9, NULL, NULL, (int (*)(void *, char **)) & osip_call_id_to_str},
         {"CSeq: ", 6, NULL, NULL, (int (*)(void *, char **)) & osip_cseq_to_str},
         {"Contact: ", 9, NULL, NULL, (int (*)(void *, char **)) & osip_contact_to_str},
         {"Authorization: ", 15, NULL, NULL, (int (*)(void *, char **)) & osip_authorization_to_str},
         {"WWW-Authenticate: ", 18, NULL, NULL, (int (*)(void *, char **)) & osip_www_authenticate_to_str},
         {"Proxy-Authenticate: ", 20, NULL, NULL, (int (*)(void *, char **)) & osip_www_authenticate_to_str},
         {"Proxy-Authorization: ", 21, NULL, NULL, (int (*)(void *, char **)) & osip_authorization_to_str},
         {"Call-Info: ", 11, NULL, NULL, (int (*)(void *, char **)) & osip_call_info_to_str},
         {"Content-Type: ", 14, NULL, NULL, (int (*)(void *, char **)) & osip_content_type_to_str},
         {"Mime-Version: ", 14, NULL, NULL, (int (*)(void *, char **)) & osip_content_length_to_str},
         {"SecurityInfo: ", 14, NULL, NULL, (int (*)(void*, char**)) & osip_securityinfo_to_str},
         {"Note: ", 6, NULL, NULL, (int (*)(void*, char**)) & osip_mtnote_to_str},
#ifndef MINISIZE
         {"Allow: ", 7, NULL, NULL, (int (*)(void *, char **)) & osip_allow_to_str},
         {"Content-Encoding: ", 18, NULL, NULL, (int (*)(void *, char **)) & osip_content_encoding_to_str},
         {"Alert-Info: ", 12, NULL, NULL, (int (*)(void *, char **)) & osip_call_info_to_str},
         {"Error-Info: ", 12, NULL, NULL, (int (*)(void *, char **)) & osip_call_info_to_str},
         {"Accept: ", 8, NULL, NULL, (int (*)(void *, char **)) & osip_accept_to_str},
         {"Accept-Encoding: ", 17, NULL, NULL, (int (*)(void *, char **)) & osip_accept_encoding_to_str},
         {"Accept-Language: ", 17, NULL, NULL, (int (*)(void *, char **)) & osip_accept_language_to_str},
         {"Authentication-Info: ", 21, NULL, NULL, (int (*)(void *, char **)) & osip_authentication_info_to_str},
         {"Proxy-Authentication-Info: ", 27, NULL, NULL, (int (*)(void *, char **)) & osip_authentication_info_to_str},
#endif
         {{'\0'}, 0, NULL, NULL, NULL}};
    pos = 0;
    table[pos++].header_list = &sip->vias;
    table[pos++].header_list = &sip->record_routes;
    table[pos++].header_list = &sip->routes;
    table[pos++].header_data = sip->from;
    table[pos++].header_data = sip->to;
    table[pos++].header_data = sip->call_id;
    table[pos++].header_data = sip->cseq;
    table[pos++].header_list = &sip->contacts;
    table[pos++].header_list = &sip->authorizations;
    table[pos++].header_list = &sip->www_authenticates;
    table[pos++].header_list = &sip->proxy_authenticates;
    table[pos++].header_list = &sip->proxy_authorizations;
    table[pos++].header_list = &sip->call_infos;
    table[pos++].header_data = sip->content_type;
    table[pos++].header_data = sip->mime_version;
    table[pos++].header_list = &sip->securityinfo;
    table[pos++].header_list = &sip->mtnote;

6、在osip_message.c 中添加资源释放函数

 osip_list_special_free(&sip->authorizations, (void (*)(void *)) & osip_authorization_free);
  osip_list_special_free(&sip->securityinfo, (void (*)(void*)) & osip_securityinfo_free);
  osip_list_special_free(&sip->mtnote, (void (*)(void*)) & osip_mtnote_free);

6、在osip_message.c 添加函数克隆

i = osip_list_clone(&sip->authorizations, &copy->authorizations, (int (*)(void *, void **)) & osip_authorization_clone);

  if (i != 0) {
    osip_message_free(copy);
    return i;
  }

  i = osip_list_clone(&sip->securityinfo, &copy->securityinfo, (int (*)(void*, void**)) & osip_securityinfo_clone);

  if (i != 0) {
	  osip_message_free(copy);
	  return i;
  }

  i = osip_list_clone(&sip->mtnote, &copy->mtnote, (int (*)(void*, void**)) & osip_mtnote_clone);
  if (i != 0) {
	  osip_message_free(copy);
	  return i;
  }

需要注意的是osip_parser_cfg.c 中NUMBER_OF_HEADERS 的大小  数据不能大不能小要刚刚好、大了报错 小了有字段解析不出来

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ww506772362

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值