From: Andreas Eversberg Date: Sat, 18 Feb 2012 08:50:43 +0000 (+0100) Subject: Allow setting IP:port for peers of SIP interfaces. X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=commitdiff_plain;h=58afedec93e67db3600e2251d922fa3a4dbd7254 Allow setting IP:port for peers of SIP interfaces. --- diff --git a/default/interface.conf b/default/interface.conf index 6c82d50..1a465ad 100644 --- a/default/interface.conf +++ b/default/interface.conf @@ -192,7 +192,7 @@ # Use Sofia-SIP as SIP point-to-point interface #[sip] -#sip +#sip [:] #sip 10.0.0.12 10.0.0.34 #earlyb no #tones no diff --git a/interface.c b/interface.c index 365e843..4f7e40a 100644 --- a/interface.c +++ b/interface.c @@ -973,8 +973,8 @@ static int inter_sip(struct interface *interface, char *filename, int line, char SPRINT(interface_error, "Error in %s (line %d): Missing SIP remote IP.\n", filename, line); return(-1); } - SCPY(interface->sip_local_ip, value); - SCPY(interface->sip_remote_ip, p); + SCPY(interface->sip_local_peer, value); + SCPY(interface->sip_remote_peer, p); return(0); #endif diff --git a/interface.h b/interface.h index cf1b192..a310a92 100644 --- a/interface.h +++ b/interface.h @@ -119,8 +119,8 @@ struct interface { #endif #ifdef WITH_SIP int sip; /* interface is a SIP interface */ - char sip_local_ip[16]; - char sip_remote_ip[16]; + char sip_local_peer[32]; + char sip_remote_peer[32]; void *sip_inst; /* sip instance */ #endif int rtp_bridge; /* bridge RTP directly (for calls comming from interface) */ diff --git a/sip.cpp b/sip.cpp index c6ddde3..4d5be39 100644 --- a/sip.cpp +++ b/sip.cpp @@ -24,8 +24,8 @@ su_home_t sip_home[1]; struct sip_inst { char interface_name[64]; - char local_ip[16]; - char remote_ip[16]; + char local_peer[32]; + char remote_peer[32]; su_root_t *root; nua_t *nua; }; @@ -872,8 +872,9 @@ int Psip::message_setup(unsigned int epoint_id, int message_id, union parameter struct sip_inst *inst = (struct sip_inst *) p_s_sip_inst; char from[128]; char to[128]; - const char *local = inst->local_ip; - const char *remote = inst->remote_ip; + const char *local = inst->local_peer; + char local_ip[16]; + const char *remote = inst->remote_peer; char sdp_str[512], pt_str[32]; struct in_addr ia; struct epoint_list *epointlist; @@ -941,8 +942,15 @@ int Psip::message_setup(unsigned int epoint_id, int message_id, union parameter end_trace(); if (!p_s_rtp_ip_local) { - PDEBUG(DEBUG_SIP, "RTP local IP not known, so we use our local SIP ip %s\n", local); - inet_pton(AF_INET, local, &p_s_rtp_ip_local); + char *p; + + /* extract IP from local peer */ + SCPY(local_ip, local); + p = strchr(local_ip, ':'); + if (p) + *p = '\0'; + PDEBUG(DEBUG_SIP, "RTP local IP not known, so we use our local SIP ip %s\n", local_ip); + inet_pton(AF_INET, local_ip, &p_s_rtp_ip_local); p_s_rtp_ip_local = ntohl(p_s_rtp_ip_local); } ia.s_addr = htonl(p_s_rtp_ip_local); @@ -1813,8 +1821,8 @@ int sip_init_inst(struct interface *interface) interface->sip_inst = inst; SCPY(inst->interface_name, interface->name); - SCPY(inst->local_ip, interface->sip_local_ip); - SCPY(inst->remote_ip, interface->sip_remote_ip); + SCPY(inst->local_peer, interface->sip_local_peer); + SCPY(inst->remote_peer, interface->sip_remote_peer); /* init root object */ inst->root = su_root_create(inst);