How to : Compile intel UPNP stack under Mac OS X (and BSD ?) systems.

How to : Compile intel UPNP stack under Mac OS X (and BSD ?) systems.

The compilation of Intel UPNP stack under Macintosh is quite straitforward since Macintosh is a POSIX compatible system. However, MAC OS X has (as well as it's ancestors : BSD systems) small differences with the POSIX features found on Linux. Intel Stack was not originally tested under a Macintosh and the current version (Generated from "Intel Device Builder for UPnP Technologies" Build: 1.0.2547.30545 from the "Digital home device code wizard") has some bugs under MAC OS X.

Appart from needing some catsing on void pointers (The compiler will stop on these when recompiling, I let you find and correct them) ; some other points are quite tricky.

The first thing I had to do on the code was the following:

Ichanged the followingcodein the ILibGetLocalIPAddressList function found in ILibParsers.c from:

nResult = ioctl(LocalSock, OSIOCGIFCONF, &ifConf);

to :

#if defined(OSIOCGIFCONF)

nResult = ioctl(LocalSock, OSIOCGIFCONF, &ifConf);

#else

nResult = ioctl(LocalSock, SIOCGIFCONF, &ifConf);

#endif

The SIOCGIFCONF under MAC OS / BSD relates to a dynamic size structure while Intel UPNP Stack needs a const size structure. The way to have this "old behaviour" under MAC OS is to use the OSIOCGIFCONF flag.

The second thing to change is the way Intel Upnp stack configures the socket not to receive SIGPIPE signals whenever a client disconnects.

Under Linux, thesend() functionis given theMSG_NOSIGNAL flag in order to do that. Under BSD / MAC OS, the same goal is achieved in a different way : you have to call setsockopt() giving a SO_NOSIGPIPE flag as a parameter.

There are quite some location in intel code you have to change this, If you want to find the location, please search for all "sendto()" in the stack code and do the modifications as expected.

The last and most importantwhen recompiling the Intel UPNP stack on a Macintosh is:
MAC OS doesn't support unnamed semaphores. Even if the code compiles
correctly using sem_init and sem_destroy, these functions have no effect
under MAC OS X and should instead be replaced by named semaphores (i.e.
using sem_open and sem_close).
There are quite a lot of locations in the UPNP stack code that uses
semaphores, so I won't list them either.

I hope all this will help you having a performant UPNP stack under Macintosh OS X (and BSD ?).

I'm considering posting my code on a future time basis, but since I do not have a lot of time, don't rely on this fact.

Jocelyn Berrendonner.

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.