FreeCalypso > hg > themwi-system-sw
view mncc/mncc_sock.c @ 118:a4450ae8fd09
sip-manual-out UAC: use the new CSeq parsing function
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 29 Sep 2022 13:03:27 -0800 |
parents | ccc5ab6d8388 |
children |
line wrap: on
line source
/* * In this module we implement low-level handling * of the main MNCC socket that connects to OsmoMSC. */ #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 mncc_socket_pathname[] = "/var/gsm/mncc_socket"; int mncc_socket; open_mncc_socket() { struct sockaddr_un sa; unsigned sa_len; int rc; mncc_socket = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (mncc_socket < 0) { syslog(LOG_CRIT, "socket(AF_UNIX, SOCK_SEQPACKET, 0): %m"); return(-1); } fill_sockaddr_un(mncc_socket_pathname, &sa, &sa_len); rc = connect(mncc_socket, (struct sockaddr *) &sa, sa_len); if (rc < 0) { syslog(LOG_ERR, "connect to %s: %m", mncc_socket_pathname); return(-1); } update_max_fd(mncc_socket); return(0); } void mncc_socket_select() { union mncc_msg msg; int rc; rc = recv(mncc_socket, &msg, sizeof msg, 0); if (rc < 0) { syslog(LOG_CRIT, "error reading from MNCC socket: %m"); exit(1); } if (rc < 4) { syslog(LOG_CRIT, "short read from MNCC 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(mncc_socket, msg, msglen, 0); }