FreeCalypso > hg > themwi-system-sw
comparison sip-manual-out/uas.c @ 147:94b5831c017f
sip-manual-out code: split bye_in.c from uas.c
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 08 Oct 2022 23:01:32 -0800 |
| parents | dd845c4933e1 |
| children | b51247739897 |
comparison
equal
deleted
inserted
replaced
| 146:54c2f271380d | 147:94b5831c017f |
|---|---|
| 10 #include <string.h> | 10 #include <string.h> |
| 11 #include <strings.h> | 11 #include <strings.h> |
| 12 #include "../libsip/parse.h" | 12 #include "../libsip/parse.h" |
| 13 #include "../libsip/uas_basic.h" | 13 #include "../libsip/uas_basic.h" |
| 14 #include "../libsip/out_msg.h" | 14 #include "../libsip/out_msg.h" |
| 15 | |
| 16 extern char call_id[]; | |
| 17 | |
| 18 static void | |
| 19 bye_correct_call(req, ess, sin) | |
| 20 struct sip_pkt_rx *req; | |
| 21 struct uas_parse_hdrs *ess; | |
| 22 struct sockaddr_in *sin; | |
| 23 { | |
| 24 struct sip_msg_out resp; | |
| 25 int rc; | |
| 26 | |
| 27 printf("Received BYE for our call, responding with 200\n"); | |
| 28 start_response_out_msg(&resp, "200 OK"); | |
| 29 rc = add_resp_basic_headers(&resp, ess, req->req_method); | |
| 30 if (rc < 0) { | |
| 31 fprintf(stderr, "sending 200 response: msg length exceeded\n"); | |
| 32 return; | |
| 33 } | |
| 34 out_msg_finish(&resp); | |
| 35 sip_tx_packet(&resp, sin); | |
| 36 } | |
| 37 | |
| 38 static void | |
| 39 bye_unknown_call(req, ess, sin) | |
| 40 struct sip_pkt_rx *req; | |
| 41 struct uas_parse_hdrs *ess; | |
| 42 struct sockaddr_in *sin; | |
| 43 { | |
| 44 struct sip_msg_out resp; | |
| 45 int rc; | |
| 46 | |
| 47 printf("Received BYE for unknown call, responding with 481\n"); | |
| 48 start_response_out_msg(&resp, "481 Call-ID not found"); | |
| 49 rc = add_resp_basic_headers(&resp, ess, req->req_method); | |
| 50 if (rc < 0) { | |
| 51 fprintf(stderr, "sending 481 response: msg length exceeded\n"); | |
| 52 return; | |
| 53 } | |
| 54 out_msg_finish(&resp); | |
| 55 sip_tx_packet(&resp, sin); | |
| 56 } | |
| 57 | |
| 58 static void | |
| 59 handle_bye(req, ess, sin) | |
| 60 struct sip_pkt_rx *req; | |
| 61 struct uas_parse_hdrs *ess; | |
| 62 struct sockaddr_in *sin; | |
| 63 { | |
| 64 if (!strcmp(ess->call_id, call_id)) | |
| 65 bye_correct_call(req, ess, sin); | |
| 66 else | |
| 67 bye_unknown_call(req, ess, sin); | |
| 68 } | |
| 69 | 15 |
| 70 static void | 16 static void |
| 71 unsupported_method(req, ess, sin) | 17 unsupported_method(req, ess, sin) |
| 72 struct sip_pkt_rx *req; | 18 struct sip_pkt_rx *req; |
| 73 struct uas_parse_hdrs *ess; | 19 struct uas_parse_hdrs *ess; |
| 105 msg->req_method, ess.error_field); | 51 msg->req_method, ess.error_field); |
| 106 return; | 52 return; |
| 107 } | 53 } |
| 108 /* dispatch by method */ | 54 /* dispatch by method */ |
| 109 if (!strcmp(msg->req_method, "BYE")) | 55 if (!strcmp(msg->req_method, "BYE")) |
| 110 handle_bye(msg, &ess, sin); | 56 handle_bye_req(msg, &ess, sin); |
| 111 else if (!strcmp(msg->req_method, "ACK")) | 57 else if (!strcmp(msg->req_method, "ACK")) |
| 112 printf("Received unexpected ACK, swallowing it\n"); | 58 printf("Received unexpected ACK, swallowing it\n"); |
| 113 else | 59 else |
| 114 unsupported_method(msg, &ess, sin); | 60 unsupported_method(msg, &ess, sin); |
| 115 } | 61 } |
