FreeCalypso > hg > themwi-system-sw
comparison sip-manual-out/uac.c @ 123:a36b731bfef9
sip-manual-out: implement sending BYE and CANCEL
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 29 Sep 2022 17:21:11 -0800 |
parents | c62d0f28da6f |
children | 6ac96217c442 |
comparison
equal
deleted
inserted
replaced
122:07e4cc5f824c | 123:a36b731bfef9 |
---|---|
24 extern char call_id[], from_uri[], to_uri[]; | 24 extern char call_id[], from_uri[], to_uri[]; |
25 extern unsigned max_forwards; | 25 extern unsigned max_forwards; |
26 | 26 |
27 char to_tag[MAX_TO_TAG+1]; | 27 char to_tag[MAX_TO_TAG+1]; |
28 | 28 |
29 add_req_boilerplate(msg, cseq) | 29 add_req_boilerplate(msg, cseq, add_to_tag) |
30 struct sip_msg_out *msg; | 30 struct sip_msg_out *msg; |
31 char *cseq; | 31 char *cseq; |
32 { | 32 { |
33 char strbuf[256]; | 33 char strbuf[256]; |
34 int rc; | 34 int rc; |
39 if (rc < 0) | 39 if (rc < 0) |
40 return rc; | 40 return rc; |
41 rc = out_msg_add_header(msg, "From", from_uri); | 41 rc = out_msg_add_header(msg, "From", from_uri); |
42 if (rc < 0) | 42 if (rc < 0) |
43 return rc; | 43 return rc; |
44 if (to_tag[0]) { | 44 if (add_to_tag && to_tag[0]) { |
45 sprintf(strbuf, "<%s>;tag=%s", to_uri, to_tag); | 45 sprintf(strbuf, "<%s>;tag=%s", to_uri, to_tag); |
46 rc = out_msg_add_header(msg, "To", strbuf); | 46 rc = out_msg_add_header(msg, "To", strbuf); |
47 } else | 47 } else |
48 rc = out_msg_add_header(msg, "To", to_uri); | 48 rc = out_msg_add_header(msg, "To", to_uri); |
49 if (rc < 0) | 49 if (rc < 0) |
78 rc = start_request_out_msg(&msg, "ACK", to_uri); | 78 rc = start_request_out_msg(&msg, "ACK", to_uri); |
79 if (rc < 0) { | 79 if (rc < 0) { |
80 msg_size_err: fprintf(stderr, "composing ACK message: size error\n"); | 80 msg_size_err: fprintf(stderr, "composing ACK message: size error\n"); |
81 return; | 81 return; |
82 } | 82 } |
83 rc = add_req_boilerplate(&msg, "1 ACK"); | 83 rc = add_req_boilerplate(&msg, "1 ACK", 1); |
84 if (rc < 0) | 84 if (rc < 0) |
85 goto msg_size_err; | 85 goto msg_size_err; |
86 out_msg_finish(&msg); | 86 out_msg_finish(&msg); |
87 sip_tx_packet(&msg, sin); | 87 sip_tx_packet(&msg, sin); |
88 } | 88 } |
127 printf("Got SIP response with wrong Call-ID\n"); | 127 printf("Got SIP response with wrong Call-ID\n"); |
128 return; | 128 return; |
129 } | 129 } |
130 if (rid.cseq_num == 1 && !strcmp(rid.cseq_method, "INVITE")) | 130 if (rid.cseq_num == 1 && !strcmp(rid.cseq_method, "INVITE")) |
131 handle_invite_response(msg, sin); | 131 handle_invite_response(msg, sin); |
132 else if (rid.cseq_num == 1 && !strcmp(rid.cseq_method, "CANCEL")) | |
133 printf("Response to CANCEL: %s\n", msg->status_str); | |
134 else if (rid.cseq_num == 2 && !strcmp(rid.cseq_method, "BYE")) | |
135 printf("Response to BYE: %s\n", msg->status_str); | |
132 else | 136 else |
133 printf("Got SIP resp for our Call-ID with unknown CSeq %u %s\n", | 137 printf("Got SIP resp for our Call-ID with unknown CSeq %u %s\n", |
134 rid.cseq_num, rid.cseq_method); | 138 rid.cseq_num, rid.cseq_method); |
135 } | 139 } |