{"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> [options-interval]",
+ {"register", &inter_register, "<user> <host> [register-interval]",
"Registers to given SIP registrar.\n"
- "Optionally give SIP timer to send OPTIONS messages to keepalive REGISTER sessions."},
+ "Optionally give RE-REGISTER interval time in seconds.\n"
+ "The exire value is set 60 seconds ahead this interval, then."},
{"authenticate", &inter_authenticate, "<user> <password> [realm]",
"Defines SIP user and password for authentication.\n"
"If no remote IP was give, we are SIP gateway, so realm must be given also."},
struct lcr_timer register_retry_timer;
struct lcr_timer register_option_timer;
int register_interval;
+ nua_handle_t *options_handle;
int options_interval;
char auth_user[128];
char auth_password[128];
PDEBUG(DEBUG_SIP, "Using SDP for invite: %s\n", sdp_str);
SPRINT(from, "sip:%s@%s", p_callerinfo.id, remote);
+// SPRINT(from, "\"%s\" <sip:%s@%s>", /*p_callerinfo.id*/ "4946448519988", 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);
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(data->e_msg), TAG_END());
nua_handle_destroy(nh);
- inst->register_handle = NULL;
+ inst->options_handle = NULL;
}
static void i_register(struct sip_inst *inst, int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[])
/* new handle */
switch (event) {
case nua_i_options:
- if (!inst->register_handle) {
+ if (!psip && !inst->options_handle) {
PDEBUG(DEBUG_SIP, "New options instance\n");
- inst->register_handle = nh;
+ inst->options_handle = nh;
+ }
+ if (!psip) {
+ i_options(inst, status, phrase, nua, magic, nh, hmagic, sip, tags);
+ return;
}
break;
case nua_i_register:
PDEBUG(DEBUG_SIP, "New register instance\n");
inst->register_handle = nh;
}
+ i_register(inst, status, phrase, nua, magic, nh, hmagic, sip, tags);
+ break;
+ case nua_r_register:
+ if (!psip) {
+ r_register(inst, status, phrase, nua, magic, nh, hmagic, sip, tags);
+ return;
+ }
break;
case nua_i_invite:
if (!psip) {
}
break;
default:
- if (!psip && !inst->register_handle) {
+ if (!psip && inst->register_handle != nh) {
PDEBUG(DEBUG_SIP, "Destroying unknown instance\n");
nua_handle_destroy(nh);
return;
}
}
- /* handle register process */
- if (inst->register_handle == nh) {
- switch (event) {
- case nua_i_options:
- i_options(inst, status, phrase, nua, magic, nh, hmagic, sip, tags);
- break;
- case nua_i_register:
- i_register(inst, status, phrase, nua, magic, nh, hmagic, sip, tags);
- break;
- case nua_r_register:
- r_register(inst, status, phrase, nua, magic, nh, hmagic, sip, tags);
- break;
- default:
- PDEBUG(DEBUG_SIP, "Event %d not handled\n", event);
- }
- return;
- }
-
/* handle port process */
if (!psip) {
PERROR("no SIP Port found for handel %p\n", nh);
stun_handle_destroy(inst->stun_handle);
if (inst->register_handle)
nua_handle_destroy(inst->register_handle);
+ if (inst->options_handle)
+ nua_handle_destroy(inst->options_handle);
if (inst->root)
su_root_destroy(inst->root);
if (inst->nua)
char from[128] = "";
char to[128] = "";
char contact[128] = "";
+ char expires[128] = "";
switch (inst->register_state) {
case REGISTER_STATE_UNREGISTERED:
SCAT(contact, p);
}
+ if (inst->register_interval) {
+ SPRINT(expires, "%d", inst->register_interval + 60);
+ }
+
sip_trace_header(NULL, inst->interface_name, "REGISTER", DIRECTION_OUT);
add_trace("from", "uri", "%s", from);
add_trace("to", "uri", "%s", to);
+ if (expires[0])
+ add_trace("expires", NULL, "%s", expires);
end_trace();
nua_register(inst->register_handle,
TAG_IF(from[0], SIPTAG_FROM_STR(from)),
TAG_IF(to[0], SIPTAG_TO_STR(to)),
TAG_IF(contact[0], SIPTAG_CONTACT_STR(contact)),
+ TAG_IF(expires[0], SIPTAG_EXPIRES_STR(expires)),
TAG_END());
inst->register_state = REGISTER_STATE_REGISTERING;