FreeCalypso > hg > themwi-system-sw
view sip-in/mncc_sock.c @ 57:d61d0136f6a5
sip-in INVITE processing: return "GSM service is offline" indication
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Sep 2022 13:39:42 -0800 |
parents | 7005d5c535e8 |
children | e5aee661e3b2 |
line wrap: on
line source
/* * In this module we implement our connection to the MNCC daemon's * mtcall socket. */ #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/mncc.h" static char mtcall_socket_pathname[] = "/var/gsm/mtcall_socket"; int gsm_socket, gsm_is_connected; connect_gsm_mtcall() { struct sockaddr_un sa; unsigned sa_len; int rc; if (gsm_is_connected) return(0); gsm_socket = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (gsm_socket < 0) { syslog(LOG_CRIT, "socket(AF_UNIX, SOCK_SEQPACKET, 0): %m"); return(-1); } fill_sockaddr_un(mtcall_socket_pathname, &sa, &sa_len); rc = connect(gsm_socket, (struct sockaddr *) &sa, sa_len); if (rc < 0) { syslog(LOG_ERR, "connect to %s: %m", mtcall_socket_pathname); close(gsm_socket); return(-1); } update_max_fd(gsm_socket); gsm_is_connected = 1; return(0); } void gsm_socket_select() { union mncc_msg msg; int rc; rc = recv(gsm_socket, &msg, sizeof msg, 0); if (rc < 0) { syslog(LOG_CRIT, "error reading from mtcall socket: %m"); /* GSM disconnect handling to be implemented */ exit(1); } if (rc < 4) { syslog(LOG_CRIT, "short read from mtcall socket: %d bytes", rc); exit(1); } /* mncc_msg_from_gsm(&msg, rc); */ } send_mncc_to_gsm(msg, msglen) union mncc_msg *msg; unsigned msglen; { return send(gsm_socket, msg, msglen, 0); }