FreeCalypso > hg > themwi-system-sw
comparison sip-out/sip_uas.c @ 154:e54b0a9e322f
beginning of themwi-sip-out
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 11 Oct 2022 23:04:01 -0800 |
| parents | sip-in/sip_uas.c@0d6435808bcd |
| children |
comparison
equal
deleted
inserted
replaced
| 153:99fd4ae573ae | 154:e54b0a9e322f |
|---|---|
| 1 /* | |
| 2 * Basic UAS functions for themwi-sip-out. | |
| 3 */ | |
| 4 | |
| 5 #include <sys/types.h> | |
| 6 #include <sys/socket.h> | |
| 7 #include <netinet/in.h> | |
| 8 #include <stdio.h> | |
| 9 #include <stdlib.h> | |
| 10 #include <string.h> | |
| 11 #include <strings.h> | |
| 12 #include <syslog.h> | |
| 13 #include "../libsip/parse.h" | |
| 14 #include "../libsip/uas_basic.h" | |
| 15 #include "../libsip/out_msg.h" | |
| 16 | |
| 17 static void | |
| 18 unsupported_method(req, ess, sin) | |
| 19 struct sip_pkt_rx *req; | |
| 20 struct uas_parse_hdrs *ess; | |
| 21 struct sockaddr_in *sin; | |
| 22 { | |
| 23 struct sip_msg_out resp; | |
| 24 int rc; | |
| 25 | |
| 26 start_response_out_msg(&resp, "501 Method not supported"); | |
| 27 rc = add_resp_basic_headers(&resp, ess, req->req_method); | |
| 28 if (rc < 0) { | |
| 29 too_long: syslog(LOG_ERR, "sending 501 error: response length exceeded"); | |
| 30 return; | |
| 31 } | |
| 32 rc = out_msg_add_header(&resp, "Allow", "INVITE,ACK,BYE"); | |
| 33 if (rc < 0) | |
| 34 goto too_long; | |
| 35 out_msg_finish(&resp); | |
| 36 sip_tx_packet(&resp, sin); | |
| 37 } | |
| 38 | |
| 39 void | |
| 40 process_sip_request(msg, sin) | |
| 41 struct sip_pkt_rx *msg; | |
| 42 struct sockaddr_in *sin; | |
| 43 { | |
| 44 struct uas_parse_hdrs ess; | |
| 45 int rc; | |
| 46 | |
| 47 rc = uas_get_basic_headers(msg, &ess); | |
| 48 if (rc < 0) { | |
| 49 syslog(LOG_ERR, "SIP %.16s request: bad or missing %s header", | |
| 50 msg->req_method, ess.error_field); | |
| 51 return; | |
| 52 } | |
| 53 /* dispatch by method */ | |
| 54 if (!strcmp(msg->req_method, "INVITE")) | |
| 55 handle_invite_req(msg, &ess, sin); | |
| 56 else if (!strcmp(msg->req_method, "ACK")) | |
| 57 return; /* no handling required */ | |
| 58 else if (!strcmp(msg->req_method, "BYE")) | |
| 59 handle_bye_req(msg, &ess, sin); | |
| 60 else | |
| 61 unsupported_method(msg, &ess, sin); | |
| 62 } |
