reg-proxy: Added configuration parameter for setting registration expiry time
diff --git a/openbsc/include/openbsc/sip.h b/openbsc/include/openbsc/sip.h
index 581f3f3..e750e97 100644
--- a/openbsc/include/openbsc/sip.h
+++ b/openbsc/include/openbsc/sip.h
@@ -12,5 +12,5 @@
int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi);
int sip_client_init(struct reg_proxy *reg, const char *src_ip, u_int16_t src_port,
- const char *dst_ip, u_int16_t dst_port);
+ const char *dst_ip, u_int16_t dst_port, int expires_time);
#endif /* _SIP_H */
diff --git a/openbsc/include/openbsc/sip_client.h b/openbsc/include/openbsc/sip_client.h
index 23eaa7f..d705ecc 100644
--- a/openbsc/include/openbsc/sip_client.h
+++ b/openbsc/include/openbsc/sip_client.h
@@ -23,11 +23,13 @@
char *dst_ip;
u_int16_t src_port;
u_int16_t dst_port;
+ int expires_time;
};
struct sip_client *sip_client_create(const char *src_ip, u_int16_t src_port,
const char *dst_ip, u_int16_t dst_port,
- sip_read_cb_t read_cb, void *data);
+ int expires_time, sip_read_cb_t read_cb,
+ void *data);
void sip_client_destroy(struct sip_client *sip_client);
int sip_client_send(struct sip_client *sip_client, struct msgb *msg);
diff --git a/openbsc/src/reg-proxy/reg_proxy.c b/openbsc/src/reg-proxy/reg_proxy.c
index 9444df7..6b3487b 100644
--- a/openbsc/src/reg-proxy/reg_proxy.c
+++ b/openbsc/src/reg-proxy/reg_proxy.c
@@ -54,6 +54,7 @@
static const char *sip_dst_ip = "127.0.0.1";
static u_int16_t src_port = 5150;
static u_int16_t dst_port = 5060;
+static int expires_time = 3600;
struct log_info_cat ipa_proxy_test_cat[] = {
[DIPA_PROXY_TEST] = {
@@ -84,6 +85,7 @@
printf(" -s --src-port port Sip client port (source).\n");
printf(" -D --sip-dst-ip ip-addr Sip server IP address (destination).\n");
printf(" -d --dst-port port Sip server port (destination).\n");
+ printf(" -t --expires-time Registration expiry time in seconds.\n");
}
static void handle_options(int argc, char **argv)
@@ -96,10 +98,11 @@
{"src-port", 1, 0, 's'},
{"sip-dst-ip", 1, 0, 'D'},
{"dst-port", 1, 0, 'd'},
+ {"expires-time", 1, 0, 't'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, "hS:s:D:d:",
+ c = getopt_long(argc, argv, "hS:s:D:d:t:",
long_options, &option_index);
if (c == -1)
break;
@@ -121,6 +124,9 @@
case 'd':
dst_port = atoi(optarg);
break;
+ case 't':
+ expires_time = atoi(optarg);
+ break;
default:
/* ignore */
break;
@@ -254,7 +260,7 @@
////////////////////////////////
- rc = sip_client_init(reg, sip_src_ip, src_port, sip_dst_ip, dst_port);
+ rc = sip_client_init(reg, sip_src_ip, src_port, sip_dst_ip, dst_port, expires_time);
if (rc < 0) {
LOGP(DSUP, LOGL_FATAL, "Cannot set up SIP\n");
exit(2);
diff --git a/openbsc/src/reg-proxy/sip.c b/openbsc/src/reg-proxy/sip.c
index e09f452..7f74831 100644
--- a/openbsc/src/reg-proxy/sip.c
+++ b/openbsc/src/reg-proxy/sip.c
@@ -145,7 +145,7 @@
sprintf(tmp, "<sip:%s@%s:%s>", imsi, sip_client->src_ip, src_port);
osip_message_set_contact(reg_msg, tmp);
- sprintf(tmp, "%i", EXPIRES_TIME_INSECS);
+ sprintf(tmp, "%i", sip_client->expires_time);
osip_message_set_expires(reg_msg, tmp);
osip_message_set_content_length(reg_msg, "0");
@@ -493,10 +493,10 @@
int sip_client_init(struct reg_proxy *reg, const char *src_ip, u_int16_t src_port,
- const char *dst_ip, u_int16_t dst_port)
+ const char *dst_ip, u_int16_t dst_port, int expires_time)
{
- reg->sip_client = sip_client_create(src_ip, src_port, dst_ip, dst_port,
+ reg->sip_client = sip_client_create(src_ip, src_port, dst_ip, dst_port, expires_time,
&sip_read_cb, reg);
if (!reg->sip_client)
return -1;
diff --git a/openbsc/src/reg-proxy/sip_client.c b/openbsc/src/reg-proxy/sip_client.c
index f161fa9..28a9d22 100644
--- a/openbsc/src/reg-proxy/sip_client.c
+++ b/openbsc/src/reg-proxy/sip_client.c
@@ -191,7 +191,8 @@
*/
struct sip_client *sip_client_create(const char *src_ip, u_int16_t src_port,
const char *dst_ip, u_int16_t dst_port,
- sip_read_cb_t read_cb, void *data)
+ int expires_time, sip_read_cb_t read_cb,
+ void *data)
{
struct sip_client *sip_client;
int rc;
@@ -216,6 +217,7 @@
sip_client->src_ip = src_ip;
sip_client->dst_port = dst_port;
sip_client->src_port = src_port;
+ sip_client->expires_time = expires_time;
rc = sip_client_connect(sip_client);