Compare commits

...

4 Commits

Author SHA1 Message Date
Vadim Yanitskiy bd166ea92d [WIP] Migrate to MNCCv8 2022-11-25 02:44:02 +07:00
Vadim Yanitskiy dfafc1873d mncc: remove duplicate GSM_MAX_* definitions 2022-11-25 01:23:23 +07:00
Vadim Yanitskiy 169afcc000 sip: do not require SOFIA_SIP_GCC_4_8_PATCH_APLLIED
sofia-sip v1.13.6 comes with this patch applied, but without macro.
2022-11-24 21:03:42 +07:00
Vadim Yanitskiy 0294904bf7 mail: fix mail_child(): properly check the result of popen() 2022-11-24 20:46:48 +07:00
4 changed files with 43 additions and 25 deletions

39
gsm.cpp
View File

@ -138,10 +138,17 @@ int send_and_free_mncc(struct lcr_gsm *lcr_gsm, unsigned int msg_type, void *dat
void Pgsm::send_mncc_rtp_connect(void)
{
struct gsm_mncc_rtp *nrtp;
struct sockaddr_in *addr;
nrtp = (struct gsm_mncc_rtp *) create_mncc(MNCC_RTP_CONNECT, p_g_callref);
nrtp->ip = p_g_rtp_ip_remote;
nrtp->port = p_g_rtp_port_remote;
addr = reinterpret_cast<struct sockaddr_in *>(&nrtp->addr);
*addr = (struct sockaddr_in) {
.sin_family = AF_INET,
.sin_port = htons(p_g_rtp_port_remote),
.sin_addr = { .s_addr = htonl(p_g_rtp_ip_remote) },
};
switch (p_g_media_type) {
case MEDIA_TYPE_GSM:
nrtp->payload_msg_type = GSM_TCHF_FRAME;
@ -888,17 +895,24 @@ void Pgsm::rtp_create_ind(unsigned int msg_type, unsigned int callref, struct gs
/* send queued setup, as we received remote RTP info */
if (p_g_setup_pending) {
const struct sockaddr_in *addr;
struct lcr_msg *message;
addr = reinterpret_cast<const struct sockaddr_in *>(&rtp->addr);
assert(addr->sin_family == AF_INET); // XXX
message = p_g_setup_pending;
PDEBUG(DEBUG_GSM, "Got RTP peer info (%08x,%d) forwarding setup\n", rtp->ip, rtp->port);
message->param.setup.rtpinfo.ip = rtp->ip;
message->param.setup.rtpinfo.port = rtp->port;
message->param.setup.rtpinfo.ip = ntohl(addr->sin_addr.s_addr);
message->param.setup.rtpinfo.port = ntohs(addr->sin_port);
PDEBUG(DEBUG_GSM, "Got RTP peer info (%08x,%d) forwarding setup\n",
message->param.setup.rtpinfo.ip,
message->param.setup.rtpinfo.port);
message_put(message);
p_g_setup_pending = NULL;
}
if (p_g_connect_pending) {
PDEBUG(DEBUG_GSM, "Got RTP peer info (%08x,%d) connecting RTP... \n", rtp->ip, rtp->port);
PDEBUG(DEBUG_GSM, "Got RTP peer info (%08x,%d) connecting RTP... \n",
p_g_rtp_ip_remote, p_g_rtp_port_remote);
send_mncc_rtp_connect();
}
}
@ -910,10 +924,17 @@ void Pgsm::rtp_connect_ind(unsigned int msg_type, unsigned int callref, struct g
struct gsm_mncc_rtp *rtp = (struct gsm_mncc_rtp *) mncc;
if (p_g_connect_pending) {
const struct sockaddr_in *addr;
addr = reinterpret_cast<const struct sockaddr_in *>(&rtp->addr);
assert(addr->sin_family == AF_INET); // XXX
message = p_g_connect_pending;
PDEBUG(DEBUG_GSM, "Got RTP peer info (%08x,%d) forwarding connect\n", rtp->ip, rtp->port);
message->param.connectinfo.rtpinfo.ip = rtp->ip;
message->param.connectinfo.rtpinfo.port = rtp->port;
message->param.connectinfo.rtpinfo.ip = ntohl(addr->sin_addr.s_addr);
message->param.connectinfo.rtpinfo.port = ntohs(addr->sin_port);
PDEBUG(DEBUG_GSM, "Got RTP peer info (%08x,%d) forwarding connect\n",
message->param.connectinfo.rtpinfo.ip,
message->param.connectinfo.rtpinfo.port);
message_put(message);
p_g_connect_pending = NULL;
}

2
mail.c
View File

@ -76,7 +76,7 @@ static void *mail_child(void *arg)
/* open process */
SPRINT(command, "%s -f%s %s", SENDMAIL, options.email, email);
if ((ph = popen(command, "w")) < 0) {
if ((ph = popen(command, "w")) == NULL) {
PERROR("Cannot send mail using command '%s'\n", command);
goto done;
}

19
mncc.h
View File

@ -1,6 +1,8 @@
#include <stdint.h>
#include <sys/socket.h>
#define MNCC_SETUP_REQ 0x0101
#define MNCC_SETUP_IND 0x0102
#define MNCC_SETUP_RSP 0x0103
@ -85,10 +87,7 @@
#define MNCC_F_CCCAP 0x0800
#define MNCC_F_KEYPAD 0x1000
#define MNCC_F_SIGNAL 0x2000
#define GSM_MAX_FACILITY 128
#define GSM_MAX_SSVERSION 128
#define GSM_MAX_USERUSER 128
#define MNCC_F_GCR 0x4000
/* GSM 04.08 Bearer Capability: Information Transfer Capability */
enum gsm48_bcap_itcap {
@ -314,6 +313,12 @@ struct gsm_mncc {
unsigned char lchan_type;
unsigned char lchan_mode;
/* Global Call Reference (encoded as per 3GPP TS 29.205) */
uint8_t gcr[16];
/* A buffer to contain SDP ('\0' terminated) */
char sdp[1024];
};
struct gsm_data_frame {
@ -325,14 +330,14 @@ struct gsm_data_frame {
struct gsm_mncc_rtp {
u_int32_t msg_type;
u_int32_t callref;
u_int32_t ip;
u_int16_t port;
struct sockaddr_storage addr;
u_int32_t payload_type;
u_int32_t payload_msg_type;
char sdp[1024];
};
#define MNCC_SOCK_VERSION 5
#define MNCC_SOCK_VERSION 8
struct gsm_mncc_hello {
uint32_t msg_type;
uint32_t version;

View File

@ -18,14 +18,6 @@
#include <sofia-sip/stun_tag.h>
#include <sofia-sip/su_md5.h>
#ifndef SOFIA_SIP_GCC_4_8_PATCH_APLLIED
#warning ********************************************************
#warning Please apply the sofia-sip-gcc-4.8.patch !
#warning If this issue is already fixed, just remove this check.
#warning ********************************************************
#error
#endif
#undef NUTAG_AUTO100
unsigned char flip[256];