FreeCalypso > hg > themwi-system-sw
annotate sip-in/sip_ack.c @ 82:ff4b76a107a1
sip-in: process responses as UAC for BYE
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 20 Sep 2022 20:33:09 -0800 |
parents | 8cf85edca543 |
children | 3e3fbf44f9d7 |
rev | line source |
---|---|
69
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Here we implement our handling of SIP ACK, the last step |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * in the 3-way INVITE handshake. |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/socket.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <netinet/in.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <syslog.h> |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "../libsip/parse.h" |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../libsip/uas_basic.h" |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "call.h" |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern struct call *find_call_by_sip_id(); |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 void |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 handle_sip_ack(req, ess, sin) |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 struct sip_pkt_rx *req; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 struct uas_parse_hdrs *ess; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct sockaddr_in *sin; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 { |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 struct call *call; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 call = find_call_by_sip_id(ess->call_id); |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 if (!call) |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 return; /* ignore spurious ACK */ |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 /* weed out wrong CSeq */ |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 if (ess->cseq_num != call->invite_cseq) |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 return; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 switch (call->sip_state) { |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 case SIP_STATE_INVITE_200: |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 call->sip_state = SIP_STATE_CONNECTED; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 break; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 case SIP_STATE_INVITE_ERR: |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 call->sip_state = SIP_STATE_ENDED; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 break; |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
8cf85edca543
sip-in: implement SIP ACK handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 } |