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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
#include <hicn/ctrl/command.h>
/* Parameters */
#define type_hicn \
{ \
.name = "type", .help = "face type (hICN)", .type = TYPE_ENUM(face_type), \
.offset = offsetof(hc_face_t, type), \
}
#define type_tcp_udp \
{ \
.name = "type", .help = "face type [tcp | udp]", \
.type = TYPE_ENUM(face_type), .offset = offsetof(hc_face_t, type), \
}
#define local_address \
{ \
.name = "local_addr", .help = "local IP address on which to bind.", \
.type = TYPE_IP_ADDRESS, .offset = offsetof(hc_face_t, local_addr), \
.offset2 = offsetof(hc_face_t, family), \
}
#define local_port \
{ \
.name = "local_port", .help = "Local port.", \
.type = TYPE_UINT16(1, UINT16_MAX), \
.offset = offsetof(hc_face_t, local_port), \
}
#define remote_address \
{ \
.name = "remote_address", \
.help = "The IPv4 or IPv6 or hostname of the remote system.", \
.type = TYPE_IP_ADDRESS, .offset = offsetof(hc_face_t, remote_addr), \
.offset2 = offsetof(hc_face_t, family), \
}
#define remote_port \
{ \
.name = "remote_port", .help = "Remote port.", \
.type = TYPE_UINT16(1, UINT16_MAX), \
.offset = offsetof(hc_face_t, remote_port), \
}
#define interface \
{ \
.name = "interface", .help = "Interface on which to bind", \
.type = TYPE_INTERFACE_NAME, \
.offset = offsetof(hc_face_t, netdevice.name), \
}
#define symbolic_or_id \
{ \
.name = "symbolic", .help = "The face symbolic name or id", \
.type = TYPE_SYMBOLIC_OR_ID, .offset = offsetof(hc_face_t, name), \
}
/* Commands */
int on_face_create(hc_face_t* face) {
face->admin_state = FACE_STATE_UP;
face->id = INVALID_FACE_ID;
return 0;
}
#if 0
static command_parser_t command_face_create3 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_FACE,
.nparams = 3,
.parameters = {type_hicn, local_address, remote_address},
.post_hook = (parser_hook_t)on_face_create,
};
COMMAND_REGISTER(command_face_create3);
static const command_parser_t command_face_create4 = {
.action = ACTION_CREATE,
.object = OBJECT_TYPE_FACE,
.nparams = 4,
.parameters = {type_hicn, local_address, remote_address,
interface},
.post_hook = (parser_hook_t)on_face_create,
};
COMMAND_REGISTER(command_face_create4);
#endif
static const command_parser_t command_face_create3 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_FACE,
.nparams = 3,
.parameters = {type_tcp_udp, remote_address, remote_port},
.post_hook = (parser_hook_t)on_face_create,
};
COMMAND_REGISTER(command_face_create3);
static const command_parser_t command_face_create4 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_FACE,
.nparams = 4,
.parameters = {type_tcp_udp, remote_address, remote_port, interface},
.post_hook = (parser_hook_t)on_face_create,
};
COMMAND_REGISTER(command_face_create4);
static const command_parser_t command_face_create5 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_FACE,
.nparams = 5,
.parameters = {type_tcp_udp, local_address, local_port, remote_address,
remote_port},
.post_hook = (parser_hook_t)on_face_create,
};
COMMAND_REGISTER(command_face_create5);
static const command_parser_t command_face_create6 = {
.action = ACTION_CREATE,
.object_type = OBJECT_TYPE_FACE,
.nparams = 6,
.parameters = {type_tcp_udp, local_address, local_port, remote_address,
remote_port, interface},
.post_hook = (parser_hook_t)on_face_create,
};
COMMAND_REGISTER(command_face_create6);
static const command_parser_t command_face_list = {
.action = ACTION_LIST,
.object_type = OBJECT_TYPE_FACE,
.nparams = 0,
};
COMMAND_REGISTER(command_face_list);
static const command_parser_t command_face_remove6 = {
.action = ACTION_DELETE,
.object_type = OBJECT_TYPE_FACE,
.nparams = 6,
.parameters = {type_tcp_udp, local_address, local_port, remote_address,
remote_port, interface},
};
COMMAND_REGISTER(command_face_remove6);
static const command_parser_t command_face_remove1 = {
.action = ACTION_DELETE,
.object_type = OBJECT_TYPE_FACE,
.nparams = 1,
.parameters = {symbolic_or_id},
};
COMMAND_REGISTER(command_face_remove1);
|