51 const char *str,
unsigned int msglevel)
69#define MSG_PAYLOAD "FgMBARkBAAEVAwNanUalkEDDxLBpZw9JnjI3tBM" \
70 "r4engpg/cDgS48DMaxyCdbzofNjQJU9Y0DD66z/notFT0cF1d60nTS" \
71 "4md4OJwoQAwEwITAxMBwCzAMACfzKnMqMyqwCvALwCewCTAKABrwCP" \
72 "AJwBnwArAFAA5wAnAEwAzAQAAnP8BAAEAAAsABAMAAQIACgAWABQAH" \
73 "QAXAB4AGQAYAQABAQECAQMBBAAWAAAAFwAAAA0AMAAuBAMFAwYDCAc" \
74 "ICAgaCBsIHAgJCAoICwgECAUIBgQBBQEGAQMDAwEDAgQCBQIGAgArA" \
75 "AUEAwQDAwAtAAIBAQAzACYAJAAdACCk4Tz2PB/2FsxOfOIV4gn/NyJ" \
76 "93rQwityP9eKSijXgcQ=="
81#ifndef ENABLE_MANAGEMENT
103 assert_string_equal(
mock_msg_buf,
"WARNING: Received malformed custom app control channel message (ACC not enabled or no negotiated protocols): 4143432c 63636b31 2c333834 2c362c46 674d4241 526b4241 41455641 774e616[more...]");
108 assert_string_equal(
mock_msg_buf,
"WARNING: Received malformed custom app control channel message (protocol 'cck1' not in list of negotiated protocols 'no:common:protocol'): 4143432c 63636b31 2c333834 2c362c46 674d4241 526b4241 41455641 774e616[more...]");
114 assert_string_equal(
mock_msg_buf,
"Received custom app control message (protocol 'cck1')");
117 const char flower_msg[] =
"ACC,flower,48,6,SSBhbSAAIEtlcm1pdCD//SB0aGUg77+94oCPZnJvZyEAAA==";
118 buf_set_read(&msg_buf, (
void *)flower_msg,
sizeof(flower_msg));
120 assert_string_equal(
mock_msg_buf,
"Received custom app control message (protocol 'flower')");
121 assert_string_equal(
mock_managment_buf,
">CLIENT:ACC,0,0,flower,0,SSBhbSAAIEtlcm1pdCD//SB0aGUg77+94oCPZnJvZyEAAA==");
124 const char msg_incorrect_len[] =
"ACC,fortune,62,6,InsgIm1lIjogImZyb2ciLCAAeGZm/SJtc2ciOiAiSSBhbSAAS2VybWl0IiB9Ig==";
125 buf_set_read(&msg_buf, (
void *)msg_incorrect_len,
sizeof(msg_incorrect_len));
127 const char *error =
"WARNING: Received malformed custom app control channel "
128 "message (field length 62, payload length 64 mismatch): "
129 "4143432c 666f7274 756e652c 36322c36 2c496e73 67496d31 "
130 "6c496a6f 67496d5[more...]";
136 const char msg_fragment[] =
"ACC,power,12,6F,aGVsbG8gdw==";
137 buf_set_read(&msg_buf, (
void *)msg_fragment,
sizeof(msg_fragment));
139 assert_string_equal(
mock_msg_buf,
"Received custom app control message (protocol 'power', fragment)");
144 const char flower_msg_two_encs[] =
"ACC,flower,48,6A,SSBhbSAAIEtlcm1pdCD//SB0aGUg77+94oCPZnJvZyEAAA==";
145 buf_set_read(&msg_buf, (
void *)flower_msg_two_encs,
sizeof(flower_msg_two_encs));
148 error =
"WARNING: Received malformed custom app control channel message "
149 "(number of encodings must be exactly one (B64=1, ASCII=1)): "
150 "4143432c 666c6f77 65722c34 382c3641 2c535342 68625341 41494574 "
157 const char flower_msg_no_encs[] =
"ACC,flower,48,,SSBhbSAAIEtlcm1pdCD//SB0aGUg77+94oCPZnJvZyEAAA==";
158 buf_set_read(&msg_buf, (
void *)flower_msg_no_encs,
sizeof(flower_msg_no_encs));
161 error =
"WARNING: Received malformed custom app control channel message "
162 "(number of encodings must be exactly one (B64=0, ASCII=0)): "
163 "4143432c 666c6f77 65722c34 382c2c53 53426862 53414149 45746c63 "
179 const char *info_acc_msg =
"4096 A:6 flower:happy";
183 assert_string_equal(protocols,
"flower:happy");
184 assert_int_equal(max_len, 1280);
188 assert_null(protocols);
191 info_acc_msg =
"1111 A:6 flower:happy";
193 assert_string_equal(protocols,
"flower:happy");
194 assert_int_equal(max_len, 1111);
197 assert_string_equal(protocols,
"flower:happy");
198 assert_int_equal(max_len, 1111);
201 info_acc_msg =
"1200 A:6:B flower:happy";
203 assert_null(protocols);
206 assert_string_equal(protocols,
"flower:happy");
207 assert_int_equal(max_len, 1200);
210 info_acc_msg =
"1400 A:6 flower:happy 77";
212 assert_null(protocols);
215 assert_null(protocols);
218 const char *iv_acc_capabilities =
"1400,A:6,flower:happy:power";
220 assert_string_equal(protocols,
"flower:happy:power");
223 info_acc_msg =
"32 A:6 flower:happy";
225 assert_null(protocols);
228 info_acc_msg =
"abff A:6 flower:happy";
230 assert_null(protocols);
256 assert_string_equal(
env_set_get(multi->
opt.
es,
"acc_protocols"),
"acc_protocols=power:flower");
257 assert_string_equal(
env_set_get(multi->
opt.
es,
"acc_message_len"),
"acc_message_len=1280");
284 "EMERGENCY BROADCAST MESSAGE - THIS IS NOT A DRILL:",
false);
288 "ACC,emergency,50,AF,EMERGENCY BROADCAST MESSAGE - THIS IS NOT A DRILL:");
291 "THE GOVERNMENT HAS ISSUED A RAINBOW COLOURED ALERT FOR YOUR AREA.",
false);
294 "ACC,emergency,65,A,THE GOVERNMENT HAS ISSUED A RAINBOW COLOURED ALERT FOR YOUR AREA.");
298 char long_message[1200] = { 0 };
300 for (
int i = 0; i < 1024; i++)
302 long_message[i] = (char)(
' ' + (i % 95));
306 assert_int_equal(long_message[1023],
'i');
307 assert_int_equal(long_message[1024],
'\0');
310 long_message,
false);
315 const char *expected_start_cc =
"ACC,emergency,1024,AF, !\"#$%&'()*+,-./012345";
325 const char *empty =
"";
326 const char *protos =
"power:flower:emergency";
331 assert_int_equal(
buf_len(&t1), 0);
334 assert_int_equal(
buf_len(&t2), 0);
337 assert_string_equal(
buf_cstr(&t3), protos);
339 const char *protos2 =
"flower:emergency:power:mario";
341 assert_string_equal(
buf_cstr(&t4),
"flower:emergency:power");
343 const char *protos3 =
"super:paper:mario:flower";
345 assert_string_equal(
buf_cstr(&t5),
"flower:mario");
347 const char *proto4 =
"flower:flower:flower:flower";
349 assert_string_equal(
buf_cstr(&t6),
"flower");
bool send_acc_message(struct context *c, struct tls_multi *multi, struct tls_session *session, const char *protocol, bool fragment, const char *acc_msg_payload, bool base64)
void receive_acc_message(struct context *c, const struct buffer *buffer)
This method parses an app custom control message and delivers it to the management interface.
char * parse_acc_parameters(const char *capabilities, const char *delim, int *max_acc_len, bool server, struct gc_arena *gc)
Parses an info message from the server that contains app custom control info information prior to the...
void determine_common_acc_protocols(struct tls_multi *multi, struct tls_session *session)
Parses the IV_ACC of the peer and sets multi.acc_negotiated_protocols to the common protocols of serv...
struct buffer get_list_intersection(struct gc_arena *gc, const char *list1, const char *list2)
Calculates the intersection of two list that are both separated by : Items in the result will have th...
static const char * buf_cstr(const struct buffer *buf)
Return the buffer content pointer cast to const char *.
static int buf_len(const struct buffer *buf)
Return the length of the buffer content.
static void buf_set_read(struct buffer *buf, const uint8_t *data, size_t size)
Initialise a buffer with an externally provided read-only memory region.
#define ALLOC_OBJ_CLEAR_GC(dptr, type, gc)
Allocate and zero-initialise a garbage-collected object of the given type.
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
const char * env_set_get(const struct env_set *es, const char *name)
struct env_set * env_set_create(struct gc_arena *gc)
#define TM_ACTIVE
Active tls_session.
char mock_managment_buf[MOCK_MSG_BUF]
char mock_msg_buf[MOCK_MSG_BUF]
Header file for server-mode related structures and functions.
Wrapper structure for dynamically allocated memory.
struct man_def_auth_context mda_context
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
Contains all state information for one tunnel.
struct context_2 c2
Level 2 context.
struct options options
Options loaded from command line or configuration file.
Garbage collection arena used to keep track of dynamically allocated memory.
Server-mode state structure for one single VPN tunnel.
struct context context
The context structure storing state for this VPN tunnel.
const char * acc_protocols
The app custom control protocols we should announce as supported.
Security parameter state for a single VPN tunnel.
char * peer_info
A multi-line string of general-purpose info received from peer over control channel.
int acc_max_message_length
the maximum length of an ACC control channel message
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
char * acc_negotiated_protocols
the protocols that are negotiated with the peer.
const char * acc_protocols
The app custom control protocols we should announce as supported.
struct man_def_auth_context * mda_context
Security parameter state of a single session within a VPN tunnel.
void test_acc_parse_client_messages(void **state)
void auth_set_client_reason(struct tls_multi *multi, const char *reason)
Sets the reason why authentication of a client failed.
void test_acc_send_message(void **state)
void test_acc_common_protocols(void **state)
void test_list_intersection(void **state)
bool send_control_channel_string_dowork(struct tls_session *session, const char *str, unsigned int msglevel)
char control_channel_message_sent[2048]
void test_parse_acc_parameters(void **state)
void send_push_reply_auth_token(struct tls_multi *multi)
Sends a push reply message only containin the auth-token to update the auth-token on the client.
#define assert_int_in_range(value, min, max)