Changes in uspace/lib/nic/src/nic_rx_control.c [cf9cb36:00d7e1b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_rx_control.c
rcf9cb36 r00d7e1b 40 40 #include <bool.h> 41 41 #include <errno.h> 42 #include <mem.h> 43 #include <nic/nic.h> 42 #include <net/device.h> 43 #include <net_checksum.h> 44 #include <packet_client.h> 44 45 #include "nic_rx_control.h" 45 46 … … 391 392 * 392 393 * @param rxc 393 * @param frameThe probed frame394 * @param packet The probed frame 394 395 * 395 396 * @return True if the frame passes, false if it does not 396 397 */ 397 int nic_rxc_check(const nic_rxc_t *rxc, const void *data, size_t size,398 int nic_rxc_check(const nic_rxc_t *rxc, const packet_t *packet, 398 399 nic_frame_type_t *frame_type) 399 400 { 400 401 assert(frame_type != NULL); 401 uint8_t *dest_addr = (uint8_t *) data;402 uint8_t *dest_addr = (uint8_t *) packet + packet->data_start; 402 403 uint8_t *src_addr = dest_addr + ETH_ADDR; 403 404 if (size < 2 * ETH_ADDR)405 return false;406 404 407 405 if (dest_addr[0] & 1) { … … 440 438 } 441 439 } 442 443 440 /* Blocked source addresses */ 444 441 if (rxc->block_sources) { … … 446 443 return false; 447 444 } 448 449 445 /* VLAN filtering */ 450 446 if (!rxc->vlan_exact && rxc->vlan_mask != NULL) { 451 447 vlan_header_t *vlan_header = (vlan_header_t *) 452 ((uint8_t *) data+ 2 * ETH_ADDR);448 ((uint8_t *) packet + packet->data_start + 2 * ETH_ADDR); 453 449 if (vlan_header->tpid_upper == VLAN_TPID_UPPER && 454 450 vlan_header->tpid_lower == VLAN_TPID_LOWER) { … … 486 482 rxc->vlan_exact = vlan_exact; 487 483 } 488 489 /** Polynomial used in multicast address hashing */490 #define CRC_MCAST_POLYNOMIAL 0x04c11db6491 492 /** Compute the standard hash from MAC493 *494 * Hashing MAC into 64 possible values and using the value as index to495 * 64bit number.496 *497 * The code is copied from qemu-0.13's implementation of ne2000 and rt8139498 * drivers, but according to documentation there it originates in FreeBSD.499 *500 * @param[in] addr The 6-byte MAC address to be hashed501 *502 * @return 64-bit number with only single bit set to 1503 *504 */505 static uint64_t multicast_hash(const uint8_t addr[6])506 {507 uint32_t crc;508 int carry, i, j;509 uint8_t b;510 511 crc = 0xffffffff;512 for (i = 0; i < 6; i++) {513 b = addr[i];514 for (j = 0; j < 8; j++) {515 carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);516 crc <<= 1;517 b >>= 1;518 if (carry)519 crc = ((crc ^ CRC_MCAST_POLYNOMIAL) | carry);520 }521 }522 523 uint64_t one64 = 1;524 return one64 << (crc >> 26);525 }526 527 484 528 485 /**
Note:
See TracChangeset
for help on using the changeset viewer.