Category Archives: C/C++

UPDATE 2009.08.20: I’ve almost completed the task of adding the ipfw support, but I’m not having enough free time lately, so I decided to share my patch and the TODO list. It has been published here.

I packaged two parts of the latest MiniUPnP version into distinct MacOSX frameworks, so developers can embed on their .app’s. The first, miniupnpc, is a client implementation of the Internet Gateway Device Protocol, and the second, libnatpmp, is a client implementation of the NAT Port Mapping Protocol (part of the Bonjour Protocol). I know the latest versions are NOT major releases, but it’s mainly to check people interest.

MiniUPnPc.framework is here.
NATPMP.framework is here.

These frameworks are universal, so they run on both PPC and x86.

Regarding to the server implementation (miniupnpd), it supports netfilter (iptables), packet filter (pf), ipfilter (ipf) and pfSense, but not ipfirewall (ipfw), so it needs considerable work to add this support preserving the API compatibilty. I would be doing that if my day had 72 hours… Anyway, I’ve already contacted the author about my interest.

#if defined(__APPLE__) || defined(MAC_OS_CLASSIC) \
	|| defined(MAC_OS_X) || defined(macintosh)
#	define OS_MAC
#elif defined(linux) || defined(__linux) || defined(__linux__)
#	define OS_LINUX
#elif defined(__FreeBSD__) || defined(__DragonFly__)
#	define OS_FREEBSD
#elif defined(__NetBSD__)
#	define OS_NETBSD
#elif defined(__OpenBSD__)
#	define OS_OPENBSD
#elif defined(__MINT__)
#	define OS_MINT
#elif defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
#	define OS_BSD_BASED
#elif defined(sun) || defined(__SVR4)
#	define OS_SOLARIS
#elif defined(hpux) || defined(__hpux) || defined(__hpux__)
#	define OS_HPUX
#elif defined(riscos) || defined(__riscos) || defined(__riscos__)
#	define OS_RISC_OS
#elif defined(__OS2__) || defined(__EMX__)
#	define OS_OS2
#elif defined(osf) || defined(__osf) \
	|| defined(__osf__) || defined(_OSF_SOURCE)
#	define SYSTEM_		OS_OSF
#elif defined(sgi) || defined(__sgi) \
	|| defined(__sgi__) || defined(_SGI_SOURCE)
#	define OS_IRIX
#elif defined(_AIX)
#	define OS_AIX
#elif defined(__BEOS__)
#	define OS_BEOS
#elif defined(__CYGWIN__)
#	define OS_CYGWIN
#elif defined(__VMS)
#	define OS_OPENVMS
#elif defined(__osf__)
#	define OS_OSF
#elif defined(__QNXNTO__)
#	define OS_QNXNTO
#elif defined(_arch_dreamcast)
#	define OS_DREAMCAST
#elif defined(WINDOWS) || defined(WIN32) || defined(_WIN32)
#	define OS_WINDOWS
#endif

#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_FREEBSD) \
	|| defined(OS_OPENBSD)
#	define OS_POSIX
#endif
#define DECLARE_SMART_ENUM(_TYPE) \
	inline _TYPE operator&(_TYPE v1, _TYPE v2) \
	{ return _TYPE(int(v1) & int(v2)); } \
	inline _TYPE operator|(_TYPE v1, _TYPE v2) \
	{ return _TYPE(int(v1) | int(v2)); } \
	inline _TYPE operator^(_TYPE v1, _TYPE v2) \
	{ return _TYPE(int(v1) ^ int(v2)); } \
	inline _TYPE operator~(_TYPE v1) \
	{ return _TYPE(~int(v1)); } \
	inline _TYPE& operator|=(_TYPE& v1, _TYPE v2) \
	{ return v1 = v1 | v2; } \
	inline _TYPE& operator&=(_TYPE& v1, _TYPE v2) \
	{ return v1 = v1 & v2; } \
	inline _TYPE& operator^=(_TYPE& v1, _TYPE v2) \
	{ return v1 = v1 ^ v2; } \
	inline _TYPE& operator++(_TYPE& v1) \
	{ return v1 = _TYPE(int(v1) + 1); } \
	inline _TYPE& operator++(_TYPE& v1, int) \
	{ return v1 = _TYPE(int(v1) + 1); } \
	inline _TYPE& operator--(_TYPE& v1) \
	{ return v1 = _TYPE(int(v1) - 1); } \
	inline _TYPE& operator--(_TYPE& v1, int) \
	{ return v1 = _TYPE(int(v1) - 1); }