FreeCalypso > hg > themwi-system-sw
view mtctest/dummy_rtp.c @ 152:7176dc850d7a
sip-in hold/retr error handling: simply send BYE
Because we know that the SIP state is CONNECTED at the time of any
such error event, we can call initiate_bye() instead of disconnect_sip(),
and thereby get rid of struct gsm_mncc_cause which will never be used
in this scenario anyway.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2022 16:11:21 -0800 |
parents | e8e82a4bf12b |
children |
line wrap: on
line source
/* * In this module we implement the code that connects to themwi-mgw * and obtains a dummy GSM-side RTP endpoint. */ #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "../include/tmgw_ctrl.h" #include "../include/tmgw_const.h" struct sockaddr_storage dummy_rtp_endp; static char tmgw_socket_pathname[] = "/var/gsm/tmgw_socket"; obtain_dummy_rtp() { struct sockaddr_un sa; unsigned sa_len; int fd, rc; struct tmgw_ctrl_req req; struct tmgw_ctrl_resp resp; fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (fd < 0) { perror("socket(AF_UNIX, SOCK_SEQPACKET, 0)"); exit(1); } fill_sockaddr_un(tmgw_socket_pathname, &sa, &sa_len); rc = connect(fd, (struct sockaddr *) &sa, sa_len); if (rc < 0) { perror(tmgw_socket_pathname); exit(1); } bzero(&req, sizeof req); req.opcode = TMGW_CTRL_OP_CRCX; req.ep_id = TMGW_EP_TYPE_DUMMY_GSM; rc = send(fd, &req, sizeof req, 0); if (rc < 0) { perror("send to TMGW socket"); exit(1); } rc = recv(fd, &resp, sizeof resp, 0); if (rc < 0) { perror("recv from TMGW socket"); exit(1); } if (rc != sizeof resp) { fprintf(stderr, "error: response packet from TMGW has wrong length (%d bytes)\n", rc); exit(1); } if (resp.res != TMGW_RESP_OK) { fprintf(stderr, "TMGW CRCX returned error %u\n", resp.res); exit(1); } bcopy(&resp.gsm_addr, &dummy_rtp_endp, sizeof(struct sockaddr_storage)); return(0); }