comparison sip-manual-out/uac.c @ 118:a4450ae8fd09

sip-manual-out UAC: use the new CSeq parsing function
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 29 Sep 2022 13:03:27 -0800
parents d7b6b8973a83
children c62d0f28da6f
comparison
equal deleted inserted replaced
117:c93c339271a7 118:a4450ae8fd09
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
11 #include <string.h> 11 #include <string.h>
12 #include <strings.h> 12 #include <strings.h>
13 #include "../libsip/parse.h" 13 #include "../libsip/parse.h"
14 #include "../libsip/resp_ident.h"
14 #include "../libsip/out_msg.h" 15 #include "../libsip/out_msg.h"
15 16
16 #define MAX_TO_TAG 63 17 #define MAX_TO_TAG 63
17 18
18 extern char *get_single_header(); 19 extern char *get_single_header();
109 void 110 void
110 process_sip_response(msg, sin) 111 process_sip_response(msg, sin)
111 struct sip_pkt_rx *msg; 112 struct sip_pkt_rx *msg;
112 struct sockaddr_in *sin; 113 struct sockaddr_in *sin;
113 { 114 {
114 char *call_id_hdr, *cseq_hdr; 115 struct sip_resp_ident rid;
116 int rc;
115 117
116 call_id_hdr = get_single_header(msg, "Call-ID", "i", (int *) 0); 118 rc = sip_resp_extract_ident(msg, &rid);
117 if (!call_id_hdr) { 119 if (rc < 0) {
118 printf("Got SIP response w/o Call-ID header\n"); 120 printf("SIP %03u response: bad or missing %s header\n",
121 msg->status_code, rid.error_field);
119 return; 122 return;
120 } 123 }
121 if (strcmp(call_id_hdr, call_id)) { 124 if (strcmp(rid.call_id, call_id)) {
122 printf("Got SIP response with wrong Call-ID\n"); 125 printf("Got SIP response with wrong Call-ID\n");
123 return; 126 return;
124 } 127 }
125 cseq_hdr = get_single_header(msg, "CSeq", (char *) 0, (int *) 0); 128 if (rid.cseq_num == 1 && !strcmp(rid.cseq_method, "INVITE"))
126 if (!cseq_hdr) {
127 printf("Got SIP response w/o CSeq header\n");
128 return;
129 }
130 if (!strcmp(cseq_hdr, "1 INVITE"))
131 handle_invite_response(msg, sin); 129 handle_invite_response(msg, sin);
132 else 130 else
133 printf("Got SIP resp for our Call-ID with unknown CSeq %s\n", 131 printf("Got SIP resp for our Call-ID with unknown CSeq %u %s\n",
134 cseq_hdr); 132 rid.cseq_num, rid.cseq_method);
135 } 133 }