add generic keepalive system and implement it in sofia to send MESSAGE or INFO packets in-dialog at specified interval.

Adds app: enable_keepalive 0|<seconds>
This app can be run in the dialplan or with execute_on_* type variables for B-legs.

Adds sofia param: keepalive-method  : defaults to MESSAGE can also be "INFO"
This param sets which SIP method to use.
This commit is contained in:
Anthony Minessale committed 2014-04-16 06:10:25 +05:00
1 parent ae69c5a7b0
commit a4a792488b
7 files changed
+82 -1

No files matched your search

+32
View File
@@ -1124,6 +1124,38 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
/* ones that do not need to lock sofia mutex */
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_KEEPALIVE:
{
if (msg->numeric_arg) {
sofia_set_flag_locked(tech_pvt, TFLAG_KEEPALIVE);
} else {
sofia_clear_flag_locked(tech_pvt, TFLAG_KEEPALIVE);
}
}
break;
case SWITCH_MESSAGE_HEARTBEAT_EVENT:
{
char pl[160] = "";
switch_snprintf(pl, sizeof(pl), "KEEP-ALIVE %d\n", ++tech_pvt->keepalive);
if (sofia_test_flag(tech_pvt, TFLAG_KEEPALIVE)) {
if (tech_pvt->profile->keepalive == KA_MESSAGE) {
nua_message(tech_pvt->nh,
SIPTAG_CONTENT_TYPE_STR("text/plain"),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
SIPTAG_PAYLOAD_STR(pl),
TAG_END());
} else if (tech_pvt->profile->keepalive == KA_INFO) {
nua_info(tech_pvt->nh,
SIPTAG_CONTENT_TYPE_STR("text/plain"),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
SIPTAG_PAYLOAD_STR(pl),
TAG_END());
}
}
}
break;
case SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH:
case SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC:
break;
+8
View File
@@ -322,6 +322,7 @@ typedef enum {
TFLAG_CAPTURE,
TFLAG_REINVITED,
TFLAG_PASS_ACK,
TFLAG_KEEPALIVE,
/* No new flags below this line */
TFLAG_MAX
} TFLAGS;
@@ -534,6 +535,11 @@ typedef enum {
#define MAX_RTPIP 50
typedef enum {
KA_MESSAGE,
KA_INFO
} ka_type_t;
struct sofia_profile {
int debug;
int parse_invite_tel_params;
@@ -706,6 +712,7 @@ struct sofia_profile {
int tcp_keepalive;
int tcp_pingpong;
int tcp_ping2pong;
ka_type_t keepalive;
};
@@ -772,6 +779,7 @@ struct private_object {
int respond_code;
char *respond_dest;
time_t last_vid_info;
uint32_t keepalive;
};
+8
View File
@@ -4025,6 +4025,14 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
profile->debug = atoi(val);
} else if (!strcasecmp(var, "parse-invite-tel-params")) {
profile->parse_invite_tel_params = switch_true(val);
} else if (!strcasecmp(var, "keepalive-method")) {
if (!zstr(val)) {
if (!strcasecmp(val, "info")) {
profile->keepalive = KA_INFO;
} else {
profile->keepalive = KA_MESSAGE;
}
}
} else if (!strcasecmp(var, "shutdown-on-fail")) {
profile->shutdown_type = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "sip-trace") && switch_true(val)) {