These are some minor modifications to make openbsc run on OSX.
You have to have these MacPorts installed: pkgconfig automake autoconf libtool libdbi libdbi-drivers sqlite3
... and set: export LDFLAGS='-L/opt/local/lib' export CPPFLAGS='-I/opt/local/include'
Everything else should work as usual.
Tobias Engel (3): Remove interface argument when compiled on OSX Remove unused librt dependency Set byte order defines when compiled on OSX
openbsc/src/ipaccess/ipaccess-find.c | 4 ++++ openbsc/src/libmgcp/mgcp_network.c | 8 +++++++- openbsc/src/libtrau/rtp_proxy.c | 8 +++++++- openbsc/tests/mgcp/Makefile.am | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-)
Since it is not possible to bind a socket to a specific interface on OSX, remove the option to specify the interface when compiled on OSX. --- openbsc/src/ipaccess/ipaccess-find.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/openbsc/src/ipaccess/ipaccess-find.c b/openbsc/src/ipaccess/ipaccess-find.c index 3f9bf41..8c9cffb 100644 --- a/openbsc/src/ipaccess/ipaccess-find.c +++ b/openbsc/src/ipaccess/ipaccess-find.c @@ -40,12 +40,14 @@ static int udp_sock(const char *ifname) if (fd < 0) return fd;
+#ifndef __APPLE__ if (ifname) { rc = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, ifname, strlen(ifname)); if (rc < 0) goto err; } +#endif
sa.sin_family = AF_INET; sa.sin_port = htons(3006); @@ -172,12 +174,14 @@ int main(int argc, char **argv) printf("ipaccess-find (C) 2009 by Harald Welte\n"); printf("This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n");
+#ifndef __APPLE__ if (argc < 2) { fprintf(stdout, "you might need to specify the outgoing\n" " network interface, e.g. ``%s eth0''\n", argv[0]); } else { ifname = argv[1]; } +#endif
bfd.cb = bfd_cb; bfd.when = BSC_FD_READ | BSC_FD_WRITE;
I would make this #ifdef SO_BINDTODEVICE.
On Wed, Oct 24, 2012 at 12:14:38PM -0400, Jim Rees wrote:
I would make this #ifdef SO_BINDTODEVICE.
I agree, please re-submit based on that.
Tobias Engel wrote:
Since it is not possible to bind a socket to a specific interface on OSX, remove the option to specify the interface when compiled on OSX.
Maybe it would be even better to change the tool to bind() to a given local IP address, rather than an interface, to be more like every other software.
//Peter
Hi Peter,
On Wed, Oct 24, 2012 at 06:20:47PM +0200, Peter Stuge wrote:
Maybe it would be even better to change the tool to bind() to a given local IP address, rather than an interface, to be more like every other software.
I would argue that most people know with more certainty the interface name than the IP address assigned to that interface. Especially in DHCP cases you would always have to check first what's the IP address, then put that into the command.
Also think of scripting scenarios, where you definitely don't want to 'sed' the IP address out of ifconfig/ip output before calling ipaccess-config.
--- openbsc/tests/mgcp/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openbsc/tests/mgcp/Makefile.am b/openbsc/tests/mgcp/Makefile.am index ff67cf8..d99c978 100644 --- a/openbsc/tests/mgcp/Makefile.am +++ b/openbsc/tests/mgcp/Makefile.am @@ -11,4 +11,4 @@ mgcp_test_SOURCES = mgcp_test.c mgcp_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libmgcp/libmgcp.a \ $(top_builddir)/src/libcommon/libcommon.a \ - $(LIBOSMOCORE_LIBS) -lrt $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) + $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS)
On Wed, Oct 24, 2012 at 05:53:49PM +0200, Tobias Engel wrote:
$(LIBOSMOCORE_LIBS) -lrt $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS)
$(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS)
man clock_gettime. Which library provides this function on OSX?
On 25.10.12 16:56, Holger Hans Peter Freyther wrote:
On Wed, Oct 24, 2012 at 05:53:49PM +0200, Tobias Engel wrote:
$(LIBOSMOCORE_LIBS) -lrt $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS)
$(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS)
man clock_gettime.
I know - but either I am blind or that function is never used in the code. time.h isn't even included:
openbsc/openbsc/tests/mgcp $ grep clock * openbsc/openbsc/tests/mgcp $ grep time * openbsc/openbsc/tests/mgcp $
-Tobias
On Thu, Oct 25, 2012 at 05:17:00PM +0200, Tobias Engel wrote:
On 25.10.12 16:56, Holger Hans Peter Freyther wrote:
I know - but either I am blind or that function is never used in the code. time.h isn't even included:
openbsc/openbsc/tests/mgcp $ grep clock * openbsc/openbsc/tests/mgcp $ grep time * openbsc/openbsc/tests/mgcp $
well, two things.
1.) We build libmgcp.a and these archives do not have library deps. This means you would need to grep in src/libmgcp and src/libcommon as well.
2.) I am going to use clock_gettime real soon(tm). You can check the zecke/mgcp-statistics branch where I implement proper RTP packet loss and jitter calculation.
thanks holger
Byte order defines have a DARWIN prefix on OSX so the values openbsc expects are set from their Darwin counterparts when compiled on OSX. --- openbsc/src/libmgcp/mgcp_network.c | 8 +++++++- openbsc/src/libtrau/rtp_proxy.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index 848f8cd..8824dc8 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -42,7 +42,13 @@ #include <limits.h>
#ifndef __BYTE_ORDER -#error "__BYTE_ORDER should be defined by someone" +# ifdef __APPLE__ +# define __BYTE_ORDER __DARWIN_BYTE_ORDER +# define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN +# define __BIG_ENDIAN __DARWIN_BIG_ENDIAN +# else +# error "__BYTE_ORDER should be defined by someone" +# endif #endif
/* according to rtp_proxy.c RFC 3550 */ diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c index 3d34ac6..f7c5a4f 100644 --- a/openbsc/src/libtrau/rtp_proxy.c +++ b/openbsc/src/libtrau/rtp_proxy.c @@ -42,7 +42,13 @@ #include <limits.h>
#ifndef __BYTE_ORDER -#error "__BYTE_ORDER should be defined by someone" +# ifdef __APPLE__ +# define __BYTE_ORDER __DARWIN_BYTE_ORDER +# define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN +# define __BIG_ENDIAN __DARWIN_BIG_ENDIAN +# else +# error "__BYTE_ORDER should be defined by someone" +# endif #endif
static LLIST_HEAD(rtp_sockets);
On Wed, Oct 24, 2012 at 05:53:50PM +0200, Tobias Engel wrote:
Byte order defines have a DARWIN prefix on OSX so the values openbsc expects are set from their Darwin counterparts when compiled on OSX.
I've only applied this part out of the series, as the others are still under discussion.