#[sip]
## define source and destination IP to make a call
#sip 192.168.0.55 sipgate.de
-## define <user> <host> <interval> to register to a SIP gateway
+## define <user> <host> [<options-interval>] to register to a SIP gateway
#register <user> sipgate.de 300
##define RTP port range or use default
#rtp-ports 30000 39999
## define keepalive timer to keep INVITE/REGISTER alive
## this is also required to keep the NAT router's table alive
#options-interval 15
+## define asserted ID (real caller ID) to use no screening CLIP
+##asserted-id <my real phone number>
## define public IP (if behind NAT firewall)
#public 123.45.67.89
## OR define stun server and resolving interval
return(0);
#endif
}
+static int options_asserted_id(struct interface *interface, char *filename, int line, char *parameter, char *value)
+{
+#ifndef WITH_SIP
+ SPRINT(interface_error, "Error in %s (line %d): SIP not compiled in.\n", filename, line);
+ return(-1);
+#else
+ if (!interface->sip) {
+ SPRINT(interface_error, "Error in %s (line %d): This is not a SIP interface.\n", filename, line);
+ return(-1);
+ }
+
+ if (!value || !value[0]) {
+ SPRINT(interface_error, "Error in %s (line %d): Missing asserted caller ID.\n", filename, line);
+ return(-1);
+ }
+ SCPY(interface->sip_asserted_id, value);
+
+ return(0);
+#endif
+}
static int options_public(struct interface *interface, char *filename, int line, char *parameter, char *value)
{
#ifndef WITH_SIP
return(-1);
}
q = get_seperated(p);
- if (!q[0]) {
- SPRINT(interface_error, "Error in %s (line %d): Missing register interval\n", filename, line);
- return(-1);
- }
+ if (!q[0])
+ interface->sip_register_interval = 0;
+ else
+ interface->sip_register_interval = atoi(q);
interface->sip_register = 1;
SCPY(interface->sip_register_user, value);
SCPY(interface->sip_register_host, p);
- interface->sip_register_interval = atoi(q);
return(0);
#endif
{"sip", &inter_sip, "<local IP/host>[:port] [<remote IP/host>[port]]",
"Sets up SIP interface that represents one SIP endpoint.\n"
"If the remote IP/host is omitted, a client must register first to us."},
- {"register", &inter_register, "<user> <host>",
- "Registers to given SIP registrar."},
+ {"register", &inter_register, "<user> <host> [options-interval]",
+ "Registers to given SIP registrar.\n"
+ "Optionally give SIP timer to send OPTIONS messages to keepalive REGISTER sessions."},
{"authenticate", &inter_authenticate, "<user> <password>",
"Defines SIP user and password for authentication."},
{"options-interval", &options_interval, "<interval> | 0",
- "Defines SIP timer to send OPTIONS messages to keepalive SIP sessions."},
+ "Defines SIP timer to send OPTIONS messages to keepalive INVITE sessions."},
+ {"asserted-id", &options_asserted_id, "<caller-id>",
+ "Defines SIP's asserted-id in INVITE message."},
{"public", &options_public, "<server> <interval>",
"Defines public IP, if this endpoint is behind NAT firewall."},
{"stun", &options_stun, "<server> <interval>",
int sip; /* interface is a SIP interface */
char sip_local_peer[128];
char sip_remote_peer[128];
+ char sip_asserted_id[128];
char sip_auth_user[128];
char sip_auth_password[128];
int sip_register;
char interface_name[64];
char local_peer[128];
char remote_peer[128];
+ char asserted_id[128];
int register_state;
char register_user[128];
char register_host[128];
{
struct sip_inst *inst = (struct sip_inst *) p_s_sip_inst;
char from[128] = "";
+ char asserted_id[128] = "", asserted_msg[256] = "";
char to[128] = "";
char contact[128] = "";
const char *local = inst->local_peer;
SPRINT(from, "sip:%s@%s", p_callerinfo.id, remote);
SPRINT(to, "sip:%s@%s", p_dialinginfo.id, remote);
+ if (inst->asserted_id[0]) {
+ SPRINT(asserted_id, "sip:%s@%s", inst->asserted_id, remote);
+ SPRINT(asserted_msg, "P-Asserted-Identity: <%s>", asserted_id);
+ }
if (inst->public_ip[0])
SPRINT(contact, "sip:%s@%s", p_callerinfo.id, inst->public_ip);
sip_trace_header(this, inst->interface_name, "INVITE", DIRECTION_OUT);
add_trace("from", "uri", "%s", from);
add_trace("to", "uri", "%s", to);
+ if (asserted_id[0])
+ add_trace("assert-id", "uri", "%s", asserted_id);
add_trace("rtp", "ip", "%s", inet_ntoa(ia));
add_trace("rtp", "port", "%d,%d", p_s_rtp_port_local, p_s_rtp_port_local + 1);
for (i = 0; i < payloads; i++)
nua_invite(p_s_handle,
TAG_IF(from[0], SIPTAG_FROM_STR(from)),
TAG_IF(to[0], SIPTAG_TO_STR(to)),
+ TAG_IF(asserted_msg[0], SIPTAG_HEADER_STR(asserted_msg)),
TAG_IF(contact[0], SIPTAG_CONTACT_STR(contact)),
TAG_IF(cseq, SIPTAG_CSEQ(cseq)),
NUTAG_MEDIA_ENABLE(0),
}
port = port->next;
}
+ if (!port)
+ psip = NULL;
/* new handle */
- if (!port && !inst->register_handle) {
+ if (!psip && inst->register_handle != nh) {
switch (event) {
case nua_i_register:
PDEBUG(DEBUG_SIP, "New register instance\n");
return;
}
-#warning fixme: wann eine response
- sip_trace_header(psip, inst->interface_name, "STATUS", DIRECTION_OUT);
- add_trace("value", NULL, "%d", status);
- add_trace("phrase", NULL, "%s", phrase);
- end_trace();
+ if (status) {
+ sip_trace_header(psip, inst->interface_name, "STATUS", DIRECTION_OUT);
+ add_trace("value", NULL, "%d", status);
+ add_trace("phrase", NULL, "%s", phrase);
+ end_trace();
+ }
switch (status) {
case 401:
SCPY(inst->interface_name, interface->name);
SCPY(inst->local_peer, interface->sip_local_peer);
SCPY(inst->remote_peer, interface->sip_remote_peer);
+ SCPY(inst->asserted_id, interface->sip_asserted_id);
if (interface->sip_register) {
inst->register_state = REGISTER_STATE_UNREGISTERED;
SCPY(inst->register_user, interface->sip_register_user);