FreeCalypso > hg > themwi-system-sw
view sip-in/mgw_sock.c @ 48:8117d8ee44a5
sip-in: beginning of INVITE handling
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 06 Sep 2022 22:07:51 -0800 |
parents | 62f39c7cee15 |
children | 02761f1ae5e5 |
line wrap: on
line source
/* * In this module we implement our local socket interface to themwi-mgw. */ #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <syslog.h> #include "../include/tmgw_ctrl.h" static char tmgw_socket_pathname[] = "/var/gsm/tmgw_socket"; int mgw_socket; open_tmgw_socket() { struct sockaddr_un sa; unsigned sa_len; int rc; mgw_socket = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (mgw_socket < 0) { syslog(LOG_CRIT, "socket(AF_UNIX, SOCK_SEQPACKET, 0): %m"); return(-1); } fill_sockaddr_un(tmgw_socket_pathname, &sa, &sa_len); rc = connect(mgw_socket, (struct sockaddr *) &sa, sa_len); if (rc < 0) { syslog(LOG_ERR, "connect to %s: %m", tmgw_socket_pathname); return(-1); } update_max_fd(mgw_socket); return(0); } void mgw_socket_select() { struct tmgw_ctrl_resp msg; int rc; rc = recv(mgw_socket, &msg, sizeof msg, 0); if (rc < 0) { syslog(LOG_CRIT, "error reading from TMGW socket: %m"); exit(1); } if (rc != sizeof(struct tmgw_ctrl_resp)) { syslog(LOG_CRIT, "response packet from TMGW has wrong length: %d bytes", rc); exit(1); } /* processing to be implemented */ }