1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "command.h"
/* Parameters */
static const command_parameter_t symbolic_or_id = {
.name = "symbolic_or_id",
.help = "The symbolic name for an egress, or the egress route id (see 'help list routes')",
.type = TYPE_SYMBOLIC_OR_ID,
.offset = offsetof(hc_route_t, face_id),
};
static const command_parameter_t prefix = {
.name = "prefix",
.help = "The hicn name as IPv4 or IPv6 address (e.g 1234::0/64).",
.type = TYPE_IP_PREFIX,
.offset = offsetof(hc_route_t, remote_addr),
.offset2 = offsetof(hc_route_t, len),
.offset3 = offsetof(hc_route_t, family),
};
static const command_parameter_t cost = {
.name = "cost",
.help = "Positive integer representing cost.",
.type = TYPE_INT(1, 255),
.offset = offsetof(hc_route_t, cost),
};
/* Commands */
static const command_parser_t command_route_create = {
.action = ACTION_CREATE,
.object = OBJECT_ROUTE,
.nparams = 3,
.parameters = { symbolic_or_id, prefix, cost },
};
COMMAND_REGISTER(command_route_create);
static const command_parser_t command_route_list = {
.action = ACTION_LIST,
.object = OBJECT_ROUTE,
.nparams = 0,
};
COMMAND_REGISTER(command_route_list);
static const command_parser_t command_route_remove = {
.action = ACTION_DELETE,
.object = OBJECT_ROUTE,
.nparams = 2,
.parameters = { symbolic_or_id, prefix },
};
COMMAND_REGISTER(command_route_remove);
|