]> Kevux Git Server - fll/commitdiff
Update: Follow up changes for adding sockaddr_storage use in the socket type.
authorKevin Day <kevin@kevux.org>
Sun, 14 Apr 2024 13:57:28 +0000 (08:57 -0500)
committerKevin Day <kevin@kevux.org>
Sun, 14 Apr 2024 13:57:28 +0000 (08:57 -0500)
The commit 6fa1ec1f961ba4bf134d6db4e6ee70f56756c5ab left out a few files.
I also forgot to add the "_e" so that I have "f_socket_address_form_storage_e".

Add use of this in the unit test.
Remove seemingly duplicate unit tests.
Maybe I was trying to do a case of "bind()" returning "false", but the code does not do that in the duplicate unit tests.
Remove the duplicate unit tests as I can always add the "false" case in the future if I so choose to.

level_0/f_socket/c/socket.c
level_0/f_socket/c/socket/address.h
level_0/f_socket/tests/unit/c/test-socket-bind.c

index 476bc8fcd4b02788b5ca13edf67bf38adf32c823..c9a70fec522f75f90c8ee4de6773a68cecf89d1e 100644 (file)
@@ -77,6 +77,10 @@ extern "C" {
         socket->address.local.sun_path[0] = 0;
       }
     }
+    else if (socket->form == f_socket_address_form_storage_e) {
+      address = (struct sockaddr *) &socket->address.storage;
+      socket->length = sizeof(struct sockaddr_storage);
+    }
 
     #ifdef _en_support_socket_address_arp_
       else if (socket->form == f_socket_address_form_arp_e) {
@@ -189,6 +193,10 @@ extern "C" {
       address = (struct sockaddr *) &socket->address.local;
       socket->length = sizeof(struct sockaddr_un);
     }
+    else if (socket->form == f_socket_address_form_storage_e) {
+      address = (struct sockaddr *) &socket->address.storage;
+      socket->length = sizeof(struct sockaddr_storage);
+    }
 
     #ifdef _en_support_socket_address_arp_
       else if (socket->form == f_socket_address_form_arp_e) {
index f8f57ea477d116d44f681eb1fa30a954edbfa37a..19e7e9c2636b11dd556f52e16752fd6ea69894db 100644 (file)
@@ -43,7 +43,7 @@ extern "C" {
     f_socket_address_form_inet4_e,
     f_socket_address_form_inet6_e,
     f_socket_address_form_local_e,
-    f_socket_address_form_storage,
+    f_socket_address_form_storage_e,
 
     #ifdef _en_support_socket_address_arp_
       f_socket_address_form_arp_e,
index 71de1fcb74bffc23526e967adfa0fb94852ff3cc..68fde1d720dc7a52a1fd321129e472c05ad88baf 100644 (file)
@@ -71,42 +71,6 @@ void test__f_socket_bind__fails(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;
-    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;
@@ -141,12 +105,13 @@ void test__f_socket_bind__fails(void **state) {
     } // for
   }
 
+  // Storage is just that, so use ipv6 with storage as a test.
   {
     f_socket_t socket = f_socket_t_initialize;
-    socket.domain = f_socket_protocol_family_local_e;
+    socket.domain = f_socket_protocol_family_inet6_e;
     socket.protocol = f_socket_protocol_tcp_e;
-    socket.type = f_socket_address_family_local_e;
-    socket.form = f_socket_address_form_local_e;
+    socket.type = f_socket_address_family_inet6_e;
+    socket.form = f_socket_address_form_storage_e;
 
     for (uint8_t i = 0; i < 12; ++i) {