Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
dhcp ip: DSCP settings for transmitted DHCP packets
[vpp.git]
/
src
/
vnet
/
ip
/
ip4_packet.h
diff --git
a/src/vnet/ip/ip4_packet.h
b/src/vnet/ip/ip4_packet.h
index
8da788b
..
c1852fc
100644
(file)
--- a/
src/vnet/ip/ip4_packet.h
+++ b/
src/vnet/ip/ip4_packet.h
@@
-41,7
+41,7
@@
#define included_ip4_packet_h
#include <vnet/ip/ip_packet.h> /* for ip_csum_t */
#define included_ip4_packet_h
#include <vnet/ip/ip_packet.h> /* for ip_csum_t */
-#include <vnet/
ip/tcp_packet.h>
/* for tcp_header_t */
+#include <vnet/
tcp/tcp_packet.h>
/* for tcp_header_t */
#include <vppinfra/byte_order.h> /* for clib_net_to_host_u16 */
/* IP4 address which can be accessed either as 4 bytes
#include <vppinfra/byte_order.h> /* for clib_net_to_host_u16 */
/* IP4 address which can be accessed either as 4 bytes
@@
-52,6
+52,7
@@
typedef union
u32 data_u32;
/* Aliases. */
u8 as_u8[4];
u32 data_u32;
/* Aliases. */
u8 as_u8[4];
+ u16 as_u16[2];
u32 as_u32;
} ip4_address_t;
u32 as_u32;
} ip4_address_t;
@@
-63,10
+64,11
@@
typedef struct
} ip4_address_fib_t;
always_inline void
} ip4_address_fib_t;
always_inline void
-ip4_addr_fib_init (ip4_address_fib_t * addr_fib,
ip4_address_t * address,
- u32 fib_index)
+ip4_addr_fib_init (ip4_address_fib_t * addr_fib,
+
const ip4_address_t * address,
u32 fib_index)
{
{
- clib_memcpy (&addr_fib->ip4_addr, address, sizeof (addr_fib->ip4_addr));
+ clib_memcpy_fast (&addr_fib->ip4_addr, address,
+ sizeof (addr_fib->ip4_addr));
addr_fib->fib_index = fib_index;
}
addr_fib->fib_index = fib_index;
}
@@
-76,9
+78,14
@@
typedef struct
ip4_address_t src, dst;
} ip4_address_pair_t;
ip4_address_t src, dst;
} ip4_address_pair_t;
+typedef struct
+{
+ ip4_address_t addr, mask;
+} ip4_address_and_mask_t;
+
/* If address is a valid netmask, return length of mask. */
always_inline uword
/* If address is a valid netmask, return length of mask. */
always_inline uword
-ip4_address_netmask_length (ip4_address_t * a)
+ip4_address_netmask_length (
const
ip4_address_t * a)
{
uword result = 0;
uword i;
{
uword result = 0;
uword i;
@@
-131,7
+138,7
@@
typedef union
u8 ip_version_and_header_length;
/* Type of service. */
u8 ip_version_and_header_length;
/* Type of service. */
-
u8
tos;
+
ip_dscp_t
tos;
/* Total layer 3 packet length including this header. */
u16 length;
/* Total layer 3 packet length including this header. */
u16 length;
@@
-187,28
+194,30
@@
typedef union
#define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS \
((4 << 4) | (sizeof (ip4_header_t) / sizeof (u32)))
#define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS \
((4 << 4) | (sizeof (ip4_header_t) / sizeof (u32)))
+#define IP4_ROUTER_ALERT_OPTION 20
+
always_inline int
always_inline int
-ip4_get_fragment_offset (ip4_header_t * i)
+ip4_get_fragment_offset (
const
ip4_header_t * i)
{
return clib_net_to_host_u16 (i->flags_and_fragment_offset) & 0x1fff;
}
always_inline int
{
return clib_net_to_host_u16 (i->flags_and_fragment_offset) & 0x1fff;
}
always_inline int
-ip4_get_fragment_more (ip4_header_t * i)
+ip4_get_fragment_more (
const
ip4_header_t * i)
{
return clib_net_to_host_u16 (i->flags_and_fragment_offset) &
IP4_HEADER_FLAG_MORE_FRAGMENTS;
}
always_inline int
{
return clib_net_to_host_u16 (i->flags_and_fragment_offset) &
IP4_HEADER_FLAG_MORE_FRAGMENTS;
}
always_inline int
-ip4_is_fragment (ip4_header_t * i)
+ip4_is_fragment (
const
ip4_header_t * i)
{
return (i->flags_and_fragment_offset &
clib_net_to_host_u16 (0x1fff | IP4_HEADER_FLAG_MORE_FRAGMENTS));
}
always_inline int
{
return (i->flags_and_fragment_offset &
clib_net_to_host_u16 (0x1fff | IP4_HEADER_FLAG_MORE_FRAGMENTS));
}
always_inline int
-ip4_is_first_fragment (ip4_header_t * i)
+ip4_is_first_fragment (
const
ip4_header_t * i)
{
return (i->flags_and_fragment_offset &
clib_net_to_host_u16 (0x1fff | IP4_HEADER_FLAG_MORE_FRAGMENTS)) ==
{
return (i->flags_and_fragment_offset &
clib_net_to_host_u16 (0x1fff | IP4_HEADER_FLAG_MORE_FRAGMENTS)) ==
@@
-217,13
+226,13
@@
ip4_is_first_fragment (ip4_header_t * i)
/* Fragment offset in bytes. */
always_inline int
/* Fragment offset in bytes. */
always_inline int
-ip4_get_fragment_offset_bytes (ip4_header_t * i)
+ip4_get_fragment_offset_bytes (
const
ip4_header_t * i)
{
return 8 * ip4_get_fragment_offset (i);
}
always_inline int
{
return 8 * ip4_get_fragment_offset (i);
}
always_inline int
-ip4_header_bytes (ip4_header_t * i)
+ip4_header_bytes (
const
ip4_header_t * i)
{
return sizeof (u32) * (i->ip_version_and_header_length & 0xf);
}
{
return sizeof (u32) * (i->ip_version_and_header_length & 0xf);
}
@@
-306,7
+315,7
@@
do { \
} while (0)
always_inline uword
} while (0)
always_inline uword
-ip4_address_is_multicast (ip4_address_t * a)
+ip4_address_is_multicast (
const
ip4_address_t * a)
{
return (a->data[0] & 0xf0) == 0xe0;
}
{
return (a->data[0] & 0xf0) == 0xe0;
}
@@
-320,9
+329,10
@@
ip4_multicast_address_set_for_group (ip4_address_t * a,
}
always_inline void
}
always_inline void
-ip4_multicast_ethernet_address (u8 * ethernet_address, ip4_address_t * a)
+ip4_multicast_ethernet_address (u8 * ethernet_address,
+ const ip4_address_t * a)
{
{
- u8 *d = a->as_u8;
+
const
u8 *d = a->as_u8;
ethernet_address[0] = 0x01;
ethernet_address[1] = 0x00;
ethernet_address[0] = 0x01;
ethernet_address[1] = 0x00;
@@
-342,10
+352,10
@@
ip4_tcp_reply_x1 (ip4_header_t * ip0, tcp_header_t * tcp0)
ip0->src_address.data_u32 = dst0;
ip0->dst_address.data_u32 = src0;
ip0->src_address.data_u32 = dst0;
ip0->dst_address.data_u32 = src0;
- src0 = tcp0->
ports.
src;
- dst0 = tcp0->
ports.
dst;
- tcp0->
ports.
src = dst0;
- tcp0->
ports.
dst = src0;
+ src0 = tcp0->src;
+ dst0 = tcp0->dst;
+ tcp0->src = dst0;
+ tcp0->dst = src0;
}
always_inline void
}
always_inline void
@@
-363,14
+373,14
@@
ip4_tcp_reply_x2 (ip4_header_t * ip0, ip4_header_t * ip1,
ip0->dst_address.data_u32 = src0;
ip1->dst_address.data_u32 = src1;
ip0->dst_address.data_u32 = src0;
ip1->dst_address.data_u32 = src1;
- src0 = tcp0->
ports.
src;
- src1 = tcp1->
ports.
src;
- dst0 = tcp0->
ports.
dst;
- dst1 = tcp1->
ports.
dst;
- tcp0->
ports.
src = dst0;
- tcp1->
ports.
src = dst1;
- tcp0->
ports.
dst = src0;
- tcp1->
ports.
dst = src1;
+ src0 = tcp0->src;
+ src1 = tcp1->src;
+ dst0 = tcp0->dst;
+ dst1 = tcp1->dst;
+ tcp0->src = dst0;
+ tcp1->src = dst1;
+ tcp0->dst = src0;
+ tcp1->dst = src1;
}
#endif /* included_ip4_packet_h */
}
#endif /* included_ip4_packet_h */