mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-06 15:03:19 +00:00
nat: Make the USSD number matching a regexp
This allows to match multiple numbers and multiple patterns
This commit is contained in:
@@ -249,6 +249,7 @@ struct bsc_nat {
|
|||||||
/* USSD messages we want to match */
|
/* USSD messages we want to match */
|
||||||
char *ussd_lst_name;
|
char *ussd_lst_name;
|
||||||
char *ussd_query;
|
char *ussd_query;
|
||||||
|
regex_t ussd_query_re;
|
||||||
char *ussd_token;
|
char *ussd_token;
|
||||||
char *ussd_local;
|
char *ussd_local;
|
||||||
struct bsc_fd ussd_listen;
|
struct bsc_fd ussd_listen;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* OpenBSC NAT interface to quagga VTY */
|
/* OpenBSC NAT interface to quagga VTY */
|
||||||
/* (C) 2010 by Holger Hans Peter Freyther
|
/* (C) 2010-2011 by Holger Hans Peter Freyther
|
||||||
* (C) 2010 by On-Waves
|
* (C) 2010-2011 by On-Waves
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -463,11 +463,11 @@ DEFUN(cfg_nat_ussd_lst_name,
|
|||||||
|
|
||||||
DEFUN(cfg_nat_ussd_query,
|
DEFUN(cfg_nat_ussd_query,
|
||||||
cfg_nat_ussd_query_cmd,
|
cfg_nat_ussd_query_cmd,
|
||||||
"ussd-query QUERY",
|
"ussd-query REGEXP",
|
||||||
"Set the USSD query to match with the ussd-list-name\n"
|
"Set the USSD query to match with the ussd-list-name\n"
|
||||||
"The query to match")
|
"The query to match")
|
||||||
{
|
{
|
||||||
bsc_replace_string(_nat, &_nat->ussd_query, argv[0]);
|
bsc_parse_reg(_nat, &_nat->ussd_query_re, &_nat->ussd_query, argc, argv);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/* USSD Filter Code */
|
/* USSD Filter Code */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
* (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
|
||||||
* (C) 2010 by On-Waves
|
* (C) 2010-2011 by On-Waves
|
||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -352,7 +352,7 @@ int bsc_check_ussd(struct sccp_connections *con, struct bsc_nat_parsed *parsed,
|
|||||||
if (req.text[0] == 0xff)
|
if (req.text[0] == 0xff)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strcmp(req.text, con->bsc->nat->ussd_query) != 0)
|
if (regexec(&con->bsc->nat->ussd_query_re, req.text, 0, NULL, 0) == REG_NOMATCH)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* found a USSD query for our subscriber */
|
/* found a USSD query for our subscriber */
|
||||||
|
|||||||
Reference in New Issue
Block a user