aboutsummaryrefslogtreecommitdiff
path: root/src/nat/nat.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-10-23 19:16:26 +0000
committerChristian Grothoff <christian@grothoff.org>2016-10-23 19:16:26 +0000
commit588f820301bf298496e7bf0e6dea7b2c60ab3936 (patch)
treef96b19b8369be97fb2feca492833bf3f9d53e2f5 /src/nat/nat.h
parenta909bc99632f438857214641ea766ff5ca5a7760 (diff)
downloadgnunet-588f820301bf298496e7bf0e6dea7b2c60ab3936.tar.gz
gnunet-588f820301bf298496e7bf0e6dea7b2c60ab3936.zip
specing out the NAT service IPC messages'
Diffstat (limited to 'src/nat/nat.h')
-rw-r--r--src/nat/nat.h190
1 files changed, 179 insertions, 11 deletions
diff --git a/src/nat/nat.h b/src/nat/nat.h
index e7bee54c0..9ab402c1d 100644
--- a/src/nat/nat.h
+++ b/src/nat/nat.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2011 GNUnet e.V. 3 Copyright (C) 2011, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -66,7 +66,37 @@ struct GNUNET_NAT_TestMessage
66 66
67 67
68/** 68/**
69 * 69 * Flags specifying the events this client would be
70 * interested in being told about.
71 */
72enum GNUNET_NAT_RegisterFlags
73{
74 /**
75 * This client does not want any notifications.
76 */
77 GNUNET_NAT_RF_NONE = 0,
78
79 /**
80 * This client wants to be informed about our IPv4 address
81 * changing.
82 */
83 GNUNET_NAT_RF_IPV4 = 1,
84
85 /**
86 * This client wants to be informed about changes to our
87 * external addresses.
88 */
89 GNUNET_NAT_RF_ADDRESSES = 2,
90
91 /**
92 * This client supports address reversal.
93 */
94 GNUNET_NAT_RF_REVERSAL = 4
95};
96
97
98/**
99 * Message sent by a client to register with its addresses.
70 */ 100 */
71struct GNUNET_NAT_RegisterMessage 101struct GNUNET_NAT_RegisterMessage
72{ 102{
@@ -74,11 +104,38 @@ struct GNUNET_NAT_RegisterMessage
74 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REGISTER 104 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REGISTER
75 */ 105 */
76 struct GNUNET_MessageHeader header; 106 struct GNUNET_MessageHeader header;
107
108 /**
109 * An `enum GNUNET_NAT_RegisterFlags`.
110 */
111 uint8_t flags GNUNET_PACKED;
112
113 /**
114 * Client's IPPROTO, e.g. IPPROTO_UDP or IPPROTO_TCP.
115 */
116 uint8_t proto GNUNET_PACKED;
117
118 /**
119 * Port we would like as we are configured to use this one for
120 * advertising (in addition to the one we are binding to).
121 */
122 uint16_t adv_port GNUNET_PACKED;
123
124 /**
125 * Number of addresses that this service is bound to that follow.
126 * Given as an array of "struct sockaddr" entries, the size of
127 * each entry being determined by the "sa_family" at the beginning.
128 */
129 uint16_t num_addrs GNUNET_PACKED;
130
131 /* Followed by @e num_addrs addresses of type 'struct
132 sockaddr' */
133
77}; 134};
78 135
79 136
80/** 137/**
81 * 138 * Client telling the service to (possibly) handle a STUN message.
82 */ 139 */
83struct GNUNET_NAT_HandleStunMessage 140struct GNUNET_NAT_HandleStunMessage
84{ 141{
@@ -86,11 +143,25 @@ struct GNUNET_NAT_HandleStunMessage
86 * Header with type #GNUNET_MESSAGE_TYPE_NAT_HANDLE_STUN 143 * Header with type #GNUNET_MESSAGE_TYPE_NAT_HANDLE_STUN
87 */ 144 */
88 struct GNUNET_MessageHeader header; 145 struct GNUNET_MessageHeader header;
146
147 /**
148 * Size of the sender address included, in NBO.
149 */
150 uint16_t sender_addr_size;
151
152 /**
153 * Number of bytes of payload included, in NBO.
154 */
155 uint16_t payload_size;
156
157 /* followed by a `struct sockaddr` of @e sender_addr_size bytes */
158
159 /* followed by payload with @e payload_size bytes */
89}; 160};
90 161
91 162
92/** 163/**
93 * 164 * Client asking the service to initiate connection reversal.
94 */ 165 */
95struct GNUNET_NAT_RequestConnectionReversalMessage 166struct GNUNET_NAT_RequestConnectionReversalMessage
96{ 167{
@@ -98,11 +169,26 @@ struct GNUNET_NAT_RequestConnectionReversalMessage
98 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL 169 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL
99 */ 170 */
100 struct GNUNET_MessageHeader header; 171 struct GNUNET_MessageHeader header;
172
173 /**
174 * Size of the local address included, in NBO.
175 */
176 uint16_t local_addr_size;
177
178 /**
179 * Size of the remote address included, in NBO.
180 */
181 uint16_t remote_addr_size;
182
183 /* followed by a `struct sockaddr` of @e local_addr_size bytes */
184
185 /* followed by a `struct sockaddr` of @e remote_addr_size bytes */
186
101}; 187};
102 188
103 189
104/** 190/**
105 * 191 * Service telling a client that connection reversal was requested.
106 */ 192 */
107struct GNUNET_NAT_ConnectionReversalRequestedMessage 193struct GNUNET_NAT_ConnectionReversalRequestedMessage
108{ 194{
@@ -110,11 +196,27 @@ struct GNUNET_NAT_ConnectionReversalRequestedMessage
110 * Header with type #GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED 196 * Header with type #GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED
111 */ 197 */
112 struct GNUNET_MessageHeader header; 198 struct GNUNET_MessageHeader header;
199
200 /**
201 * Size of the local address where we received the request, in NBO.
202 */
203 uint16_t local_addr_size;
204
205 /**
206 * Size of the remote address making the request, in NBO.
207 */
208 uint16_t remote_addr_size;
209
210 /* followed by a `struct sockaddr` of @e local_addr_size bytes */
211
212 /* followed by a `struct sockaddr` of @e remote_addr_size bytes */
213
113}; 214};
114 215
115 216
116/** 217/**
117 * 218 * Service notifying the client about changes in the set of
219 * addresses it has.
118 */ 220 */
119struct GNUNET_NAT_AddressChangeNotificationMessage 221struct GNUNET_NAT_AddressChangeNotificationMessage
120{ 222{
@@ -122,11 +224,20 @@ struct GNUNET_NAT_AddressChangeNotificationMessage
122 * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE 224 * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE
123 */ 225 */
124 struct GNUNET_MessageHeader header; 226 struct GNUNET_MessageHeader header;
227
228 /**
229 * #GNUNET_YES to add, #GNUNET_NO to remove the address from the list.
230 */
231 int32_t add_remove GNUNET_PACKED;
232
233 /* followed by a `struct sockaddr` */
234
125}; 235};
126 236
127 237
128/** 238/**
129 * 239 * Service notifying the client about a change of our
240 * known external IPv4 address.
130 */ 241 */
131struct GNUNET_NAT_Ipv4ChangeNotificationMessage 242struct GNUNET_NAT_Ipv4ChangeNotificationMessage
132{ 243{
@@ -134,11 +245,22 @@ struct GNUNET_NAT_Ipv4ChangeNotificationMessage
134 * Header with type #GNUNET_MESSAGE_TYPE_NAT_IPV4_CHANGE 245 * Header with type #GNUNET_MESSAGE_TYPE_NAT_IPV4_CHANGE
135 */ 246 */
136 struct GNUNET_MessageHeader header; 247 struct GNUNET_MessageHeader header;
248
249 /**
250 * #GNUNET_YES to add, #GNUNET_NO to remove the address from the list.
251 */
252 int32_t add_remove GNUNET_PACKED;
253
254 /**
255 * IPv4 address affected.
256 */
257 struct in_addr addr GNUNET_PACKED;
258
137}; 259};
138 260
139 261
140/** 262/**
141 * 263 * Client requesting test of network connectivity.
142 */ 264 */
143struct GNUNET_NAT_RequestTestMessage 265struct GNUNET_NAT_RequestTestMessage
144{ 266{
@@ -146,11 +268,37 @@ struct GNUNET_NAT_RequestTestMessage
146 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_TEST 268 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_TEST
147 */ 269 */
148 struct GNUNET_MessageHeader header; 270 struct GNUNET_MessageHeader header;
271
272 /**
273 * Port to bind to, in NBO
274 */
275 uint16_t bind_port GNUNET_PACKED;
276
277 /**
278 * Port external verifier should try to connect to, in NBO.
279 */
280 uint16_t extern_port GNUNET_PACKED;
281
282 /**
283 * IPv4 to bind to, in NBO.
284 */
285 struct in_addr bind_ip GNUNET_PACKED;
286
287 /**
288 * IPv4 external verifier should try to connect to, in NBO.
289 */
290 struct in_addr extern_ip GNUNET_PACKED;
291
292 /**
293 * IP protocol to use, i.e. IPPROTO_UDP or IPPROTO_TCP.
294 */
295 uint8_t proto;
296
149}; 297};
150 298
151 299
152/** 300/**
153 * 301 * Service responding with network connectivity test result.
154 */ 302 */
155struct GNUNET_NAT_TestResultMessage 303struct GNUNET_NAT_TestResultMessage
156{ 304{
@@ -158,11 +306,16 @@ struct GNUNET_NAT_TestResultMessage
158 * Header with type #GNUNET_MESSAGE_TYPE_NAT_TEST_RESULT 306 * Header with type #GNUNET_MESSAGE_TYPE_NAT_TEST_RESULT
159 */ 307 */
160 struct GNUNET_MessageHeader header; 308 struct GNUNET_MessageHeader header;
309
310 /**
311 * An `enum GNUNET_NAT_StatusCode` in NBO.
312 */
313 int32_t status_code GNUNET_PACKED;
161}; 314};
162 315
163 316
164/** 317/**
165 * 318 * Client requesting automatic configuration.
166 */ 319 */
167struct GNUNET_NAT_AutoconfigRequestMessage 320struct GNUNET_NAT_AutoconfigRequestMessage
168{ 321{
@@ -170,11 +323,14 @@ struct GNUNET_NAT_AutoconfigRequestMessage
170 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG 323 * Header with type #GNUNET_MESSAGE_TYPE_NAT_REQUEST_AUTO_CFG
171 */ 324 */
172 struct GNUNET_MessageHeader header; 325 struct GNUNET_MessageHeader header;
326
327 /* Followed by configuration (diff, serialized, compressed) */
328
173}; 329};
174 330
175 331
176/** 332/**
177 * 333 * Service responding with proposed configuration.
178 */ 334 */
179struct GNUNET_NAT_AutoconfigResultMessage 335struct GNUNET_NAT_AutoconfigResultMessage
180{ 336{
@@ -182,6 +338,18 @@ struct GNUNET_NAT_AutoconfigResultMessage
182 * Header with type #GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT 338 * Header with type #GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT
183 */ 339 */
184 struct GNUNET_MessageHeader header; 340 struct GNUNET_MessageHeader header;
341
342 /**
343 * An `enum GNUNET_NAT_StatusCode` in NBO.
344 */
345 int32_t status_code GNUNET_PACKED;
346
347 /**
348 * An `enum GNUNET_NAT_Type` in NBO.
349 */
350 int32_t type GNUNET_PACKED;
351
352 /* Followed by configuration (diff, serialized, compressed) */
185}; 353};
186 354
187 355