24 #define PACKET_HOST 0 /* To us */ 25 #define PACKET_BROADCAST 1 /* To all */ 26 #define PACKET_MULTICAST 2 /* To group */ 27 #define PACKET_OTHERHOST 3 /* To someone else */ 28 #define PACKET_OUTGOING 4 /* Outgoing of any type */
1433 static inline int 1434 linux_check_direction(const pcap_t *handle, const struct sockaddr_ll *sll) 1435 { 1436 struct pcap_linux *handlep = handle->priv; 1437 1438 if (sll->sll_pkttype == PACKET_OUTGOING) { 1439 /* 1440 * Outgoing packet. 1441 * If this is from the loopback device, reject it; 1442 * we'll see the packet as an incoming packet as well, 1443 * and we don't want to see it twice. 1444 */ 1445 if (sll->sll_ifindex == handlep->lo_ifindex) 1446 return0; 1447 1448 /* 1449 * If the user only wants incoming packets, reject it. 1450 */ 1451 if (handle->direction == PCAP_D_IN) 1452 return0; 1453 } else { 1454 /* 1455 * Incoming packet. 1456 * If the user only wants outgoing packets, reject it. 1457 */ 1458 if (handle->direction == PCAP_D_OUT) 1459 return0; 1460 } 1461 return1; 1462 }