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, ©->authorizations, (int (*)(void *, void **)) & osip_authorization_clone);
if (i != 0) {
osip_message_free(copy);
return i;
}
i = osip_list_clone(&sip->securityinfo, ©->securityinfo, (int (*)(void*, void**)) & osip_securityinfo_clone);
if (i != 0) {
osip_message_free(copy);
return i;
}
i = osip_list_clone(&sip->mtnote, ©->mtnote, (int (*)(void*, void**)) & osip_mtnote_clone);
if (i != 0) {
osip_message_free(copy);
return i;
}
需要注意的是osip_parser_cfg.c 中NUMBER_OF_HEADERS 的大小 数据不能大不能小要刚刚好、大了报错 小了有字段解析不出来