@@ -43,25 +43,29 @@ static const char sock_connect_usage_str[] =
4343 "Usage: sock connect -a <address> -p <port>\n"
4444 " [-f <family>] [-t <type>] [-b <port>] [-I <cid>] [-K]\n"
4545 " [-S] [-T <sec_tag>] [-c] [-V <level>] [-H <hostname>]\n"
46+ " [-C <dtls_cid>] [-F <dtls_frag_ext>]\n"
4647 "Options:\n"
47- " -a, --address, [str] Address as ip address or hostname\n"
48- " -p, --port, [int] Port\n"
49- " -f, --family, [str] Address family: 'inet' (ipv4, default),\n"
50- " 'inet6' (ipv6) or 'packet'\n"
51- " -t, --type, [str] Address type: 'stream' (tcp, default),\n"
52- " 'dgram' (udp) or 'raw'\n"
53- " -b, --bind_port, [int] Local port to bind the socket to\n"
54- " -I, --cid, [int] Use this option to bind socket to specific\n"
55- " PDN CID. See link command for available CIDs.\n"
56- " -K, --keep_open Keep socket open when its PDN connection is lost.\n"
57- " -S, --secure, Enable secure connection (TLS 1.2/DTLS 1.2).\n"
58- " -T, --sec_tag, [int] Security tag for TLS certificate(s).\n"
59- " -c, --cache, Enable TLS session cache.\n"
60- " -V, --peer_verify, [int] TLS peer verification level. None (0),\n"
61- " optional (1) or required (2). Default value is 2.\n"
62- " -H, --hostname, [str] Hostname for TLS peer verification.\n"
63- " -C, --dtls_cid, [int] DTLS CID setting: 0 (disabled), 1 (supported), 2 (enabled).\n"
64- " -h, --help, Shows this help information" ;
48+ " -a, --address, [str] Address as ip address or hostname\n"
49+ " -p, --port, [int] Port\n"
50+ " -f, --family, [str] Address family: 'inet' (ipv4, default),\n"
51+ " 'inet6' (ipv6) or 'packet'\n"
52+ " -t, --type, [str] Address type: 'stream' (tcp, default),\n"
53+ " 'dgram' (udp) or 'raw'\n"
54+ " -b, --bind_port, [int] Local port to bind the socket to\n"
55+ " -I, --cid, [int] Use this option to bind socket to specific\n"
56+ " PDN CID. See link command for available CIDs.\n"
57+ " -K, --keep_open Keep socket open when its PDN connection is lost.\n"
58+ " -S, --secure, Enable secure connection (TLS 1.2/DTLS 1.2).\n"
59+ " -T, --sec_tag, [int] Security tag for TLS certificate(s).\n"
60+ " -c, --cache, Enable TLS session cache.\n"
61+ " -V, --peer_verify, [int] TLS peer verification level: 0 (none), 1 (optional) or\n"
62+ " 2 (required, default).\n"
63+ " -H, --hostname, [str] Hostname for TLS peer verification.\n"
64+ " -C, --dtls_cid, [int] DTLS CID setting: 0 (disabled, default), 1 (supported) or\n"
65+ " 2 (enabled).\n"
66+ " -F, --dtls_frag_ext, [int] DTLS fragmentation extension setting:\n"
67+ " 0 (disabled, default), 1 (512 bytes) or 2 (1024 bytes).\n"
68+ " -h, --help, Shows this help information" ;
6569
6670static const char sock_close_usage_str [] =
6771 "Usage: sock close -i <socket id>\n"
@@ -259,6 +263,7 @@ static struct option long_options[] = {
259263 { "peer_verify" , required_argument , 0 , 'V' },
260264 { "hostname" , required_argument , 0 , 'H' },
261265 { "dtls_cid" , required_argument , 0 , 'C' },
266+ { "dtls_frag_ext" , required_argument , 0 , 'F' },
262267 { "data" , required_argument , 0 , 'd' },
263268 { "length" , required_argument , 0 , 'l' },
264269 { "period" , required_argument , 0 , 'e' },
@@ -282,7 +287,7 @@ static struct option long_options[] = {
282287 { 0 , 0 , 0 , 0 }
283288};
284289
285- static const char short_options [] = "i:I:a:p:f:t:b:ST:cV:H:C:d:l:e:s:xrB:WKP:o:v:h" ;
290+ static const char short_options [] = "i:I:a:p:f:t:b:ST:cV:H:C:F: d:l:e:s:xrB:WKP:o:v:h" ;
286291
287292static void sock_print_usage (enum sock_shell_command command )
288293{
@@ -438,6 +443,7 @@ static int cmd_sock_connect(const struct shell *shell, size_t argc, char **argv)
438443 int arg_peer_verify = 2 ;
439444 char arg_peer_hostname [SOCK_MAX_ADDR_LEN + 1 ];
440445 int arg_dtls_cid = 0 ;
446+ int arg_dtls_frag_ext = 0 ;
441447
442448 memset (arg_address , 0 , SOCK_MAX_ADDR_LEN + 1 );
443449 memset (arg_peer_hostname , 0 , SOCK_MAX_ADDR_LEN + 1 );
@@ -565,7 +571,15 @@ static int cmd_sock_connect(const struct shell *shell, size_t argc, char **argv)
565571 return - EINVAL ;
566572 }
567573 break ;
568-
574+ case 'F' : /* DTLS fragmentation extension */
575+ arg_dtls_frag_ext = atoi (optarg );
576+ if (arg_dtls_frag_ext < 0 || arg_dtls_frag_ext > 2 ) {
577+ mosh_error (
578+ "Valid values for DTLS fragmentation extension (%d) are "
579+ "0, 1 and 2." , arg_dtls_frag_ext );
580+ return - EINVAL ;
581+ }
582+ break ;
569583 case 'h' :
570584 goto show_usage ;
571585 case '?' :
@@ -593,7 +607,8 @@ static int cmd_sock_connect(const struct shell *shell, size_t argc, char **argv)
593607 arg_keep_open ,
594608 arg_peer_verify ,
595609 arg_peer_hostname ,
596- arg_dtls_cid );
610+ arg_dtls_cid ,
611+ arg_dtls_frag_ext );
597612
598613 return err ;
599614
0 commit comments