2 ** Copyright (c) 2015, Asim Jamshed, Robin Sommer, Seth Hall
3 ** and the International Computer Science Institute. All rights reserved.
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions are met:
8 ** (1) Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
11 ** (2) Redistributions in binary form must reproduce the above copyright
12 ** notice, this list of conditions and the following disclaimer in the
13 ** documentation and/or other materials provided with the distribution.
16 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 ** POSSIBILITY OF SUCH DAMAGE.
31 /*---------------------------------------------------------------------*/
33 ** Packet header hashing function utility - This file contains functions
34 ** that parse the packet headers and computes hash functions based on
35 ** the header fields. Please see pkt_hash.c for more details...
37 /*---------------------------------------------------------------------*/
40 /*---------------------------------------------------------------------*/
42 #define likely(x) __builtin_expect(!!(x), 1)
43 #define unlikely(x) __builtin_expect(!!(x), 0)
46 #define unlikely(x) (x)
49 #define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | \
50 (((unsigned short)(n) & 0xFF00) >> 8))
51 #define NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | \
52 (((unsigned short)(n) & 0xFF00) >> 8))
54 #define HTONL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
55 ((((unsigned long)(n) & 0xFF00)) << 8) | \
56 ((((unsigned long)(n) & 0xFF0000)) >> 8) | \
57 ((((unsigned long)(n) & 0xFF000000)) >> 24))
59 #define NTOHL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
60 ((((unsigned long)(n) & 0xFF00)) << 8) | \
61 ((((unsigned long)(n) & 0xFF0000)) >> 8) | \
62 ((((unsigned long)(n) & 0xFF000000)) >> 24))
63 /*---------------------------------------------------------------------*/
64 typedef struct vlanhdr {
65 uint16_t pri_cfi_vlan;
68 /*---------------------------------------------------------------------*/
70 ** Analyzes the packet header of computes a corresponding
74 pkt_hdr_hash(const unsigned char *buffer,
77 /*---------------------------------------------------------------------*/
78 #endif /* LB_PKT_HASH_H */