comparison sip-in/sip_ack.c @ 69:8cf85edca543

sip-in: implement SIP ACK handling
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 19 Sep 2022 14:55:57 -0800
parents
children 3e3fbf44f9d7
comparison
equal deleted inserted replaced
68:709b78a4ebf0 69:8cf85edca543
1 /*
2 * Here we implement our handling of SIP ACK, the last step
3 * in the 3-way INVITE handshake.
4 */
5
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <netinet/in.h>
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <strings.h>
14 #include <syslog.h>
15 #include "../libsip/parse.h"
16 #include "../libsip/uas_basic.h"
17 #include "call.h"
18
19 extern struct call *find_call_by_sip_id();
20
21 void
22 handle_sip_ack(req, ess, sin)
23 struct sip_pkt_rx *req;
24 struct uas_parse_hdrs *ess;
25 struct sockaddr_in *sin;
26 {
27 struct call *call;
28
29 call = find_call_by_sip_id(ess->call_id);
30 if (!call)
31 return; /* ignore spurious ACK */
32 /* weed out wrong CSeq */
33 if (ess->cseq_num != call->invite_cseq)
34 return;
35 switch (call->sip_state) {
36 case SIP_STATE_INVITE_200:
37 call->sip_state = SIP_STATE_CONNECTED;
38 break;
39 case SIP_STATE_INVITE_ERR:
40 call->sip_state = SIP_STATE_ENDED;
41 break;
42 }
43 }