FreeCalypso > hg > themwi-system-sw
view sip-out/reinvite.c @ 192:f8a33603288f
sip-manual-out: generate outgoing RTP stream with PCM silence
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 17 Mar 2023 13:45:31 -0800 |
parents | 9419fe55824f |
children |
line wrap: on
line source
/* * Here we handle incoming INVITE requests in the UAS role: even though * we are strictly outbound, BulkVS servers will send us periodic * re-INVITEs as keepalives, and we have to play along. */ #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> #include <netinet/in.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <syslog.h> #include "../include/out_routes.h" #include "../libsip/parse.h" #include "../libsip/uas_basic.h" #include "../libsip/out_msg.h" #include "call.h" extern struct call *find_call_by_sip_id(); static void invite_found_call(req, ess, sin, call) struct sip_pkt_rx *req; struct uas_parse_hdrs *ess; struct sockaddr_in *sin; struct call *call; { struct sip_msg_out resp; int rc; switch (call->sip_state) { case SIP_STATE_INV_SENT: case SIP_STATE_100_RCVD: start_response_out_msg(&resp, "491 Outbound INVITE pending"); break; case SIP_STATE_CONNECTED: start_response_out_msg(&resp, "200 OK"); break; case SIP_STATE_CANCEL_SENT: case SIP_STATE_BYE_SENT: case SIP_STATE_ACCEPT_100: case SIP_STATE_ACCEPT_200: case SIP_STATE_ENDED: start_response_out_msg(&resp, "488 Call terminated"); break; case SIP_STATE_MSG_SIZE_ERR: return; default: syslog(LOG_CRIT, "FATAL: invalid SIP state 0x%x on incoming re-INVITE", call->sip_state); exit(1); } rc = add_resp_basic_headers(&resp, ess, req->req_method); if (rc < 0) { syslog(LOG_ERR, "Re-INVITE response message size error"); return; } out_msg_finish(&resp); sip_tx_packet(&resp, sin); } static void invite_unknown_call(req, ess, sin) struct sip_pkt_rx *req; struct uas_parse_hdrs *ess; struct sockaddr_in *sin; { struct sip_msg_out resp; int rc; start_response_out_msg(&resp, "405 This gateway is outbound only"); rc = add_resp_basic_headers(&resp, ess, req->req_method); if (rc < 0) return; out_msg_finish(&resp); sip_tx_packet(&resp, sin); } void handle_invite_req(req, ess, sin) struct sip_pkt_rx *req; struct uas_parse_hdrs *ess; struct sockaddr_in *sin; { struct call *call; call = find_call_by_sip_id(ess->call_id); if (call) invite_found_call(req, ess, sin, call); else invite_unknown_call(req, ess, sin); }