]> Kevux Git Server - fll/commitdiff
Update: Re-design f_socket to better support handling of different struct sockaddr...
authorKevin Day <thekevinday@gmail.com>
Fri, 8 Dec 2023 04:46:53 +0000 (22:46 -0600)
committerKevin Day <thekevinday@gmail.com>
Fri, 8 Dec 2023 04:46:53 +0000 (22:46 -0600)
The networking types are already in use, such as address family (AF_*) and protocol family (PF_*).
The known and supported socket address structures (struct sockaddr) do not directly relate to either.
Create a new enumeration that directly maps to these socket address structures (struct sockaddr), called an address form.
A 16-bit integer is hopefully more than is ever needed for this.

Rewrite f_socket_bind() and f_socket_connect() to use the socket.form enumeration.
The custom *_inet4(), *_inet6(), and *_local() functions are removed.

Add a generic, or fallback aka failsafe, type for handling the most basic socket address tructure (struct sockaddr).

14 files changed:
level_0/f_socket/c/socket.c
level_0/f_socket/c/socket.h
level_0/f_socket/c/socket/address.h
level_0/f_socket/c/socket/socket.h
level_0/f_socket/data/build/settings-tests
level_0/f_socket/tests/unit/c/test-socket-bind.c
level_0/f_socket/tests/unit/c/test-socket-bind_inet4.c [deleted file]
level_0/f_socket/tests/unit/c/test-socket-bind_inet4.h [deleted file]
level_0/f_socket/tests/unit/c/test-socket-bind_inet6.c [deleted file]
level_0/f_socket/tests/unit/c/test-socket-bind_inet6.h [deleted file]
level_0/f_socket/tests/unit/c/test-socket-bind_local.c [deleted file]
level_0/f_socket/tests/unit/c/test-socket-bind_local.h [deleted file]
level_0/f_socket/tests/unit/c/test-socket.c
level_0/f_socket/tests/unit/c/test-socket.h

index e44ed7913b6cd0294ebb1ed3805ccddd2b2e92c9..0c44ec9e2f133c561a761f39a67a073850762fb1 100644 (file)
@@ -52,69 +52,102 @@ extern "C" {
       if (!socket) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
 
-    if (bind(socket->id, (struct sockaddr *) &socket->address, socket->length) == -1) {
-      if (errno == EACCES) return F_status_set_error(F_access_denied);
-      if (errno == EADDRINUSE) return F_status_set_error(F_busy_address);
-      if (errno == EADDRNOTAVAIL) return F_status_set_error(F_available_not_address);
-      if (errno == EFAULT) return F_status_set_error(F_buffer);
-      if (errno == EINVAL) return F_status_set_error(F_parameter);
-      if (errno == ELOOP) return F_status_set_error(F_loop);
-      if (errno == ENAMETOOLONG) return F_status_set_error(F_string_too_large);
-      if (errno == ENOENT) return F_status_set_error(F_file_found_not);
-      if (errno == ENOMEM) return F_status_set_error(F_memory_not);
-      if (errno == ENOTDIR) return F_status_set_error(F_directory_found_not);
-      if (errno == ENOTSOCK) return F_status_set_error(F_socket_not);
-
-      return F_status_set_error(F_failure);
+    struct sockaddr * address = 0;
+
+    if (socket->form == f_socket_address_form_inet4_e) {
+      address = (struct sockaddr *) &socket->address.inet4;
+      socket->address.inet4.sin_family = f_socket_address_family_inet4_e;
+      socket->length = sizeof(struct sockaddr);
+    }
+    else if (socket->form == f_socket_address_form_inet6_e) {
+      address = (struct sockaddr *) &socket->address.inet6;
+      socket->address.inet6.sin6_family = f_socket_address_family_inet6_e;
+      socket->length = sizeof(struct sockaddr);
+    }
+    else if (socket->form == f_socket_address_form_local_e) {
+      address = (struct sockaddr *) &socket->address.local;
+      socket->address.local.sun_family = f_socket_address_family_local_e;
+      socket->length = sizeof(struct sockaddr);
+
+      if (socket->name.used && socket->name.string && socket->name.used + 1 <= socket->name.size) {
+        memcpy((void *) socket->address.local.sun_path, (void *) socket->name.string, socket->name.used);
+        socket->address.local.sun_path[socket->name.used] = 0;
+      }
+      else {
+        socket->address.local.sun_path[0] = 0;
+      }
     }
 
-    return F_okay;
-  }
-#endif // _di_f_socket_bind_
+    #ifdef _en_support_socket_address_arp_
+      else if (socket->form == f_socket_address_form_arp_e) {
+        address = (struct sockaddr *) &socket->address.arp;
+        socket->length = sizeof(struct sockaddr);
+      }
+    #endif // _en_support_socket_address_arp_
 
-#ifndef _di_f_socket_bind_inet4_
-  f_status_t f_socket_bind_inet4(f_socket_t * const socket) {
-    #ifndef _di_level_0_parameter_checking_
-      if (!socket) return F_status_set_error(F_parameter);
-    #endif // _di_level_0_parameter_checking_
+    #ifdef _en_support_socket_address_at_
+      else if (socket->form == f_socket_address_form_at_e) {
+        address = (struct sockaddr *) &socket->address.at;
+        socket->length = sizeof(struct sockaddr);
+      }
+    #endif // _en_support_socket_address_at_
 
-    if (socket->domain != f_socket_protocol_family_inet4_e) return F_status_set_error(F_address_not);
+    #ifdef _en_support_socket_address_ax25_
+      else if (socket->form == f_socket_address_form_ax25_e) {
+        address = (struct sockaddr *) &socket->address.ax25;
+        socket->length = sizeof(struct sockaddr);
+      }
+    #endif // _en_support_socket_address_ax25_
 
-    socket->address.inet4.sin_family = f_socket_address_family_inet4_e;
-    socket->length = sizeof(struct sockaddr_in);
+    #ifdef _en_support_socket_address_dl_
+      else if (socket->form == f_socket_address_form_dl_e) {
+        address = (struct sockaddr *) &socket->address.dl;
+        socket->length = sizeof(struct sockaddr);
+      }
+    #endif // _en_support_socket_address_dl_
 
-    if (bind(socket->id, (struct sockaddr *) &socket->address.inet4, socket->length) == -1) {
-      if (errno == EACCES) return F_status_set_error(F_access_denied);
-      if (errno == EADDRINUSE) return F_status_set_error(F_busy_address);
-      if (errno == EADDRNOTAVAIL) return F_status_set_error(F_available_not_address);
-      if (errno == EFAULT) return F_status_set_error(F_buffer);
-      if (errno == EINVAL) return F_status_set_error(F_parameter);
-      if (errno == ELOOP) return F_status_set_error(F_loop);
-      if (errno == ENAMETOOLONG) return F_status_set_error(F_string_too_large);
-      if (errno == ENOENT) return F_status_set_error(F_file_found_not);
-      if (errno == ENOMEM) return F_status_set_error(F_memory_not);
-      if (errno == ENOTDIR) return F_status_set_error(F_directory_found_not);
-      if (errno == ENOTSOCK) return F_status_set_error(F_socket_not);
+    #ifdef _en_support_socket_address_eon_
+      else if (socket->form == f_socket_address_form_eon_e) {
+        address = (struct sockaddr *) &socket->address.eon;
+        socket->length = sizeof(struct sockaddr);
+      }
+    #endif // _en_support_socket_address_eon_
 
-      return F_status_set_error(F_failure);
-    }
+    #ifdef _en_support_socket_address_ipx_
+      else if (socket->form == f_socket_address_form_ipx_e) {
+        address = (struct sockaddr *) &socket->address.ipx;
+        socket->length = sizeof(struct sockaddr);
+      }
+    #endif // _en_support_socket_address_ipx_
 
-    return F_okay;
-  }
-#endif // _di_f_socket_bind_inet4_
+    #ifdef _en_support_socket_address_iso_
+      else if (socket->form == f_socket_address_form_iso_e) {
+        address = (struct sockaddr *) &socket->address.iso;
+        socket->length = sizeof(struct sockaddr);
+      }
+    #endif // _en_support_socket_address_iso_
 
-#ifndef _di_f_socket_bind_inet6_
-  f_status_t f_socket_bind_inet6(f_socket_t * const socket) {
-    #ifndef _di_level_0_parameter_checking_
-      if (!socket) return F_status_set_error(F_parameter);
-    #endif // _di_level_0_parameter_checking_
+    #ifdef _en_support_socket_address_ns_
+      else if (socket->form == f_socket_address_form_ns_e) {
+        address = (struct sockaddr *) &socket->address.ns;
+        socket->length = sizeof(struct sockaddr);
+      }
+    #endif // _en_support_socket_address_ns_
 
-    if (socket->domain != f_socket_protocol_family_inet6_e) return F_status_set_error(F_address_not);
+    #ifdef _en_support_socket_address_x25_
+      else if (socket->form == f_socket_address_form_x25_e) {
+        address = (struct sockaddr *) &socket->address.x25;
+        socket->length = sizeof(struct sockaddr_x25);
+      }
+    #endif // _en_support_socket_address_x25_
 
-    socket->address.inet6.sin6_family = f_socket_address_family_inet6_e;
-    socket->length = sizeof(struct sockaddr_in6);
+    // Generic (f_socket_address_form_generic_e) or failsafe.
+    else {
+      address = (struct sockaddr *) &socket->address.generic;
+      socket->length = sizeof(struct sockaddr);
+    }
 
-    if (bind(socket->id, (struct sockaddr *) &socket->address.inet6, socket->length) == -1) {
+    if (bind(socket->id, address, socket->length) == -1) {
       if (errno == EACCES) return F_status_set_error(F_access_denied);
       if (errno == EADDRINUSE) return F_status_set_error(F_busy_address);
       if (errno == EADDRNOTAVAIL) return F_status_set_error(F_available_not_address);
@@ -132,53 +165,86 @@ extern "C" {
 
     return F_okay;
   }
-#endif // _di_f_socket_bind_inet6_
+#endif // _di_f_socket_bind_
 
-#ifndef _di_f_socket_bind_local_
-  f_status_t f_socket_bind_local(f_socket_t * const socket) {
-    #ifndef _di_level_0_parameter_checking_
-      if (!socket) return F_status_set_error(F_parameter);
-    #endif // _di_level_0_parameter_checking_
+#ifndef _di_f_socket_connect_
+  f_status_t f_socket_connect(const f_socket_t socket) {
 
-    if (socket->domain != f_socket_protocol_family_local_e) return F_status_set_error(F_local_not);
+    if (socket.id == -1) return F_file_descriptor;
 
-    socket->address.local.sun_family = f_socket_address_family_local_e;
-    socket->length = sizeof(struct sockaddr_un);
+    struct sockaddr * address = 0;
 
-    if (socket->name.used && socket->name.string) {
-      memcpy((void *) socket->address.local.sun_path, (void *) socket->name.string, socket->name.used);
-      socket->address.local.sun_path[socket->name.used] = 0;
+    if (socket.form == f_socket_address_form_inet4_e) {
+      address = (struct sockaddr *) &socket.address.inet4;
     }
-    else {
-      socket->address.local.sun_path[0] = 0;
+    else if (socket.form == f_socket_address_form_inet6_e) {
+      address = (struct sockaddr *) &socket.address.inet6;
+    }
+    else if (socket.form == f_socket_address_form_local_e) {
+      address = (struct sockaddr *) &socket.address.local;
     }
 
-    if (bind(socket->id, (struct sockaddr *) &socket->address.local, socket->length) == -1) {
-      if (errno == EACCES) return F_status_set_error(F_access_denied);
-      if (errno == EADDRINUSE) return F_status_set_error(F_busy_address);
-      if (errno == EADDRNOTAVAIL) return F_status_set_error(F_available_not_address);
-      if (errno == EFAULT) return F_status_set_error(F_buffer);
-      if (errno == EINVAL) return F_status_set_error(F_parameter);
-      if (errno == ELOOP) return F_status_set_error(F_loop);
-      if (errno == ENAMETOOLONG) return F_status_set_error(F_string_too_large);
-      if (errno == ENOENT) return F_status_set_error(F_file_found_not);
-      if (errno == ENOMEM) return F_status_set_error(F_memory_not);
-      if (errno == ENOTDIR) return F_status_set_error(F_directory_found_not);
-      if (errno == ENOTSOCK) return F_status_set_error(F_socket_not);
+    #ifdef _en_support_socket_address_arp_
+      else if (socket.form == f_socket_address_form_arp_e) {
+        address = (struct sockaddr *) &socket.address.arp;
+      }
+    #endif // _en_support_socket_address_arp_
 
-      return F_status_set_error(F_failure);
-    }
+    #ifdef _en_support_socket_address_at_
+      else if (socket.form == f_socket_address_form_at_e) {
+        address = (struct sockaddr *) &socket.address.at;
+      }
+    #endif // _en_support_socket_address_at_
 
-    return F_okay;
-  }
-#endif // _di_f_socket_bind_local_
+    #ifdef _en_support_socket_address_ax25_
+      else if (socket.form == f_socket_address_form_ax25_e) {
+        address = (struct sockaddr *) &socket.address.ax25;
+      }
+    #endif // _en_support_socket_address_ax25_
 
-#ifndef _di_f_socket_connect_
-  f_status_t f_socket_connect(const f_socket_t socket) {
+    #ifdef _en_support_socket_address_dl_
+      else if (socket.form == f_socket_address_form_dl_e) {
+        address = (struct sockaddr *) &socket.address.dl;
+      }
+    #endif // _en_support_socket_address_dl_
 
-    if (socket.id == -1) return F_file_descriptor;
+    #ifdef _en_support_socket_address_eon_
+      else if (socket.form == f_socket_address_form_eon_e) {
+        address = (struct sockaddr *) &socket.address.eon;
+      }
+    #endif // _en_support_socket_address_eon_
+
+    #ifdef _en_support_socket_address_ipx_
+      else if (socket.form == f_socket_address_form_ipx_e) {
+        address = (struct sockaddr *) &socket.address.ipx;
+      }
+    #endif // _en_support_socket_address_ipx_
+
+    #ifdef _en_support_socket_address_iso_
+      else if (socket.form == f_socket_address_form_iso_e) {
+        address = (struct sockaddr *) &socket.address.iso;
+      }
+    #endif // _en_support_socket_address_iso_
+
+    #ifdef _en_support_socket_address_ns_
+      else if (socket.form == f_socket_address_form_ns_e) {
+        address = (struct sockaddr *) &socket.address.ns;
+      }
+    #endif // _en_support_socket_address_ns_
+
+    #ifdef _en_support_socket_address_x25_
+      else if (socket.form == f_socket_address_form_x25_e) {
+        address = (struct sockaddr *) &socket.address.x25;
+      }
+    #endif // _en_support_socket_address_x25_
+
+    else {
+
+      // Generic (f_socket_address_form_generic_e) or failsafe.
+      address = (struct sockaddr *) &socket.address.generic;
+    }
 
-    if (connect(socket.id, (struct sockaddr *) &socket.address, socket.length) == -1) {
+    if (connect(socket.id, address, socket.length) == -1) {
       if (errno == EACCES) return F_status_set_error(F_access_denied);
       if (errno == EADDRINUSE) return F_status_set_error(F_busy_address);
       if (errno == EADDRNOTAVAIL) return F_status_set_error(F_available_not_address);
index 36ec320bd9414baf1094c6f95acc8ec69d0a5b34..7691ddf75ef463cca5c227083abe836bf84d3951 100644 (file)
@@ -106,11 +106,37 @@ extern "C" {
  * @param socket
  *   The socket structure.
  *   The socket.address may be any valid structure, like "struct sockaddr", "struct sockaddr_un", or "struct sockaddr_in".
- *   The socket.address.*.*_family is not directly altered by this function.
+ *   The socket.address.*.*_family is conditionally altered by this function.
  *   The caller must appropriately initialize and configure the socket.address.
  *   The socket.length must represent the full size of the address structure and is not altered by this function.
  *   The socket.id must refer to a valid socket file descriptor.
  *
+ *   For IPv4:
+ *     The socket.address.inet4.sin_family is directly assigned to f_socket_address_family_inet4_e.
+ *     The socket.domain (potocol family) must be assigned to f_socket_protocol_family_inet4_e.
+ *     The socket.length is updated to represent the size of "struct sockaddr_in".
+ *     The socket.type is not modified.
+ *
+ *   For IPv6:
+ *     The socket.address.inet4.sin_family is directly assigned to f_socket_address_family_inet6_e.
+ *     The socket.domain (potocol family) must be assigned to f_socket_protocol_family_inet6_e.
+ *     The socket.length is updated to represent the size of "struct sockaddr_in6".
+ *     The socket.type is not modified.
+ *
+ *   For local (UNIX socket):
+ *     The socket.address.local.sun_family is directly assigned to f_socket_address_family_local_e.
+ *     The socket.address.local.sun_path is updated with the value from socket.name.string.
+ *     The socket.domain (potocol family) must be assigned to f_socket_protocol_family_local_e.
+ *     The socket.length is updated to represent the size of "struct sockaddr_un".
+ *     The socket.name must be assigned to a path.
+ *     The socket.type is not modified.
+ *
+ *   For generic or unknown (failsafe):
+ *     The socket.address.inet4.sin_family is directly assigned to f_socket_address_family_unspecified_e.
+ *     The socket.domain (potocol family) must be assigned to f_socket_protocol_family_unspecified_e.
+ *     The socket.length is updated to represent the size of "struct sockaddr".
+ *     The socket.type is not modified.
+ *
  * @return
  *   F_okay on success.
  *
@@ -135,114 +161,6 @@ extern "C" {
 #endif // _di_f_socket_bind_
 
 /**
- * Bind a socket to an IPv4 address.
- *
- * @param socket
- *   The socket to use.
- *
- *   The socket.address.inet4.sin_family is directly assigned to f_socket_address_family_inet4_e.
- *   The socket.domain (potocol family) must be assigned to f_socket_protocol_family_inet4_e.
- *   The socket.length is updated to represent the size of "struct sockaddr_in".
- *   The socket.type (address family) will be assigned to f_socket_address_family_inet4_e.
- *
- * @return
- *   F_okay on success.
- *
- *   F_address (with error bit) if address is already in use (therefore unavailable).
- *   F_address_not (with error bit) if socket.domain is not set to f_socket_protocol_family_inet4_e.
- *   F_available_not_address (with error bit) if address is unavailable (is non-existent).
- *   F_buffer (with error bit) if the buffer is invalid.
- *   F_busy_address (with error bit) if address is already in use (therefore unavailable).
- *   F_directory_found_not (with error bit) if directory was not found.
- *   F_file_found_not (with error bit) if file not found.
- *   F_memory_not (with error bit) if out of memory.
- *   F_name (with error bit) on path name error.
- *   F_parameter (with error bit) if a parameter is invalid.
- *   F_socket_not (with error bit) if the ID is not a socket descriptor.
- *   F_string_too_large (with error bit) if string is too large to store in the buffer.
- *
- *   F_failure (with error bit) for any other error.
- *
- * @see bind()
- */
-#ifndef _di_f_socket_bind_inet4_
-  extern f_status_t f_socket_bind_inet4(f_socket_t * const socket);
-#endif // _di_f_socket_bind_inet4_
-
-/**
- * Bind a socket to an IPv6 address.
- *
- * @param socket
- *   The socket to use.
- *
- *   The socket.address.inet6.sin_family is directly assigned to f_socket_address_family_inet6_e.
- *   The socket.domain (potocol family) must be assigned to f_socket_protocol_family_inet6_e.
- *   The socket.length is updated to represent the size of "struct sockaddr_in6".
- *   The socket.type (address family) will be assigned to f_socket_address_family_inet6_e.
- *
- * @return
- *   F_okay on success.
- *
- *   F_address (with error bit) if address is already in use (therefore unavailable).
- *   F_address_not (with error bit) if socket.domain is not set to f_socket_protocol_family_inet6_e.
- *   F_available_not_address (with error bit) if address is unavailable (is non-existent).
- *   F_buffer (with error bit) if the buffer is invalid.
- *   F_busy_address (with error bit) if address is already in use (therefore unavailable).
- *   F_directory_found_not (with error bit) if directory was not found.
- *   F_file_found_not (with error bit) if file not found.
- *   F_memory_not (with error bit) if out of memory.
- *   F_name (with error bit) on path name error.
- *   F_parameter (with error bit) if a parameter is invalid.
- *   F_socket_not (with error bit) if the ID is not a socket descriptor.
- *   F_string_too_large (with error bit) if string is too large to store in the buffer.
- *
- *   F_failure (with error bit) for any other error.
- *
- * @see bind()
- */
-#ifndef _di_f_socket_bind_inet6_
-  extern f_status_t f_socket_bind_inet6(f_socket_t * const socket);
-#endif // _di_f_socket_bind_inet6_
-
-/**
- * Bind a socket to a local (UNIX) socket file.
- *
- * @param socket
- *   The socket to use.
- *
- *   The socket.address.local.sun_family is directly assigned to f_socket_address_family_local_e.
- *   The socket.address.local.sun_path is updated with the value from socket.name.string.
- *   The socket.domain (potocol family) must be assigned to f_socket_protocol_family_local_e.
- *   The socket.length is updated to represent the size of "struct sockaddr_un".
- *   The socket.name must be assigned to a path.
- *   The socket.type (address family) will be assigned to f_socket_address_family_local_e.
- *
- * @return
- *   F_okay on success.
- *
- *   F_address (with error bit) if address is already in use (therefore unavailable).
- *   F_available_not_address (with error bit) if address is unavailable (is non-existent or not local).
- *   F_buffer (with error bit) if the buffer is invalid.
- *   F_busy_address (with error bit) if address is already in use (therefore unavailable).
- *   F_directory_found_not (with error bit) if directory was not found.
- *   F_file_found_not (with error bit) if file not found.
- *   F_local_not (with error bit) if socket.domain is not set to f_socket_protocol_family_local_e.
- *   F_memory_not (with error bit) if out of memory.
- *   F_name (with error bit) on path name error.
- *   F_parameter (with error bit) if a parameter is invalid.
- *   F_socket_not (with error bit) if the ID is not a socket descriptor.
- *   F_string_too_large (with error bit) if string is too large to store in the buffer.
- *
- *   F_failure (with error bit) for any other error.
- *
- * @see bind()
- * @see memcpy()
- */
-#ifndef _di_f_socket_bind_local_
-  extern f_status_t f_socket_bind_local(f_socket_t * const socket);
-#endif // _di_f_socket_bind_local_
-
-/**
  * Connect to a socket.
  *
  * This connects the socket against socket.id.
@@ -250,7 +168,8 @@ extern "C" {
  *
  * @param socket
  *   The socket structure.
- *   The socket.address may point to any valid structure, like "struct sockaddr", "struct sockaddr_un", or "struct sockaddr_in".
+ *   The socket.address must have the proper structure setup based on the socket.type value, like "f_socket_address_family_inet4_e".
+ *   Only domains defined with an associated structure in the f_socket_address_t are supported.
  *   Only socket.id is used.
  *
  * @return
index bc5a07194eed834ebbe9555f88728eeaee272f04..eb3941b28e027b5308213bd838fe01846829be5e 100644 (file)
@@ -17,6 +17,71 @@ extern "C" {
 #endif
 
 /**
+ * Socket address forms.
+ *
+ * These are specific to the f_socket_address_t below for designating which form of sockaddr is being used.
+ *
+ * f_socket_address_form_*_e:
+ *   - arp:     Arp.
+ *   - at:      At.
+ *   - ax25:    Ax25.
+ *   - dl:      Dl.
+ *   - eon:     Eon.
+ *   - inet4:   Ipv4 internet network socket.
+ *   - inet6:   Ipv6 internet network socket..
+ *   - ipx:     Ipx.
+ *   - iso:     Iso.
+ *   - local:   Local (aka: Unix) socket (socket file or localhost).
+ *   - ns:      Ns.
+ *   - generic: None specified, does not use extra fields and should be considered the fallback / failsafe (see AF_UNSPEC).
+ *   - x25:     X25.
+ */
+#ifndef _di_f_socket_address_form_e_
+  enum {
+    f_socket_address_form_generic_e = 0,
+    f_socket_address_form_inet4_e,
+    f_socket_address_form_inet6_e,
+    f_socket_address_form_local_e,
+
+    #ifdef _en_support_socket_address_arp_
+      f_socket_address_form_arp_e,
+    #endif // _en_support_socket_address_arp_
+
+    #ifdef _en_support_socket_address_at_
+      f_socket_address_form_at_e,
+    #endif // _en_support_socket_address_at_
+
+    #ifdef _en_support_socket_address_ax25_
+      f_socket_address_form_ax25_e,
+    #endif // _en_support_socket_address_ax25_
+
+    #ifdef _en_support_socket_address_dl_
+      f_socket_address_form_dl_e,
+    #endif // _en_support_socket_address_dl_
+
+    #ifdef _en_support_socket_address_eon_
+      f_socket_address_form_eon_e,
+    #endif // _en_support_socket_address_eon_
+
+    #ifdef _en_support_socket_address_ipx_
+      f_socket_address_form_ipx_e,
+    #endif // _en_support_socket_address_ipx_
+
+    #ifdef _en_support_socket_address_iso_
+      f_socket_address_form_iso_e,
+    #endif // _en_support_socket_address_iso_
+
+    #ifdef _en_support_socket_address_ns_
+      f_socket_address_form_ns_e,
+    #endif // _en_support_socket_address_ns_
+
+    #ifdef _en_support_socket_address_x25_
+      f_socket_address_form_x25_e,
+    #endif // _en_support_socket_address_x25_
+  }; // enum
+#endif // _di_f_socket_address_form_e_
+
+/**
  * Provide a union to simplify using struct sockaddr in arrays.
  *
  * Managing different structures is not as practical.
@@ -25,22 +90,26 @@ extern "C" {
  *
  * All of the properties may or may not be present, but inet4, inet6, and local are generally assumed to exist.
  *
+ * These are associated with the address family, such as f_socket_address_family_local_e.
+ *
  * Properties:
- *   - arp:   Arp.
- *   - at:    At.
- *   - ax25:  Ax25.
- *   - dl:    Dl.
- *   - eon:   Eon.
- *   - inet4: Ipv4 internet network socket.
- *   - inet6: Ipv6 internet network socket..
- *   - ipx:   Ipx.
- *   - iso:   Iso.
- *   - local: Local (aka: Unix) socket (socket file or localhost).
- *   - ns:    Ns.
- *   - x25:   X25.
+ *   - arp:     Arp.
+ *   - at:      At.
+ *   - ax25:    Ax25.
+ *   - dl:      Dl.
+ *   - eon:     Eon.
+ *   - inet4:   Ipv4 internet network socket.
+ *   - inet6:   Ipv6 internet network socket..
+ *   - ipx:     Ipx.
+ *   - iso:     Iso.
+ *   - local:   Local (aka: Unix) socket (socket file or localhost).
+ *   - ns:      Ns.
+ *   - generic: None specified, does not use extra fields and should be considered the fallback / failsafe (see AF_UNSPEC).
+ *   - x25:     X25.
  */
 #ifndef _di_f_socket_address_t_
   typedef union {
+    struct sockaddr generic;
     struct sockaddr_in inet4;
     struct sockaddr_in6 inet6;
     struct sockaddr_un local;
@@ -84,6 +153,7 @@ extern "C" {
 
   #define f_socket_address_t_initialize { 0 }
 
+  #define f_socket_address_initialize_generic(value_generic) { .generic = value_generic }
   #define f_socket_address_initialize_inet4(value_inet4) { .inet4 = value_inet4 }
   #define f_socket_address_initialize_inet6(value_inet6) { .inet6 = value_inet6 }
   #define f_socket_address_initialize_local(value_local) { .local = value_local }
index 692f90d28948a46f6cd6e868d8e12acae7cdb63b..3246ee90088cd44db1f10b7c6972d3a1fe51ccbc 100644 (file)
@@ -25,6 +25,7 @@ extern "C" {
  *   - 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).
+ *   - form:     The form of the socket address type, such as f_socket_address_form_inet4_e for sockaddr_in.
  *
  *   - 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.
@@ -43,6 +44,7 @@ extern "C" {
     int domain;
     int protocol;
     int type;
+    uint16_t form;
 
     size_t size_read;
     size_t size_write;
@@ -53,14 +55,15 @@ extern "C" {
     f_string_static_t name;
   } f_socket_t;
 
-  #define f_socket_t_initialize { -1, -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 f_socket_t_initialize { -1, -1, 0, 0, 0, f_socket_address_form_generic_e, 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) { \
+  #define macro_f_socket_t_initialize_1(form, address, length) { \
     -1, \
     -1, \
     0, \
     0, \
     0, \
+    form, \
     F_socket_default_read_size_d, \
     F_socket_default_write_size_d, \
     address, \
@@ -68,12 +71,13 @@ extern "C" {
     f_string_empty_s \
   }
 
-  #define macro_f_socket_t_initialize_2(address, length, name) { \
+  #define macro_f_socket_t_initialize_2(form, address, length, name) { \
     -1, \
     -1, \
     0, \
     0, \
     0, \
+    form, \
     F_socket_default_read_size_d, \
     F_socket_default_write_size_d, \
     address, \
@@ -81,12 +85,13 @@ extern "C" {
     name \
   }
 
-  #define macro_f_socket_t_initialize_3(id, domain, protocol, type, address, length, name) { \
+  #define macro_f_socket_t_initialize_3(id, domain, protocol, type, form, address, length, name) { \
     id, \
     -1, \
     domain, \
     protocol, \
     type, \
+    form, \
     F_socket_default_read_size_d, \
     F_socket_default_write_size_d, \
     address, \
@@ -94,12 +99,13 @@ extern "C" {
     name \
   }
 
-  #define macro_f_socket_t_initialize_4(id, domain, protocol, type, size_read, size_write, address, length, name) { \
+  #define macro_f_socket_t_initialize_4(id, domain, protocol, type, form, size_read, size_write, address, length, name) { \
     id, \
     -1, \
     domain, \
     protocol, \
     type, \
+    form, \
     size_read, \
     size_write, \
     address, \
@@ -107,12 +113,13 @@ extern "C" {
     name \
   }
 
-  #define macro_f_socket_t_initialize_5(id, id_data, domain, protocol, type, size_read, size_write, address, length, name) { \
+  #define macro_f_socket_t_initialize_5(id, id_data, domain, protocol, type, form, size_read, size_write, address, length, name) { \
     id, \
     id_data, \
     domain, \
     protocol, \
     type, \
+    form, \
     size_read, \
     size_write, \
     address, \
@@ -126,6 +133,7 @@ extern "C" {
     file.domain = 0; \
     file.protocol = 0; \
     file.type = 0; \
+    file.form = 0; \
     file.size_read = 0; \
     file.size_write = 0; \
     file.length = 0; \
@@ -137,6 +145,7 @@ extern "C" {
     file.domain = 0; \
     file.protocol = 0; \
     file.type = 0; \
+    file.form = f_socket_address_form_generic_e; \
     file.size_read = F_socket_default_read_size_d; \
     file.size_write = F_socket_default_write_size_d; \
     file.length = 0; \
index e1e8e410c94902d41864024196bee8dccabbbe62..ff781c604455e9a78f821af86859a844a8eb9566 100644 (file)
@@ -25,7 +25,7 @@ build_language c
 build_libraries -lc -lcmocka
 build_libraries-individual -lf_memory -lf_string -lf_type_array -lf_socket
 
-build_sources_program test-socket-accept.c test-socket-bind.c test-socket-bind_inet4.c test-socket-bind_inet6.c test-socket-bind_local.c test-socket-connect.c test-socket-create.c test-socket-create_pair.c test-socket-disconnect.c test-socket-listen.c test-socket-name_host.c test-socket-name_peer.c test-socket-option_get.c test-socket-option_set.c test-socket-read.c test-socket-read_message.c test-socket-read_stream.c test-socket-write.c test-socket-write_message.c test-socket-write_stream.c
+build_sources_program test-socket-accept.c test-socket-bind.c test-socket-connect.c test-socket-create.c test-socket-create_pair.c test-socket-disconnect.c test-socket-listen.c test-socket-name_host.c test-socket-name_peer.c test-socket-option_get.c test-socket-option_set.c test-socket-read.c test-socket-read_message.c test-socket-read_stream.c test-socket-write.c test-socket-write_message.c test-socket-write_stream.c
 build_sources_program test-socket-addressss_delete_callback.c test-socket-addressss_destroy_callback.c
 build_sources_program test-socket-ss_delete_callback.c test-socket-ss_destroy_callback.c
 
index 356ba6f78ec46e44086127a88b8fee51ef2a7ca9..71de1fcb74bffc23526e967adfa0fb94852ff3cc 100644 (file)
@@ -7,8 +7,6 @@ extern "C" {
 
 void test__f_socket_bind__fails(void **state) {
 
-  f_socket_t socket = f_socket_t_initialize;
-
   int errnos[] = {
     EACCES,
     EADDRINUSE,
@@ -39,15 +37,127 @@ void test__f_socket_bind__fails(void **state) {
     F_failure,
   };
 
-  for (uint8_t i = 0; i < 12; ++i) {
+  {
+    f_socket_t socket = f_socket_t_initialize;
 
-    will_return(__wrap_bind, true);
-    will_return(__wrap_bind, errnos[i]);
+    for (uint8_t i = 0; i < 12; ++i) {
 
-    const f_status_t status = f_socket_bind(&socket);
+      will_return(__wrap_bind, true);
+      will_return(__wrap_bind, errnos[i]);
+
+      const f_status_t status = f_socket_bind(&socket);
+
+      assert_int_equal(status, F_status_set_error(statuss[i]));
+    } // for
+  }
+
+  {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_inet4_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_inet4_e;
+    socket.form = f_socket_address_form_inet4_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(&socket);
+
+      assert_int_equal(status, F_status_set_error(statuss[i]));
+    } // for
+  }
+
+  {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_inet4_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_inet4_e;
+    socket.form = f_socket_address_form_inet4_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(&socket);
+
+      assert_int_equal(status, F_status_set_error(statuss[i]));
+    } // for
+  }
+
+  {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_inet6_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_inet6_e;
+    socket.form = f_socket_address_form_inet6_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(&socket);
+
+      assert_int_equal(status, F_status_set_error(statuss[i]));
+    } // for
+  }
+
+  {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_inet6_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_inet6_e;
+    socket.form = f_socket_address_form_inet6_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(&socket);
+
+      assert_int_equal(status, F_status_set_error(statuss[i]));
+    } // for
+  }
+
+  {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_local_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_local_e;
+    socket.form = f_socket_address_form_local_e;
 
-    assert_int_equal(status, F_status_set_error(statuss[i]));
-  } // for
+    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(&socket);
+
+      assert_int_equal(status, F_status_set_error(statuss[i]));
+    } // for
+  }
+
+  {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_local_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_local_e;
+    socket.form = f_socket_address_form_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(&socket);
+
+      assert_int_equal(status, F_status_set_error(statuss[i]));
+    } // for
+  }
 }
 
 void test__f_socket_bind__parameter_checking(void **state) {
@@ -61,9 +171,53 @@ void test__f_socket_bind__parameter_checking(void **state) {
 
 void test__f_socket_bind__works(void **state) {
 
-  f_socket_t socket = f_socket_t_initialize;
+  {
+    f_socket_t socket = f_socket_t_initialize;
+
+    {
+      will_return(__wrap_bind, false);
+
+      const f_status_t status = f_socket_bind(&socket);
+
+      assert_int_equal(status, F_okay);
+    }
+  }
 
   {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_inet4_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_inet4_e;
+    socket.form = f_socket_address_form_inet4_e;
+
+    will_return(__wrap_bind, false);
+
+    const f_status_t status = f_socket_bind(&socket);
+
+    assert_int_equal(status, F_okay);
+  }
+
+  {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_inet6_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_inet6_e;
+    socket.form = f_socket_address_form_inet6_e;
+
+    will_return(__wrap_bind, false);
+
+    const f_status_t status = f_socket_bind(&socket);
+
+    assert_int_equal(status, F_okay);
+  }
+
+  {
+    f_socket_t socket = f_socket_t_initialize;
+    socket.domain = f_socket_protocol_family_local_e;
+    socket.protocol = f_socket_protocol_tcp_e;
+    socket.type = f_socket_address_family_local_e;
+    socket.form = f_socket_address_form_local_e;
+
     will_return(__wrap_bind, false);
 
     const f_status_t status = f_socket_bind(&socket);
diff --git a/level_0/f_socket/tests/unit/c/test-socket-bind_inet4.c b/level_0/f_socket/tests/unit/c/test-socket-bind_inet4.c
deleted file mode 100644 (file)
index 5d552dd..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "test-socket.h"
-#include "test-socket-bind_inet4.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_socket_bind_inet4__fails(void **state) {
-
-  int errnos[] = {
-    EACCES,
-    EADDRINUSE,
-    EADDRNOTAVAIL,
-    EFAULT,
-    EINVAL,
-    ELOOP,
-    ENAMETOOLONG,
-    ENOENT,
-    ENOMEM,
-    ENOTDIR,
-    ENOTSOCK,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_access_denied,
-    F_busy_address,
-    F_available_not_address,
-    F_buffer,
-    F_parameter,
-    F_loop,
-    F_string_too_large,
-    F_file_found_not,
-    F_memory_not,
-    F_directory_found_not,
-    F_socket_not,
-    F_failure,
-  };
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_inet4_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = f_socket_address_family_inet4_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_inet4(&socket);
-
-      assert_int_equal(status, F_status_set_error(statuss[i]));
-    } // for
-  }
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_inet4_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = f_socket_address_family_inet4_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_inet4(&socket);
-
-      assert_int_equal(status, F_status_set_error(statuss[i]));
-    } // for
-  }
-}
-
-void test__f_socket_bind_inet4__parameter_checking(void **state) {
-
-  {
-    const f_status_t status = f_socket_bind_inet4(0);
-
-    assert_int_equal(status, F_status_set_error(F_parameter));
-  }
-}
-
-void test__f_socket_bind_inet4__works(void **state) {
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_inet4_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = f_socket_address_family_inet4_e;
-
-    will_return(__wrap_bind, false);
-
-    const f_status_t status = f_socket_bind_inet4(&socket);
-
-    assert_int_equal(status, F_okay);
-  }
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
diff --git a/level_0/f_socket/tests/unit/c/test-socket-bind_inet4.h b/level_0/f_socket/tests/unit/c/test-socket-bind_inet4.h
deleted file mode 100644 (file)
index 9c556f1..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * FLL - Level 0
- *
- * Project: Socket
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the socket project.
- */
-#ifndef _TEST__F_socket_bind_inet4_h
-#define _TEST__F_socket_bind_inet4_h
-
-/**
- * Test that function fails.
- *
- * @see f_socket_bind_inet4()
- */
-extern void test__f_socket_bind_inet4__fails(void **state);
-
-/**
- * Test that parameter checking works as expected.
- *
- * @see f_socket_bind_inet4()
- */
-extern void test__f_socket_bind_inet4__parameter_checking(void **state);
-
-/**
- * Test that function works.
- *
- * @see f_socket_bind_inet4()
- */
-extern void test__f_socket_bind_inet4__works(void **state);
-
-#endif // _TEST__F_socket_bind_inet4_h
diff --git a/level_0/f_socket/tests/unit/c/test-socket-bind_inet6.c b/level_0/f_socket/tests/unit/c/test-socket-bind_inet6.c
deleted file mode 100644 (file)
index 9329a13..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "test-socket.h"
-#include "test-socket-bind_inet6.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_socket_bind_inet6__fails(void **state) {
-
-  int errnos[] = {
-    EACCES,
-    EADDRINUSE,
-    EADDRNOTAVAIL,
-    EFAULT,
-    EINVAL,
-    ELOOP,
-    ENAMETOOLONG,
-    ENOENT,
-    ENOMEM,
-    ENOTDIR,
-    ENOTSOCK,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_access_denied,
-    F_busy_address,
-    F_available_not_address,
-    F_buffer,
-    F_parameter,
-    F_loop,
-    F_string_too_large,
-    F_file_found_not,
-    F_memory_not,
-    F_directory_found_not,
-    F_socket_not,
-    F_failure,
-  };
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_inet6_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = f_socket_address_family_inet6_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_inet6(&socket);
-
-      assert_int_equal(status, F_status_set_error(statuss[i]));
-    } // for
-  }
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_inet6_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = f_socket_address_family_inet6_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_inet6(&socket);
-
-      assert_int_equal(status, F_status_set_error(statuss[i]));
-    } // for
-  }
-}
-
-void test__f_socket_bind_inet6__parameter_checking(void **state) {
-
-  {
-    const f_status_t status = f_socket_bind_inet6(0);
-
-    assert_int_equal(status, F_status_set_error(F_parameter));
-  }
-}
-
-void test__f_socket_bind_inet6__works(void **state) {
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_inet6_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = f_socket_address_family_inet6_e;
-
-    will_return(__wrap_bind, false);
-
-    const f_status_t status = f_socket_bind_inet6(&socket);
-
-    assert_int_equal(status, F_okay);
-  }
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
diff --git a/level_0/f_socket/tests/unit/c/test-socket-bind_inet6.h b/level_0/f_socket/tests/unit/c/test-socket-bind_inet6.h
deleted file mode 100644 (file)
index 95d7af3..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * FLL - Level 0
- *
- * Project: Socket
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the socket project.
- */
-#ifndef _TEST__F_socket_bind_inet6_h
-#define _TEST__F_socket_bind_inet6_h
-
-/**
- * Test that function fails.
- *
- * @see f_socket_bind_inet6()
- */
-extern void test__f_socket_bind_inet6__fails(void **state);
-
-/**
- * Test that parameter checking works as expected.
- *
- * @see f_socket_bind_inet6()
- */
-extern void test__f_socket_bind_inet6__parameter_checking(void **state);
-
-/**
- * Test that function works.
- *
- * @see f_socket_bind_inet6()
- */
-extern void test__f_socket_bind_inet6__works(void **state);
-
-#endif // _TEST__F_socket_bind_inet6_h
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
deleted file mode 100644 (file)
index 9df2ed2..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "test-socket.h"
-#include "test-socket-bind_local.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void test__f_socket_bind_local__fails(void **state) {
-
-  int errnos[] = {
-    EACCES,
-    EADDRINUSE,
-    EADDRNOTAVAIL,
-    EFAULT,
-    EINVAL,
-    ELOOP,
-    ENAMETOOLONG,
-    ENOENT,
-    ENOMEM,
-    ENOTDIR,
-    ENOTSOCK,
-    mock_errno_generic,
-  };
-
-  f_status_t statuss[] = {
-    F_access_denied,
-    F_busy_address,
-    F_available_not_address,
-    F_buffer,
-    F_parameter,
-    F_loop,
-    F_string_too_large,
-    F_file_found_not,
-    F_memory_not,
-    F_directory_found_not,
-    F_socket_not,
-    F_failure,
-  };
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_local_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = 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(statuss[i]));
-    } // for
-  }
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_local_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = 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(statuss[i]));
-    } // for
-  }
-}
-
-void test__f_socket_bind_local__parameter_checking(void **state) {
-
-  {
-    const f_status_t status = f_socket_bind_local(0);
-
-    assert_int_equal(status, F_status_set_error(F_parameter));
-  }
-}
-
-void test__f_socket_bind_local__works(void **state) {
-
-  {
-    f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_local_e;
-    socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = f_socket_address_family_local_e;
-
-    will_return(__wrap_bind, false);
-
-    const f_status_t status = f_socket_bind_local(&socket);
-
-    assert_int_equal(status, F_okay);
-  }
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
diff --git a/level_0/f_socket/tests/unit/c/test-socket-bind_local.h b/level_0/f_socket/tests/unit/c/test-socket-bind_local.h
deleted file mode 100644 (file)
index e19e2a6..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * FLL - Level 0
- *
- * Project: Socket
- * API Version: 0.7
- * Licenses: lgpl-2.1-or-later
- *
- * Test the socket project.
- */
-#ifndef _TEST__F_socket_bind_local_h
-#define _TEST__F_socket_bind_local_h
-
-/**
- * Test that function fails.
- *
- * @see f_socket_bind_local()
- */
-extern void test__f_socket_bind_local__fails(void **state);
-
-/**
- * Test that parameter checking works as expected.
- *
- * @see f_socket_bind_local()
- */
-extern void test__f_socket_bind_local__parameter_checking(void **state);
-
-/**
- * Test that function works.
- *
- * @see f_socket_bind_local()
- */
-extern void test__f_socket_bind_local__works(void **state);
-
-#endif // _TEST__F_socket_bind_local_h
index f9740fdfac8a7fe6526ac50c75da934b71bcbdf7..e521eac370377c375e796728a580c832246613ff 100644 (file)
@@ -25,15 +25,6 @@ int main(void) {
     cmocka_unit_test(test__f_socket_bind__fails),
     cmocka_unit_test(test__f_socket_bind__works),
 
-    cmocka_unit_test(test__f_socket_bind_inet4__fails),
-    cmocka_unit_test(test__f_socket_bind_inet4__works),
-
-    cmocka_unit_test(test__f_socket_bind_inet6__fails),
-    cmocka_unit_test(test__f_socket_bind_inet6__works),
-
-    cmocka_unit_test(test__f_socket_bind_local__fails),
-    cmocka_unit_test(test__f_socket_bind_local__works),
-
     cmocka_unit_test(test__f_socket_connect__fails),
     cmocka_unit_test(test__f_socket_connect__returns_file_descriptor),
     cmocka_unit_test(test__f_socket_connect__works),
@@ -104,9 +95,6 @@ int main(void) {
     #ifndef _di_level_0_parameter_checking_
       cmocka_unit_test(test__f_socket_accept__parameter_checking),
       cmocka_unit_test(test__f_socket_bind__parameter_checking),
-      cmocka_unit_test(test__f_socket_bind_inet4__parameter_checking),
-      cmocka_unit_test(test__f_socket_bind_inet6__parameter_checking),
-      cmocka_unit_test(test__f_socket_bind_local__parameter_checking),
       cmocka_unit_test(test__f_socket_create__parameter_checking),
       cmocka_unit_test(test__f_socket_create_pair__parameter_checking),
       cmocka_unit_test(test__f_socket_disconnect__parameter_checking),
index db423272254a2a560efb02ca82765ab20775910a..fe9b209a1e9a89c6d1469d895d4eaccdb2c83e9a 100644 (file)
@@ -30,9 +30,6 @@
 #include "test-socket-addressss_delete_callback.h"
 #include "test-socket-addressss_destroy_callback.h"
 #include "test-socket-bind.h"
-#include "test-socket-bind_inet4.h"
-#include "test-socket-bind_inet6.h"
-#include "test-socket-bind_local.h"
 #include "test-socket-connect.h"
 #include "test-socket-create.h"
 #include "test-socket-create_pair.h"