From: Kevin Day Date: Fri, 7 Jul 2023 03:37:08 +0000 (-0500) Subject: Update: The f_socket enumerations and comments, the f_socket_t structure, the f_socke... X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=165b96f670d2e617cec8b1524f148b5ad04e5e6c;p=fll Update: The f_socket enumerations and comments, the f_socket_t structure, the f_socket build settings, and the f_socket unit tests. The _di_f_socket_protocol_e_ enumerations are missing the trailing "_e" in the name. As stated in a previous commit (90d0f47999fd5615f2f3550d688f63d49e590482), update the documentation comments for the f_socket_protocol_family_e enumerations. Change the ordering of properties in the f_socket_t to have length property after the address property. Set the default string for the name property to be f_string_static_t_initialize instead of f_string_empty_s. Disable the braces warning in f_console. The brace usage here is correct, and so the warning is disabled. Fix the unit tests as they were not updated after changes in the previous commit (90d0f47999fd5615f2f3550d688f63d49e590482) and in this commit. --- diff --git a/level_0/f_socket/c/socket/common.h b/level_0/f_socket/c/socket/common.h index 1a8fc1c..b1ddf5d 100644 --- a/level_0/f_socket/c/socket/common.h +++ b/level_0/f_socket/c/socket/common.h @@ -466,61 +466,61 @@ extern "C" { */ #ifndef _di_f_socket_protocol_e_ enum { - f_socket_protocol_ip = 0, - f_socket_protocol_ah = 51, - f_socket_protocol_ax25 = 93, - f_socket_protocol_dccp = 33, - f_socket_protocol_ddp = 37, - f_socket_protocol_egp = 8, - f_socket_protocol_eigrp = 88, - f_socket_protocol_encap = 98, - f_socket_protocol_encryption = 99, - f_socket_protocol_esp = 50, - f_socket_protocol_etherip = 97, - f_socket_protocol_fc = 133, - f_socket_protocol_ggp = 3, - f_socket_protocol_gre = 47, - f_socket_protocol_hip = 139, - f_socket_protocol_hmp = 20, - f_socket_protocol_icmp = 1, - f_socket_protocol_idpr_cmtp = 38, - f_socket_protocol_idrp = 45, - f_socket_protocol_igmp = 2, - f_socket_protocol_igp = 9, - f_socket_protocol_ipcomp = 108, - f_socket_protocol_ipencap = 4, - f_socket_protocol_ipip = 94, - f_socket_protocol_ipv6 = 41, - f_socket_protocol_ipv6_frag = 44, - f_socket_protocol_ipv6_icmp = 58, - f_socket_protocol_ipv6_nonxt = 59, - f_socket_protocol_ipv6_opts = 60, - f_socket_protocol_ipv6_route = 43, - f_socket_protocol_isis = 124, - f_socket_protocol_iso_tp4 = 29, - f_socket_protocol_l2tp = 115, - f_socket_protocol_manet = 138, - f_socket_protocol_mobility_header = 135, - f_socket_protocol_mpls_in_ip = 137, - f_socket_protocol_ospf = 89, - f_socket_protocol_pim = 103, - f_socket_protocol_pup = 12, - f_socket_protocol_rdp = 27, - f_socket_protocol_rohc = 142, - f_socket_protocol_rspf = 73, - f_socket_protocol_rsvp = 46, - f_socket_protocol_sctp = 132, - f_socket_protocol_shim6 = 140, - f_socket_protocol_skip = 57, - f_socket_protocol_st = 5, - f_socket_protocol_tcp = 6, - f_socket_protocol_udp = 17, - f_socket_protocol_udplite = 136, - f_socket_protocol_vmtp = 81, - f_socket_protocol_vrrp = 112, - f_socket_protocol_wesp = 141, - f_socket_protocol_xns_idp = 22, - f_socket_protocol_xtp = 36, + f_socket_protocol_ip_e = 0, + f_socket_protocol_ah_e = 51, + f_socket_protocol_ax25_e = 93, + f_socket_protocol_dccp_e = 33, + f_socket_protocol_ddp_e = 37, + f_socket_protocol_egp_e = 8, + f_socket_protocol_eigrp_e = 88, + f_socket_protocol_encap_e = 98, + f_socket_protocol_encryption_e = 99, + f_socket_protocol_esp_e = 50, + f_socket_protocol_etherip_e = 97, + f_socket_protocol_fc_e = 133, + f_socket_protocol_ggp_e = 3, + f_socket_protocol_gre_e = 47, + f_socket_protocol_hip_e = 139, + f_socket_protocol_hmp_e = 20, + f_socket_protocol_icmp_e = 1, + f_socket_protocol_idpr_cmtp_e = 38, + f_socket_protocol_idrp_e = 45, + f_socket_protocol_igmp_e = 2, + f_socket_protocol_igp_e = 9, + f_socket_protocol_ipcomp_e = 108, + f_socket_protocol_ipencap_e = 4, + f_socket_protocol_ipip_e = 94, + f_socket_protocol_ipv6_e = 41, + f_socket_protocol_ipv6_frag_e = 44, + f_socket_protocol_ipv6_icmp_e = 58, + f_socket_protocol_ipv6_nonxt_e = 59, + f_socket_protocol_ipv6_opts_e = 60, + f_socket_protocol_ipv6_route_e = 43, + f_socket_protocol_isis_e = 124, + f_socket_protocol_iso_tp4_e = 29, + f_socket_protocol_l2tp_e = 115, + f_socket_protocol_manet_e = 138, + f_socket_protocol_mobility_header_e = 135, + f_socket_protocol_mpls_in_ip_e = 137, + f_socket_protocol_ospf_e = 89, + f_socket_protocol_pim_e = 103, + f_socket_protocol_pup_e = 12, + f_socket_protocol_rdp_e = 27, + f_socket_protocol_rohc_e = 142, + f_socket_protocol_rspf_e = 73, + f_socket_protocol_rsvp_e = 46, + f_socket_protocol_sctp_e = 132, + f_socket_protocol_shim6_e = 140, + f_socket_protocol_skip_e = 57, + f_socket_protocol_st_e = 5, + f_socket_protocol_tcp_e = 6, + f_socket_protocol_udp_e = 17, + f_socket_protocol_udplite_e = 136, + f_socket_protocol_vmtp_e = 81, + f_socket_protocol_vrrp_e = 112, + f_socket_protocol_wesp_e = 141, + f_socket_protocol_xns_idp_e = 22, + f_socket_protocol_xtp_e = 36, }; #endif // _di_f_socket_protocol_e_ @@ -529,49 +529,49 @@ extern "C" { * * f_socket_protocol_family_*_e: * - unspecified: No protocol family specified. - * - local: Localhost, pipes, Unix sockets, or file sockets (PF_LOCAL, PF_UNIX, PF_FILE). - * - inet: IP protocol family. - * - ax25: Amateur Radio AX.25. - * - ipx: Novell Internet Protocol. + * - alg: Algorithm sockets. * - appletalk: Appletalk DDP. - * - netrom: Amateur radio NetROM. - * - bridge: Multiprotocol bridge. + * - ash: Ash. * - atmpvc: ATM PVCs. - * - x25: Reserved for X.25 project. - * - inet6: IP version 6. - * - rose: Amateur Radio X.25 PLP. + * - atmsvc: ATM SVCs. + * - ax25: Amateur Radio AX.25. + * - bluetooth: Bluetooth sockets. + * - bridge: Multiprotocol bridge. + * - caif: CAIF sockets. + * - can: Controller Area Network. * - decnet: Reserved for DECnet project. - * - netbeui: Reserved for 802.2LLC project. - * - security: Security callback pseudo AF. - * - key: PF_KEY key management API. - * - netlink: Netlink and BSD (PF_NETLINK and PF_ROUTE). - * - packet: Packet family. - * - ash: Ash. * - econet: Acorn Econet. - * - atmsvc: ATM SVCs. - * - rds: RDS sockets. - * - sna: Linux SNA Project. + * - ib: Native InfiniBand address. + * - ieee802154: IEEE 802.15.4 sockets. + * - inet: IP protocol family. + * - inet6: IP version 6. + * - ipx: Novell Internet Protocol. * - irda: IRDA sockets. - * - pppox: PPPoX sockets. - * - wanpipe: Wanpipe API sockets. + * - isdn: mISDN sockets. + * - iucb: IUCV sockets. + * - kcm: Kernel Connection Multiplexor. + * - key: PF_KEY key management API. * - llc: Linux LLC. - * - ib: Native InfiniBand address. + * - local: Localhost, pipes, Unix sockets, or file sockets (PF_LOCAL, PF_UNIX, PF_FILE). * - mpls: MPLS. - * - can: Controller Area Network. - * - tipc: TIPC sockets. - * - bluetooth: Bluetooth sockets. - * - iucb: IUCV sockets. - * - rxrpc: RxRPC sockets. - * - isdn: mISDN sockets. - * - phonet: Phonet sockets. - * - ieee802154: IEEE 802.15.4 sockets. - * - caif: CAIF sockets. - * - alg: Algorithm sockets. + * - netbeui: Reserved for 802.2LLC project. + * - netlink: Netlink and BSD (PF_NETLINK and PF_ROUTE). + * - netrom: Amateur radio NetROM. * - nfc: NFC sockets. - * - vsock: vSockets. - * - kcm: Kernel Connection Multiplexor. + * - packet: Packet family. + * - phonet: Phonet sockets. + * - pppox: PPPoX sockets. * - qipcrtr: Qualcomm IPC Router. + * - rds: RDS sockets. + * - rose: Amateur Radio X.25 PLP. + * - rxrpc: RxRPC sockets. + * - security: Security callback pseudo AF. * - smc: SMC sockets. + * - sna: Linux SNA Project. + * - tipc: TIPC sockets. + * - vsock: vSockets. + * - wanpipe: Wanpipe API sockets. + * - x25: Reserved for X.25 project. * - max: The maximum value for known protocol families (this is not a protocol family). */ #ifndef _di_f_socket_protocol_family_e_ @@ -734,15 +734,15 @@ extern "C" { * Commonly used socket related properties, loosely based off of f_file_t. * * id: File descriptor, with a value of -1 represents a closed file. - * domain: The socket domain (protocol family). - * protocol: The socket protocol. - * type: The socket type (address family). + * domain: The socket domain (protocol family, such as f_socket_protocol_family_local_e). + * protocol: The socket protocol(such as f_socket_protocol_tcp_e). + * type: The socket type (address family, such as f_socket_address_family_local_e). * * size_read: The default number of 1-byte characters to read at a time and is often used for the read buffer size. * size_write: The default number of 1-byte characters to read at a time and is often used for the write buffer size. * - * length: The length of the socket. * address: Tthe socket address. + * length: The length of the socket. * * name: The name of the socket, if a name is given (for UNIX sockets this represents the path) (Must be a NULL terminated string). * @@ -758,13 +758,13 @@ extern "C" { size_t size_read; size_t size_write; - socklen_t length; f_socket_address_t address; + socklen_t length; f_string_static_t name; } f_socket_t; - #define f_socket_t_initialize { -1, 0, 0, 0, F_socket_default_read_size_d, F_socket_default_write_size_d, 0, f_socket_address_t_initialize, f_string_empty_s } + #define f_socket_t_initialize { -1, 0, 0, 0, F_socket_default_read_size_d, F_socket_default_write_size_d, f_socket_address_t_initialize, 0, f_string_static_t_initialize } #define macro_f_socket_t_initialize_1(address, length) { \ -1, \ diff --git a/level_0/f_socket/data/build/settings b/level_0/f_socket/data/build/settings index 0474b34..d401687 100644 --- a/level_0/f_socket/data/build/settings +++ b/level_0/f_socket/data/build/settings @@ -61,7 +61,7 @@ search_static yes environment PATH LD_LIBRARY_PATH environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH -flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses +flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces flags-clang -Wno-logical-op-parentheses flags-test -O0 -fstack-protector -Wall flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ diff --git a/level_0/f_socket/data/build/settings-mocks b/level_0/f_socket/data/build/settings-mocks index 1ddf8a4..77b53fd 100644 --- a/level_0/f_socket/data/build/settings-mocks +++ b/level_0/f_socket/data/build/settings-mocks @@ -53,7 +53,7 @@ search_static yes environment PATH LD_LIBRARY_PATH environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH -flags -O0 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses +flags -O0 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces flags-clang -Wno-logical-op-parentheses flags-test -fstack-protector -Wall flags-coverage --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ diff --git a/level_0/f_socket/data/build/settings-tests b/level_0/f_socket/data/build/settings-tests index 4b2cdbe..7bb2229 100644 --- a/level_0/f_socket/data/build/settings-tests +++ b/level_0/f_socket/data/build/settings-tests @@ -52,7 +52,7 @@ defines -Ibuild/includes defines_static -Lbuild/libraries/static defines_shared -Lbuild/libraries/shared -flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses +flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces flags-clang -Wno-logical-op-parentheses flags-test -fstack-protector -Wall flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ diff --git a/level_0/f_socket/tests/unit/c/test-socket-bind_local.c b/level_0/f_socket/tests/unit/c/test-socket-bind_local.c index cf306a6..05c0193 100644 --- a/level_0/f_socket/tests/unit/c/test-socket-bind_local.c +++ b/level_0/f_socket/tests/unit/c/test-socket-bind_local.c @@ -39,32 +39,28 @@ void test__f_socket_bind_local__fails(void **state) { { f_socket_t socket = f_socket_t_initialize; - struct sockaddr_un address; - - memset(&address, 0, sizeof(struct sockaddr_un)); - - address.sun_family = f_socket_protocol_family_local_e; - - socket.address = (struct sockaddr *) &address; + socket.domain = f_socket_protocol_family_local_e; + socket.protocol = f_socket_protocol_tcp_e; + socket.type = f_socket_address_family_local_e; + socket.address.local.sun_family = f_socket_address_family_local_e; for (uint8_t i = 0; i < 12; ++i) { + will_return(__wrap_bind, true); + will_return(__wrap_bind, errnos[i]); + const f_status_t status = f_socket_bind_local(&socket); - assert_int_equal(status, F_status_set_error(F_local_not)); + assert_int_equal(status, F_status_set_error(statuss[i])); } // for } { f_socket_t socket = f_socket_t_initialize; - struct sockaddr_un address; - - memset(&address, 0, sizeof(struct sockaddr_un)); - - address.sun_family = f_socket_protocol_family_local_e; - - socket.address = (struct sockaddr *) &address; socket.domain = f_socket_protocol_family_local_e; + socket.protocol = f_socket_protocol_tcp_e; + socket.type = f_socket_address_family_local_e; + socket.address.local.sun_family = f_socket_address_family_local_e; for (uint8_t i = 0; i < 12; ++i) { @@ -91,14 +87,10 @@ void test__f_socket_bind_local__works(void **state) { { f_socket_t socket = f_socket_t_initialize; - struct sockaddr_un address; - - memset(&address, 0, sizeof(struct sockaddr_un)); - - address.sun_family = f_socket_protocol_family_local_e; - - socket.address = (struct sockaddr *) &address; socket.domain = f_socket_protocol_family_local_e; + socket.protocol = f_socket_protocol_tcp_e; + socket.type = f_socket_address_family_local_e; + socket.address.local.sun_family = f_socket_address_family_local_e; will_return(__wrap_bind, false); diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_append.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_append.c index edfd8c2..cd44a62 100644 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_append.c +++ b/level_0/f_socket/tests/unit/c/test-socket-sockets_append.c @@ -19,7 +19,7 @@ void test__f_socket_sockets_append__parameter_checking(void **state) { void test__f_socket_sockets_append__works(void **state) { f_string_static_t test = macro_f_string_static_t_initialize_1("test", 0, 4); - const f_socket_t source = macro_f_socket_t_initialize_3(1, 2, 3, 4, 0, 0, test); + const f_socket_t source = macro_f_socket_t_initialize_3(1, 2, 3, 4, f_socket_address_t_initialize, 0, test); f_sockets_t destination = f_sockets_t_initialize; { diff --git a/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.c b/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.c index ab6f65a..b18e430 100644 --- a/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.c +++ b/level_0/f_socket/tests/unit/c/test-socket-sockets_append_all.c @@ -53,8 +53,8 @@ void test__f_socket_sockets_append_all__works(void **state) { }; f_socket_t sources[] = { - macro_f_socket_t_initialize_3(1, 2, 3, 4, 0, 0, tests[0]), - macro_f_socket_t_initialize_3(5, 6, 7, 8, 0, 0, tests[1]), + macro_f_socket_t_initialize_3(1, 2, 3, 4, f_socket_address_t_initialize, 0, tests[0]), + macro_f_socket_t_initialize_3(5, 6, 7, 8, f_socket_address_t_initialize, 0, tests[1]), }; f_sockets_t source = f_sockets_t_initialize; diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_append.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_append.c index 48f7c56..5b8b623 100644 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_append.c +++ b/level_0/f_socket/tests/unit/c/test-socket-socketss_append.c @@ -55,11 +55,11 @@ void test__f_socket_socketss_append__works(void **state) { }; f_socket_t sources[] = { - macro_f_socket_t_initialize_3(1, 2, 3, 4, 0, 0, tests[0]), - macro_f_socket_t_initialize_3(5, 6, 7, 8, 0, 0, tests[1]), - macro_f_socket_t_initialize_3(9, 10, 11, 12, 0, 0, tests[2]), - macro_f_socket_t_initialize_3(13, 14, 15, 16, 0, 0, tests[3]), - macro_f_socket_t_initialize_3(17, 18, 19, 20, 0, 0, tests[4]), + macro_f_socket_t_initialize_3(1, 2, 3, 4, f_socket_address_t_initialize, 0, tests[0]), + macro_f_socket_t_initialize_3(5, 6, 7, 8, f_socket_address_t_initialize, 0, tests[1]), + macro_f_socket_t_initialize_3(9, 10, 11, 12, f_socket_address_t_initialize, 0, tests[2]), + macro_f_socket_t_initialize_3(13, 14, 15, 16, f_socket_address_t_initialize, 0, tests[3]), + macro_f_socket_t_initialize_3(17, 18, 19, 20, f_socket_address_t_initialize, 0, tests[4]), }; f_sockets_t source = f_sockets_t_initialize; diff --git a/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.c b/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.c index e7fd41a..16520af 100644 --- a/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.c +++ b/level_0/f_socket/tests/unit/c/test-socket-socketss_append_all.c @@ -53,8 +53,8 @@ void test__f_socket_socketss_append_all__works(void **state) { }; f_socket_t sources[] = { - macro_f_socket_t_initialize_3(1, 2, 3, 4, 0, 0, tests[0]), - macro_f_socket_t_initialize_3(5, 6, 7, 8, 0, 0, tests[1]), + macro_f_socket_t_initialize_3(1, 2, 3, 4, f_socket_address_t_initialize, 0, tests[0]), + macro_f_socket_t_initialize_3(5, 6, 7, 8, f_socket_address_t_initialize, 0, tests[1]), }; f_socketss_t source = f_socketss_t_initialize;