MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / encode_contact

Function encode_contact

modules/mangler/contact_ops.c:44–142  ·  view source on GitHub ↗

define DEBUG

Source from the content-addressed store, hash-verified

42
43//#define DEBUG
44int
45encode_contact (struct sip_msg *msg, str *encoding_prefix, str *public_ip)
46{
47
48 contact_body_t *cb;
49 contact_t *c;
50 str uri;
51 str newUri;
52 int res;
53 char separator;
54
55 /*
56 * I have a list of contacts in contact->parsed which is of type
57 * contact_body_t inside i have a contact->parsed->contact which is the
58 * head of the list of contacts inside it is a
59 * str uri;
60 * struct contact *next;
61 * I just have to visit each uri and encode each uri according to a scheme
62 */
63
64 if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT_F,0) == -1) ||
65 (msg->contact == NULL) ))
66 {
67 LM_ERR("no Contact header present\n");
68 return -1;
69 }
70
71
72 separator = DEFAULT_SEPARATOR[0];
73 if (contact_flds_separator != NULL)
74 if (strlen(contact_flds_separator)>=1)
75 separator = contact_flds_separator[0];
76
77 if (msg->contact->parsed == NULL && parse_contact (msg->contact) < 0) {
78 LM_ERR("cannnot parse contact header!\n");
79 return -1;
80 }
81 if (msg->contact->parsed != NULL)
82 {
83 cb = (contact_body_t *) msg->contact->parsed;
84 c = cb->contacts;
85 /* we visit each contact */
86 if (c != NULL)
87 {
88 uri = c->uri;
89 if ((uri.s < msg->buf) || (uri.s > (msg->buf + msg->len))) {
90 LM_ERR("you can't encode a contact that was aleady "
91 "changed !!!\n");
92 return -1;
93 }
94
95 res = encode_uri(uri, encoding_prefix,public_ip,separator,&newUri);
96 if (res != 0)
97 {
98 LM_ERR("failed encoding contact.Code %d\n", res);
99#ifdef STRICT_CHECK
100 return res;
101#endif

Callers 1

func_inviteFunction · 0.85

Calls 3

parse_contactFunction · 0.85
patchFunction · 0.85
encode_uriFunction · 0.70

Tested by

no test coverage detected