BridgeUnix.c: add TAP local bridge support for FreeBSD
@@ -1651,50 +1651,23 @@ CANCEL *EthGetCancel(ETH *e)
// Read a packet
UINT EthGetPacket(ETH *e, void **data)
{
- UINT ret = 0;
-
-#if defined(UNIX_LINUX)
- ret = EthGetPacketLinux(e, data);
-#elif defined(UNIX_SOLARIS)
- ret = EthGetPacketSolaris(e, data);
-#elif defined(BRIDGE_PCAP)
- ret = EthGetPacketPcap(e, data);
-#elif defined(BRIDGE_BPF)
- ret = EthGetPacketBpf(e, data);
-#endif
-
- return ret;
-}
-
-#ifdef UNIX_LINUX
-
-UINT EthGetPacketLinux(ETH *e, void **data)
-{
- int s, ret;
- UCHAR tmp[UNIX_ETH_TMP_BUFFER_SIZE];
- struct iovec msg_iov;
- struct msghdr msg_header;
- struct cmsghdr *cmsg;
- union
- {
- struct cmsghdr cmsg;
- char buf[CMSG_SPACE(sizeof(struct my_tpacket_auxdata))];
- } cmsg_buf;
// Validate arguments
if (e == NULL || data == NULL)
{
return INFINITE;
}
+#ifdef UNIX_LINUX
if (e->IsRawIpMode)
{
return EthGetPacketLinuxIpRaw(e, data);
}
+#endif
if (e->Tap != NULL)
{
#ifndef NO_VLAN
- // tap mode
+ // TAP mode
void *buf;
UINT size;
@@ -1705,11 +1678,37 @@ UINT EthGetPacketLinux(ETH *e, void **data)
*data = buf;
return size;
-#else // NO_VLAN
+#else
return INFINITE;
#endif
}
+#if defined(UNIX_LINUX)
+ return EthGetPacketLinux(e, data);
+#elif defined(UNIX_SOLARIS)
+ return EthGetPacketSolaris(e, data);
+#elif defined(BRIDGE_PCAP)
+ return EthGetPacketPcap(e, data);
+#elif defined(BRIDGE_BPF)
+ return EthGetPacketBpf(e, data);
+#endif
+}
+
+#ifdef UNIX_LINUX
+
+UINT EthGetPacketLinux(ETH *e, void **data)
+{
+ int s, ret;
+ UCHAR tmp[UNIX_ETH_TMP_BUFFER_SIZE];
+ struct iovec msg_iov;
+ struct msghdr msg_header;
+ struct cmsghdr *cmsg;
+ union
+ {
+ struct cmsghdr cmsg;
+ char buf[CMSG_SPACE(sizeof(struct my_tpacket_auxdata))];
+ } cmsg_buf;
+
s = e->Socket;
if (s == INVALID_SOCKET)
@@ -1839,11 +1838,6 @@ UINT EthGetPacketSolaris(ETH *e, void **data)
int s;
int flags = 0;
int ret;
- // Validate arguments
- if (e == NULL || data == NULL)
- {
- return INFINITE;
- }
s = e->Socket;
if (s == INVALID_SOCKET)
