aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/lisp-cp/packets.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-02-28 15:15:56 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2017-03-01 20:25:48 +0000
commit68b0fb0c620c7451ef1a6380c43c39de6614db51 (patch)
treef4188fa09723152f3ebfcebbbe4cacad903e0cf1 /src/vnet/lisp-cp/packets.c
parentf869028740aaebeb0375077d4d84fa07a17fff1a (diff)
VPP-598: tcp stack initial commit
Change-Id: I49e5ce0aae6e4ff634024387ceaf7dbc432a0351 Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/lisp-cp/packets.c')
-rw-r--r--src/vnet/lisp-cp/packets.c65
1 files changed, 5 insertions, 60 deletions
diff --git a/src/vnet/lisp-cp/packets.c b/src/vnet/lisp-cp/packets.c
index 3a4f421b02a..f24024f1500 100644
--- a/src/vnet/lisp-cp/packets.c
+++ b/src/vnet/lisp-cp/packets.c
@@ -15,7 +15,7 @@
#include <vnet/lisp-cp/packets.h>
#include <vnet/lisp-cp/lisp_cp_messages.h>
-#include <vnet/ip/udp_packet.h>
+#include <vnet/udp/udp_packet.h>
/* Returns IP ID for the packet */
/* static u16 ip_id = 0;
@@ -142,61 +142,6 @@ pkt_push_udp (vlib_main_t * vm, vlib_buffer_t * b, u16 sp, u16 dp)
}
void *
-pkt_push_ipv4 (vlib_main_t * vm, vlib_buffer_t * b, ip4_address_t * src,
- ip4_address_t * dst, int proto)
-{
- ip4_header_t *ih;
-
- /* make some room */
- ih = vlib_buffer_push_uninit (b, sizeof (ip4_header_t));
-
- ih->ip_version_and_header_length = 0x45;
- ih->tos = 0;
- ih->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b));
-
- /* iph->fragment_id = clib_host_to_net_u16(get_IP_ID ()); */
-
- /* TODO: decide if we allow fragments in case of control */
- ih->flags_and_fragment_offset = clib_host_to_net_u16 (IP_DF);
- ih->ttl = 255;
- ih->protocol = proto;
- ih->src_address.as_u32 = src->as_u32;
- ih->dst_address.as_u32 = dst->as_u32;
-
- ih->checksum = ip4_header_checksum (ih);
- return ih;
-}
-
-void *
-pkt_push_ipv6 (vlib_main_t * vm, vlib_buffer_t * b, ip6_address_t * src,
- ip6_address_t * dst, int proto)
-{
- ip6_header_t *ip6h;
- u16 payload_length;
-
- /* make some room */
- ip6h = vlib_buffer_push_uninit (b, sizeof (ip6_header_t));
-
- ip6h->ip_version_traffic_class_and_flow_label =
- clib_host_to_net_u32 (0x6 << 28);
-
- /* calculate ip6 payload length */
- payload_length = vlib_buffer_length_in_chain (vm, b);
- payload_length -= sizeof (*ip6h);
-
- ip6h->payload_length = clib_host_to_net_u16 (payload_length);
-
- ip6h->hop_limit = 0xff;
- ip6h->protocol = proto;
- clib_memcpy (ip6h->src_address.as_u8, src->as_u8,
- sizeof (ip6h->src_address));
- clib_memcpy (ip6h->dst_address.as_u8, dst->as_u8,
- sizeof (ip6h->src_address));
-
- return ip6h;
-}
-
-void *
pkt_push_ip (vlib_main_t * vm, vlib_buffer_t * b, ip_address_t * src,
ip_address_t * dst, u32 proto)
{
@@ -210,12 +155,12 @@ pkt_push_ip (vlib_main_t * vm, vlib_buffer_t * b, ip_address_t * src,
switch (ip_addr_version (src))
{
case IP4:
- return pkt_push_ipv4 (vm, b, &ip_addr_v4 (src), &ip_addr_v4 (dst),
- proto);
+ return vlib_buffer_push_ip4 (vm, b, &ip_addr_v4 (src),
+ &ip_addr_v4 (dst), proto);
break;
case IP6:
- return pkt_push_ipv6 (vm, b, &ip_addr_v6 (src), &ip_addr_v6 (dst),
- proto);
+ return vlib_buffer_push_ip6 (vm, b, &ip_addr_v6 (src),
+ &ip_addr_v6 (dst), proto);
break;
}