reg-proxy: Implement purge ms forwarding and handling

This commit is contained in:
Ivan Kluchnikov 2016-12-15 13:00:00 +03:00
parent 8d8bedff4c
commit 444a9b9304
4 changed files with 44 additions and 15 deletions

View File

@ -9,7 +9,7 @@
int tx_ss_handle(struct sip_client *sip_client, osip_t *osip, struct ss_request *ss,
const char *extention);
int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi);
int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi, int expires_time);
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, int expires_time);

View File

@ -13,4 +13,7 @@ int sup_server_init(struct reg_proxy *reg);
int handle_location_update_result(struct gsm_sup_server *sup_server,
char *imsi, char *msisdn);
int handle_purge_ms_result(struct gsm_sup_server *sup_server,
char *imsi);
#endif /* _SUP_H */

View File

@ -78,7 +78,8 @@ int sip_send(struct sip_client *sip_client, osip_t *osip,
}
int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi)
int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi,
int expires_time)
{
osip_message_t *reg_msg;
@ -146,7 +147,7 @@ int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi)
sprintf(tmp, "<sip:%s@%s:%s>", imsi, sip_client->src_ip, src_port);
osip_message_set_contact(reg_msg, tmp);
sprintf(tmp, "%i", sip_client->expires_time);
sprintf(tmp, "%i", expires_time);
osip_message_set_expires(reg_msg, tmp);
osip_message_set_content_length(reg_msg, "0");
@ -264,17 +265,18 @@ void sip_cb_rcv2xx(int type, osip_transaction_t *tr, osip_message_t *sip_msg)
struct reg_proxy *reg = sip_client->data;
char imsi[16];
char msisdn[16];
osip_message_get_contact(sip_msg, 0, &contact);
memcpy(msisdn, contact->url->username, 16);
to = osip_message_get_to(sip_msg);
memcpy(imsi, to->url->username, 16);
printf("OSIP_NICT_STATUS_2XX_RECEIVED imsi = %s \n", imsi);
printf("OSIP_NICT_STATUS_2XX_RECEIVED msisdn = %d \n", msisdn);
printf("OSIP_NICT_STATUS_2XX_RECEIVED msisdn = %s \n", msisdn);
handle_location_update_result(reg->sup_server, imsi, msisdn);
if (osip_message_get_contact(sip_msg, 0, &contact) < 0) {
handle_purge_ms_result(reg->sup_server, imsi);
} else {
memcpy(msisdn, contact->url->username, 16);
printf("OSIP_NICT_STATUS_2XX_RECEIVED msisdn = %s \n", msisdn);
handle_location_update_result(reg->sup_server, imsi, msisdn);
}
}
void sip_cb_rcv2xx_again(int type, osip_transaction_t *pott,osip_message_t *pomt)

View File

@ -17,12 +17,27 @@ static int handle_sup_upd_loc_req(struct gsm_sup_server *sup_server,
osip_t *osip = reg->osip;
LOGGSUPP(LOGL_INFO, sup_msg,
"Try to send sip_register 0x%02x\n", sup_msg->message_type);
rc = tx_sip_register(sip_client, osip, sup_msg->imsi);
rc = tx_sip_register(sip_client, osip, sup_msg->imsi, sip_client->expires_time);
LOGGSUPP(LOGL_INFO, sup_msg,
"Sip_register was send 0x%02x\n", sup_msg->message_type);
return rc;
}
static int handle_sup_purge_ms_req(struct gsm_sup_server *sup_server,
struct gprs_gsup_message *sup_msg)
{
int rc = 0;
struct reg_proxy *reg = sup_server->app;
struct sip_client *sip_client = reg->sip_client;
osip_t *osip = reg->osip;
LOGGSUPP(LOGL_INFO, sup_msg,
"Try to send sip_register (cancellation) 0x%02x\n", sup_msg->message_type);
rc = tx_sip_register(sip_client, osip, sup_msg->imsi, 0);
LOGGSUPP(LOGL_INFO, sup_msg,
"Sip_register (cancellation) was send 0x%02x\n", sup_msg->message_type);
return rc;
}
#if 0
static int handle_sup_ss(struct gsm_sup_server *sup_server,
struct ss_request *ss,
@ -284,6 +299,9 @@ int rx_sup_message(struct gsm_sup_server *sup_server, struct msgb *msg)
case GPRS_GSUP_MSGT_LOCATION_CANCEL_ERROR:
case GPRS_GSUP_MSGT_LOCATION_CANCEL_RESULT:
case GPRS_GSUP_MSGT_PURGE_MS_REQUEST:
rc = handle_sup_purge_ms_req(sup_server, &sup_msg);
break;
case GPRS_GSUP_MSGT_INSERT_DATA_ERROR:
case GPRS_GSUP_MSGT_INSERT_DATA_RESULT:
LOGGSUPP(LOGL_ERROR, &sup_msg,
@ -304,10 +322,7 @@ int rx_sup_message(struct gsm_sup_server *sup_server, struct msgb *msg)
//subscr_put(subscr);
return
rc;
return rc;
}
static int tx_sup_message(struct gsm_sup_server *sup_server,
@ -354,6 +369,15 @@ int handle_location_update_result(struct gsm_sup_server *sup_server,
return tx_sup_message(sup_server, &gsup_msg);
}
int handle_purge_ms_result(struct gsm_sup_server *sup_server,
char *imsi)
{
struct gprs_gsup_message gsup_msg = {0};
gsup_msg.message_type = GPRS_GSUP_MSGT_PURGE_MS_RESULT;
memcpy(gsup_msg.imsi, imsi, 17);
return tx_sup_message(sup_server, &gsup_msg);
}
static int sup_read_cb(struct gsm_sup_server *sup_server, struct msgb *msg)
{
int rc;