aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl/src/commands/command_route.c
blob: 8e7db8192962662a40e6ef996238a9cba1fcaf08 (plain)
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
52
53
#include <math.h>
#include <hicn/ctrl/command.h>

/* Parameters */

#define 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_name),   \
  }

#define 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),                             \
  }

#define 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_type = OBJECT_TYPE_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_type = OBJECT_TYPE_ROUTE,
    .nparams = 0,
};
COMMAND_REGISTER(command_route_list);

static const command_parser_t command_route_remove = {
    .action = ACTION_DELETE,
    .object_type = OBJECT_TYPE_ROUTE,
    .nparams = 2,
    .parameters = {symbolic_or_id, prefix},
};
COMMAND_REGISTER(command_route_remove);