MT#61856 control_ng: introduce NG commands table

Introduce a common NG commands table `ng_command_defs`
for all type of things: OP enum, name, escaped name,
short name and most important the handler.

This table operates on and returns a dedicated struct `ng_command_def`,
which has all the information required on the command (like
all type of things mentioned above) and may have either
single-parameter or double-parameter signature (for cases with
the `addr` requiring commands such as the offer command).

Also add unified signatures for X and XA handlers,
they will be used later accordingly. Most of those use single-parameter,
and those exceptional use the second one.

Also add dummy plug-functions for ping and block/unblock silence media.
The ping one doesn't have any particular handler, but because a new
structure of NG commands wants to see a real declaration of the func
handler, just give it. For the block/unblock silence media, there aren't
even handling of commands in the control NG, they are just dummy OPs,
so fulfill the actual NG commands structure, and give them dummy funcs.

Change-Id: I2064ddca1595079959a6c6843119556a8b6bf5d5
mr26.1
Donat Zenichev 2 weeks ago
parent 98d9bf091f
commit 551ba3d82d

@ -720,6 +720,12 @@ out:
return errstr;
}
const char *call_ping_ng(ng_command_ctx_t *ctx)
{
/* consider ping as always unconditionally ok */
return NULL;
}
const char *call_offer_ng(ng_command_ctx_t *ctx,
const char *addr)
{

@ -31,6 +31,30 @@ const char magic_load_limit_strings[__LOAD_LIMIT_MAX][64] = {
[LOAD_LIMIT_BW] = "Bandwidth limit exceeded",
};
typedef const char *(*ng_command_handler_t)(ng_command_ctx_t *ctx);
typedef const char *(*ng_command_addr_handler_t)(ng_command_ctx_t *ctx,
const char *addr);
struct ng_command_def {
enum ng_opmode opmode;
const char *name;
const char *escaped_name;
const char *short_name;
/* Only one of handler/addr_handler should be set at a time */
ng_command_handler_t handler;
ng_command_addr_handler_t addr_handler;
};
static const struct ng_command_def ng_command_defs[OP_COUNT] = {
#define X(op, name, esc, short_name, handler) \
[op] = { op, name, esc, short_name, handler, NULL },
#define XA(op, name, esc, short_name, handler) \
[op] = { op, name, esc, short_name, NULL, handler },
NG_COMMANDS(X, XA)
#undef XA
#undef X
};
const char *ng_command_strings[OP_COUNT] = {
#define X(op, name, esc, short_name, handler) [op] = name,
#define XA(op, name, esc, short_name, handler) [op] = name,

@ -28,6 +28,7 @@ str call_lookup_udp(char **);
str call_delete_udp(char **);
str call_query_udp(char **);
const char *call_ping_ng(ng_command_ctx_t *ctx);
const char *call_offer_ng(ng_command_ctx_t *, const char *);
const char *call_answer_ng(ng_command_ctx_t *);
const char *call_delete_ng(ng_command_ctx_t *);

Loading…
Cancel
Save