Commit ba063881 authored by Christophe Massiot's avatar Christophe Massiot

Mac OS X port, patch courtesy of Benjamin Cohen

parent 3892cef2
......@@ -3,6 +3,7 @@
VERSION = 2.0
CFLAGS += -Wall -Wformat-security -O3 -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -D_ISOC99_SOURCE -D_BSD_SOURCE
CFLAGS += -g
# Comment out the following line for Mac OS X build
LDLIBS += -lrt
OBJ_MULTICAT = multicat.o util.o
......
......@@ -259,6 +259,7 @@ static int udp_InitRead( const char *psz_arg, size_t i_len,
static ssize_t raw_Write( const void *p_buf, size_t i_len )
{
#ifndef __APPLE__
ssize_t i_ret;
struct iovec iov[2];
......@@ -287,6 +288,9 @@ static ssize_t raw_Write( const void *p_buf, size_t i_len )
}
return i_ret;
#else
return -1;
#endif
}
/* Please note that the write functions also work for TCP */
......
......@@ -216,7 +216,7 @@ void real_Sleep( uint64_t i_delay )
*****************************************************************************/
static int GetInterfaceIndex( const char *psz_name )
{
#ifndef __FreeBSD__
#if !defined(__FreeBSD__) && !defined(__APPLE__)
int i_fd;
struct ifreq ifr;
......@@ -398,6 +398,7 @@ static void RawFillHeaders(struct udprawpkt *dgram,
uint16_t portsrc, uint16_t portdst,
uint8_t ttl, uint8_t tos, uint16_t len)
{
#ifndef __APPLE__
struct iphdr *iph = &(dgram->iph);
struct udphdr *udph = &(dgram->udph);
......@@ -439,6 +440,7 @@ static void RawFillHeaders(struct udprawpkt *dgram,
// Compute ip header checksum. Computed by kernel when frag_off = 0 ?
//iph->check = csum((unsigned short *)iph, sizeof(struct iphdr));
#endif
}
/*****************************************************************************
......@@ -654,6 +656,7 @@ int OpenSocket( const char *_psz_arg, int i_ttl, uint16_t i_bind_port,
if ( bind_addr.ss.ss_family != AF_UNSPEC )
{
#ifndef __APPLE__
if ( IN6_IS_ADDR_MULTICAST( &bind_addr.sin6.sin6_addr ) )
{
struct ipv6_mreq imr;
......@@ -683,6 +686,7 @@ int OpenSocket( const char *_psz_arg, int i_ttl, uint16_t i_bind_port,
}
}
else
#endif
goto normal_bind;
}
}
......
......@@ -24,7 +24,11 @@
#include <netinet/udp.h>
#include <netinet/ip.h>
#ifdef __APPLE__
#define POLLRDHUP 0
#else
#define HAVE_CLOCK_NANOSLEEP
#endif
#define DEFAULT_PORT 1234
#define DEFAULT_PAYLOAD_SIZE 1316
......@@ -40,9 +44,11 @@
* Raw udp packet structure with flexible-array payload
*****************************************************************************/
struct udprawpkt {
#ifndef __APPLE__
struct iphdr iph;
struct udphdr udph;
uint8_t payload[];
#endif
} __attribute__((packed));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment