Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-08-11 Thread lynxis lazus
lynxis lazus has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..

socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

When dealing with IPv4 and IPv6 address, the struct sockaddr
allows to hold IPv4 and IPv6.
However even when struct sockaddr is being used, a cast to the
IPv4 or IPv6 family must happen. To work around this additional code,
use a union for the most common types.

Change-Id: If80172373735193401af872b18e1ff00c93880e7
---
M include/osmocom/core/socket.h
1 file changed, 11 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h
index 129612c..9cb8d6b 100644
--- a/include/osmocom/core/socket.h
+++ b/include/osmocom/core/socket.h
@@ -2,6 +2,7 @@
  *  Osmocom socket convenience functions. */

 #pragma once
+#if (!EMBEDDED)

 /*! \defgroup socket Socket convenience functions
  *  @{
@@ -11,17 +12,24 @@
 #include 
 #include 

-#if (!EMBEDDED)
 #include 

 /*! maximum length of a socket name ("r=1.2.3.4:123<->l=5.6.7.8:987") */
 #define OSMO_SOCK_NAME_MAXLEN (2 + INET6_ADDRSTRLEN + 1 + 5 + 3 + 2 + 
INET6_ADDRSTRLEN + 1 + 5 + 1)
-#endif

 struct sockaddr_in;
 struct sockaddr;
 struct osmo_fd;

+struct osmo_sockaddr {
+   union {
+   struct sockaddr sa;
+   struct sockaddr_storage sas;
+   struct sockaddr_in sin;
+   struct sockaddr_in6 sin6;
+   } u;
+};
+
 /* flags for osmo_sock_init. */
 /*! connect the socket to a remote peer */
 #define OSMO_SOCK_F_CONNECT(1 << 0)
@@ -92,4 +100,5 @@

 int osmo_sock_local_ip(char *local_ip, const char *remote_ip);

+#endif /* (!EMBEDDED) */
 /*! @} */

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 10
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-CC: pespin 
Gerrit-MessageType: merged


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-08-10 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..


Patch Set 9: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 9
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Mon, 10 Aug 2020 20:12:36 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-08-09 Thread lynxis lazus
Hello laforge, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/19141

to look at the new patch set (#9).

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..

socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

When dealing with IPv4 and IPv6 address, the struct sockaddr
allows to hold IPv4 and IPv6.
However even when struct sockaddr is being used, a cast to the
IPv4 or IPv6 family must happen. To work around this additional code,
use a union for the most common types.

Change-Id: If80172373735193401af872b18e1ff00c93880e7
---
M include/osmocom/core/socket.h
1 file changed, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/41/19141/9
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 9
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-CC: pespin 
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-08-04 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..


Patch Set 8:

> While looking into socket.h, if EMBEDDED it doesn't include . 
> But should be socket.h used at all on EMBEDDED?

no, there are no sockets on arm-none-eabi bare-iron embedded targets.


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 8
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Tue, 04 Aug 2020 10:59:19 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-08-01 Thread lynxis lazus
lynxis lazus has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..


Patch Set 8: Code-Review-1

@laforge: I don't have any idea how I should handle the EMBEDDED. Any ideas? I 
don't know enough how libosmocore is used on EMBEDDED. While looking into 
socket.h, if EMBEDDED it doesn't include . But should be socket.h 
used at all on EMBEDDED?


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 8
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Sat, 01 Aug 2020 20:16:21 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-08-01 Thread lynxis lazus
lynxis lazus has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..


Patch Set 8:

(1 comment)

https://gerrit.osmocom.org/c/libosmocore/+/19141/1/include/osmocom/core/socket.h
File include/osmocom/core/socket.h:

https://gerrit.osmocom.org/c/libosmocore/+/19141/1/include/osmocom/core/socket.h@25
PS1, Line 25: struct osmo_sockaddr {
> yes, I think it's universally the case that you always have a "sin_addr" / 
> "sin6_addr" / ... […]
I don't think this is a problem.



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 8
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: lynxis lazus 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Sat, 01 Aug 2020 20:10:00 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin 
Comment-In-Reply-To: laforge 
Gerrit-MessageType: comment


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-07-09 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Thu, 09 Jul 2020 10:47:37 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-07-06 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/c/libosmocore/+/19141/1/include/osmocom/core/socket.h
File include/osmocom/core/socket.h:

https://gerrit.osmocom.org/c/libosmocore/+/19141/1/include/osmocom/core/socket.h@25
PS1, Line 25: struct osmo_sockaddr {
> How do you differentiate the address family in here? Do all contain a type 
> field in the same address […]
yes, I think it's universally the case that you always have a "sin_addr" / 
"sin6_addr" / ... field as first member in the 'struct sockaddr_foo'.  Ugly, 
but has been used in BSD sockets API for decades :/



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Mon, 06 Jul 2020 19:53:10 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin 
Gerrit-MessageType: comment


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-07-06 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )

Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/c/libosmocore/+/19141/1/include/osmocom/core/socket.h
File include/osmocom/core/socket.h:

https://gerrit.osmocom.org/c/libosmocore/+/19141/1/include/osmocom/core/socket.h@25
PS1, Line 25: struct osmo_sockaddr {
How do you differentiate the address family in here? Do all contain a type 
field in the same address and it doesn't get overwritten no matter which 
substruct you use?



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin 
Gerrit-Comment-Date: Mon, 06 Jul 2020 08:48:53 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

2020-07-05 Thread lynxis lazus
lynxis lazus has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/19141 )


Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
..

socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

When dealing with IPv4 and IPv6 address, the struct sockaddr
allows to hold IPv4 and IPv6.
However even when struct sockaddr is being used, a cast to the
IPv4 or IPv6 family must happen. To work around this additional code,
use a union for the most common types.

Change-Id: If80172373735193401af872b18e1ff00c93880e7
---
M include/osmocom/core/socket.h
1 file changed, 9 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/41/19141/1

diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h
index 129612c..bc60dfc 100644
--- a/include/osmocom/core/socket.h
+++ b/include/osmocom/core/socket.h
@@ -22,6 +22,15 @@
 struct sockaddr;
 struct osmo_fd;

+struct osmo_sockaddr {
+   union {
+   struct sockaddr sa;
+   struct sockaddr_storage sas;
+   struct sockaddr_in sin;
+   struct sockaddr_in6 sin6;
+   } u;
+};
+
 /* flags for osmo_sock_init. */
 /*! connect the socket to a remote peer */
 #define OSMO_SOCK_F_CONNECT(1 << 0)

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19141
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus 
Gerrit-MessageType: newchange