memset(&ia, 0, sizeof(ia));
ia.s_addr = htonl(get_local_ip(p_s_rtp_ip_local));
-#warning TESTING must always send SDP on 200 OK
-if (1) {
-// if (p_s_rtp_bridge || interface->is_tones != IS_YES) {
- SPRINT(sdp_str,
- "v=0\r\n"
- "o=LCR-Sofia-SIP 0 0 IN IP4 %s\r\n"
- "s=SIP Call\r\n"
- "c=IN IP4 %s\r\n"
- "t=0 0\r\n"
- "m=audio %d RTP/AVP %d\r\n"
- "a=rtpmap:%d %s/8000\r\n"
- , inet_ntoa(ia), inet_ntoa(ia), p_s_rtp_port_local, payload_type, payload_type, media_type2name(media_type));
- PDEBUG(DEBUG_SIP, "Using SDP response: %s\n", sdp_str);
- }
+ SPRINT(sdp_str,
+ "v=0\r\n"
+ "o=LCR-Sofia-SIP 0 0 IN IP4 %s\r\n"
+ "s=SIP Call\r\n"
+ "c=IN IP4 %s\r\n"
+ "t=0 0\r\n"
+ "m=audio %d RTP/AVP %d\r\n"
+ "a=rtpmap:%d %s/8000\r\n"
+ , inet_ntoa(ia), inet_ntoa(ia), p_s_rtp_port_local, payload_type, payload_type, media_type2name(media_type));
+ PDEBUG(DEBUG_SIP, "Using SDP response: %s\n", sdp_str);
/* NOTE:
* If this response causes corrupt messages, like SDP body inside or
*/
nua_respond(p_s_handle, SIP_200_OK,
NUTAG_MEDIA_ENABLE(0),
- TAG_IF(sdp_str[0], SIPTAG_CONTENT_TYPE_STR("application/sdp")),
- TAG_IF(sdp_str[0], SIPTAG_PAYLOAD_STR(sdp_str)),
- TAG_END());
+ SIPTAG_CONTENT_TYPE_STR("application/sdp"),
+ SIPTAG_PAYLOAD_STR(sdp_str), TAG_END());
new_state(PORT_STATE_CONNECT);
sip_trace_header(this, inst->interface_name, "RESPOND", DIRECTION_OUT);
}
/* start option timer */
if (inst->options_interval)
+ PDEBUG(DEBUG_SIP, "register ok, scheduling option timer with %d seconds\n", inst->options_interval);
schedule_timer(&inst->register_option_timer, inst->options_interval, 0);
break;
case 401:
}
if (p_state != PORT_STATE_IDLE) {
+#warning fixme: select new RTP and respond with SDP
sip_trace_header(this, inst->interface_name, "RE-INVITE", DIRECTION_IN);
end_trace();
nua_respond(p_s_handle, SIP_200_OK,
}
message_put(message);
- PDEBUG(DEBUG_SIP, "Invite received, scheduling option timer\n");
/* start option timer */
- if (inst->options_interval)
+ if (inst->options_interval) {
+ PDEBUG(DEBUG_SIP, "Invite received, scheduling option timer with %d seconds\n", inst->options_interval);
schedule_timer(&p_s_invite_option_timer, inst->options_interval, 0);
+ }
+
p_s_invite_direction = DIRECTION_IN;
/* send progress, if tones are available and if we don't bridge */
}
}
+void Psip::i_options(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[])
+{
+ struct sip_inst *inst = (struct sip_inst *) p_s_sip_inst;
+
+ PDEBUG(DEBUG_SIP, "options received\n");
+
+ sip_trace_header(this, inst->interface_name, "OPTIONS", DIRECTION_IN);
+ end_trace();
+
+ nua_respond(nh, SIP_200_OK, TAG_END());
+}
+
void Psip::i_bye(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[])
{
struct sip_inst *inst = (struct sip_inst *) p_s_sip_inst;
}
/* connect to remote RTP (if not bridging) */
- if (!p_s_rtp_bridge && rtp_connect() < 0) {
+ if (!p_s_rtp_bridge && !p_s_rtp_is_connected && rtp_connect() < 0) {
nua_cancel(nh, TAG_END());
sip_trace_header(this, inst->interface_name, "CANCEL", DIRECTION_OUT);
add_trace("reason", NULL, "failed to open RTP/RTCP sockts");
}
}
- PDEBUG(DEBUG_SIP, "Invite response, scheduling option timer\n");
/* start option timer */
- if (inst->options_interval)
+ if (inst->options_interval) {
+ PDEBUG(DEBUG_SIP, "Invite response, scheduling option timer with %d seconds\n", inst->options_interval);
schedule_timer(&p_s_invite_option_timer, inst->options_interval, 0);
+ }
switch (status) {
case 100:
PDEBUG(DEBUG_SIP, "options result %d received\n", status);
if (status >= 200 && status <= 299) {
- PDEBUG(DEBUG_SIP, "options ok, scheduling timer\n");
+ PDEBUG(DEBUG_SIP, "options ok, scheduling option timer with %d seconds\n", inst->options_interval);
/* restart option timer */
schedule_timer(&p_s_invite_option_timer, inst->options_interval, 0);
return;
case nua_i_active:
PDEBUG(DEBUG_SIP, "active received\n");
break;
+ case nua_i_options:
+ psip->i_options(status, phrase, nua, magic, nh, hmagic, sip, tags);
+ break;
case nua_i_bye:
psip->i_bye(status, phrase, nua, magic, nh, hmagic, sip, tags);
break;
SCPY(inst->public_ip, interface->sip_public_ip);
if (interface->sip_stun_server[0]) {
-#if 0
- inst->stun_root = su_root_create(inst);
- if (!inst->stun_root) {
- PERROR("Failed to create STUN root\n");
- sip_exit_inst(interface);
- return -EINVAL;
- }
- auch im exit
-#endif
SCPY(inst->stun_server, interface->sip_stun_server);
inst->stun_interval = interface->sip_stun_interval;
inst->stun_handle = stun_handle_init(inst->root,
extern su_log_t su_log_default[];
extern su_log_t nua_log[];
-//extern su_log_t soa_log[];
int sip_init(void)
{
rtp_send_frame(buf, SEND_SIP_LEN, (options.law=='a')?PAYLOAD_TYPE_ALAW:PAYLOAD_TYPE_ULAW);
}
-#warning den source-port beim registrieren einstellen