summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-11-21 12:36:48 +0100
committerPatrick McHardy <kaber@trash.net>2010-11-21 20:04:30 +0100
commit360ca87ffc822d6d12362a9abd1c58abb2ca0949 (patch)
tree252c45137176e885b88fdad8a8965b47f4232173
parent42aff744b9d9fdbd992991d56b1d11e9f4e70d1a (diff)
cmd-parser: add MNSS_FACILITY-req, parse primitives in cluster context
Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--include/dectmon.h2
-rw-r--r--src/cli.c3
-rw-r--r--src/cmd-parser.y118
-rw-r--r--src/cmd-scanner.l10
-rw-r--r--src/main.c10
5 files changed, 136 insertions, 7 deletions
diff --git a/include/dectmon.h b/include/dectmon.h
index 5d48530..a30b397 100644
--- a/include/dectmon.h
+++ b/include/dectmon.h
@@ -38,6 +38,8 @@ struct dect_handle_priv {
struct dect_tbc *slots[DECT_FRAME_SIZE];
};
+extern struct dect_handle_priv *dect_handle_get_by_name(const char *name);
+
enum dect_mm_procedures {
DECT_MM_NONE,
DECT_MM_KEY_ALLOCATION,
diff --git a/src/cli.c b/src/cli.c
index 3b79bc4..c853183 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -84,10 +84,13 @@ static const char *keywords[] = {
"llme",
"MNCC_SETUP-req",
"MNCC_INFO-req",
+ "MNSS_FACILITY-req",
+ "portable-identity",
"sending-complete",
"keypad",
"basic-service",
"escape-to-proprietary",
+ "IPEI",
"info",
"service",
"class",
diff --git a/src/cmd-parser.y b/src/cmd-parser.y
index 59432a4..90c3aa3 100644
--- a/src/cmd-parser.y
+++ b/src/cmd-parser.y
@@ -81,9 +81,11 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%union {
uint64_t val;
const char *string;
+ struct dect_handle *dh;
struct dect_ie_common *ie;
struct dect_mncc_setup_param *mncc_setup_param;
struct dect_mncc_info_param *mncc_info_param;
+ struct dect_mnss_param *mnss_param;
}
%token TOKEN_EOF 0 "end of file"
@@ -114,11 +116,16 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%token MNCC_SETUP_REQ "MNCC_SETUP-req"
%token MNCC_INFO_REQ "MNCC_INFO-req"
+%token MNSS_FACILITY_REQ "MNSS_FACILITY-req"
+
+%token PORTABLE_IDENTITY "portable-identity"
%token SENDING_COMPLETE "sending-complete"
%token KEYPAD "keypad"
%token BASIC_SERVICE "basic-service"
%token ESCAPE_TO_PROPRIETARY "escape-to-proprietary"
+%token IPEI "IPEI"
+
%token INFO "info"
%token SERVICE "service"
%token CLASS "class"
@@ -147,12 +154,20 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%type <val> debug_subsys on_off
+%type <dh> cluster
+
%type <mncc_setup_param> mncc_setup_param_alloc
%type <mncc_setup_param> mncc_setup_params mncc_setup_param
%type <mncc_info_param> mncc_info_param_alloc
%type <mncc_info_param> mncc_info_params mncc_info_param
+%type <mnss_param> mnss_param_alloc
+%type <mnss_param> mnss_params mnss_param
+
+%type <ie> portable_identity_ie portable_identity_ie_alloc
+%type <ie> portable_identity_ie_params portable_identity_ie_param
+
%type <ie> keypad_ie keypad_ie_alloc
%type <ie> sending_complete_ie
@@ -175,6 +190,7 @@ line : cluster_stmt
| tbc_stmt
| debug_stmt
| cc_primitive
+ | ss_primitive
;
cluster_stmt : CLUSTER SHOW
@@ -250,6 +266,23 @@ on_off : ON { $$ = true; }
| OFF { $$ = false; }
;
+cluster : STRING
+ {
+ struct dect_handle_priv *priv;
+
+ priv = dect_handle_get_by_name($1);
+ if (priv == NULL) {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "cluster '%s' does not exist\n", $1);
+ yyerror(&@1, scanner, state, buf);
+ YYABORT;
+ } else
+ $$ = priv->dh;
+
+ }
+ ;
+
cc_primitive : mncc_setup_req
| mncc_info_req
;
@@ -258,19 +291,19 @@ cc_primitive : mncc_setup_req
* MNCC_SETUP-req
*/
-mncc_setup_req : MNCC_SETUP_REQ mncc_setup_param_alloc '(' mncc_setup_params ')'
+mncc_setup_req : MNCC_SETUP_REQ '(' cluster mncc_setup_param_alloc ',' mncc_setup_params ')'
{
- struct dect_handle *dh = parser_get_handle();
+ struct dect_handle *dh = $3;
struct dect_ipui ipui = {};
struct dect_call *call;
call = dect_call_alloc(dh);
- dect_mncc_setup_req(dh, call, &ipui, $2);
+ dect_mncc_setup_req(dh, call, &ipui, $4);
}
mncc_setup_param_alloc :
{
- $$ = dect_ie_collection_alloc(parser_get_handle(),
+ $$ = dect_ie_collection_alloc($<dh>0,
sizeof(struct dect_mncc_setup_param));
}
;
@@ -282,7 +315,11 @@ mncc_setup_params : mncc_setup_param
| mncc_setup_params ',' mncc_setup_param
;
-mncc_setup_param : keypad_ie
+mncc_setup_param : portable_identity_ie
+ {
+ //$<mncc_setup_param>-1->portable_identity = (struct dect_ie_portable_identity *)$1;
+ }
+ | keypad_ie
{
$<mncc_setup_param>-1->keypad = (struct dect_ie_keypad *)$1;
}
@@ -304,14 +341,14 @@ mncc_setup_param : keypad_ie
* MNCC_INFO-req
*/
-mncc_info_req : MNCC_INFO_REQ mncc_info_param_alloc '(' mncc_info_params ')'
+mncc_info_req : MNCC_INFO_REQ '(' cluster mncc_info_param_alloc ',' mncc_info_params ')'
{
}
;
mncc_info_param_alloc :
{
- $$ = dect_ie_collection_alloc(parser_get_handle(),
+ $$ = dect_ie_collection_alloc($<dh>0,
sizeof(struct dect_mncc_info_param));
}
;
@@ -337,6 +374,73 @@ mncc_info_param : keypad_ie
}
;
+ss_primitive : mnss_facility_req
+ ;
+
+/*
+ * MNSS_FACILITY-req
+ */
+
+mnss_facility_req : MNSS_FACILITY_REQ '(' cluster mnss_param_alloc ',' mnss_params ')'
+ {
+ struct dect_handle *dh = $3;
+ struct dect_ipui ipui = {};
+ struct dect_ss_endpoint *sse;
+
+ sse = dect_ss_endpoint_alloc(dh, &ipui);
+ dect_mnss_facility_req(dh, sse, $4);
+ }
+ ;
+
+mnss_param_alloc :
+ {
+ $$ = dect_ie_collection_alloc($<dh>0,
+ sizeof(struct dect_mnss_param));
+ }
+ ;
+
+mnss_params : mnss_param
+ | mnss_params ',' mnss_param
+ ;
+
+mnss_param : keypad_ie
+ {
+ $<mnss_param>-1->keypad = (struct dect_ie_keypad *)$1;
+ }
+ | etp_ie
+ {
+ $<mnss_param>-1->escape_to_proprietary = (struct dect_ie_escape_to_proprietary *)$1;
+ }
+ ;
+
+/*
+ * Portable Identity IE
+ */
+
+portable_identity_ie : PORTABLE_IDENTITY portable_identity_ie_alloc '(' portable_identity_ie_params ')'
+ {
+ $$ = $2;
+ }
+ ;
+
+portable_identity_ie_alloc:
+ {
+ $$ = dect_ie_alloc(parser_get_handle(), sizeof(struct dect_ie_portable_identity));
+ }
+ ;
+
+portable_identity_ie_params: portable_identity_ie_param
+ | portable_identity_ie_params ',' portable_identity_ie_param
+ ;
+
+portable_identity_ie_param: IPEI '=' STRING
+ {
+ struct dect_ie_portable_identity *ie = dect_ie_container(ie, $<ie>-1);
+
+ dect_parse_ipei_string(&ie->ipui.pun.n.ipei, $3);
+ }
+ ;
+
/*
* Keypad IE
*/
diff --git a/src/cmd-scanner.l b/src/cmd-scanner.l
index b32c898..6ad121a 100644
--- a/src/cmd-scanner.l
+++ b/src/cmd-scanner.l
@@ -100,11 +100,16 @@ slash \/
"MNCC_SETUP-req" { return MNCC_SETUP_REQ; }
"MNCC_INFO-req" { return MNCC_INFO_REQ; }
+"MNSS_FACILITY-req" { return MNSS_FACILITY_REQ; }
+
+"portable-identity" { return PORTABLE_IDENTITY; }
"sending-complete" { return SENDING_COMPLETE; }
"keypad" { return KEYPAD; }
"basic-service" { return BASIC_SERVICE; }
"escape-to-proprietary" { return ESCAPE_TO_PROPRIETARY; }
+"IPEI" { return IPEI; }
+
"info" { return INFO; }
"service" { return SERVICE; }
"class" { return CLASS; }
@@ -136,6 +141,11 @@ slash \/
return STRING;
}
+{quotedstring} {
+ yylval->string = strndup(yytext + 1, yyleng - 2);
+ return STRING;
+ }
+
{decstring} {
yylval->val = strtoul(yytext, NULL, 0);
return NUMBER;
diff --git a/src/main.c b/src/main.c
index ec86855..e507113 100644
--- a/src/main.c
+++ b/src/main.c
@@ -59,6 +59,16 @@ static struct dect_handle_priv *dect_handle_lookup(const struct dect_ari *pari)
return NULL;
}
+struct dect_handle_priv *dect_handle_get_by_name(const char *name)
+{
+ struct dect_handle_priv *priv;
+
+ list_for_each_entry(priv, &dect_handles, list)
+ if (!strcmp(name, priv->cluster))
+ return priv;
+ return NULL;
+}
+
static void dect_lock_timer(struct dect_handle *dh, struct dect_timer *timer)
{
struct dect_handle_priv *priv = dect_handle_priv(dh);