aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrej Kozemcak <akozemca@cisco.com>2016-04-26 08:18:33 +0200
committerDave Barach <openvpp@barachs.net>2016-04-28 20:27:30 +0000
commit499929d54cbf9ac8706f4740207ebedd26ce1e27 (patch)
treed3c9273543d2e0e7be816169d4a2fa72c5968470
parent99cb335ac1209d5bb7ede754f59d7df898ae0e81 (diff)
LISP IPv6 control support, create IPv6 header
Change-Id: I50d2946df8f5de0142b76f4023d8bd60ee6d2f0d Signed-off-by: Andrej Kozemcak <akozemca@cisco.com>
-rw-r--r--vnet/vnet/lisp-cp/control.c1
-rw-r--r--vnet/vnet/lisp-cp/packets.c35
2 files changed, 21 insertions, 15 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c
index f067cf6d762..a1d21be76ce 100644
--- a/vnet/vnet/lisp-cp/control.c
+++ b/vnet/vnet/lisp-cp/control.c
@@ -1682,7 +1682,6 @@ lisp_cp_init (vlib_main_t *vm)
lcm->vnet_main = vnet_get_main();
gid_dictionary_init (&lcm->mapping_index_by_gid);
- gid_dictionary_init (&lcm->mapping_index_by_gid);
/* default vrf mapped to vni 0 */
hash_set(lcm->table_id_by_vni, 0, 0);
diff --git a/vnet/vnet/lisp-cp/packets.c b/vnet/vnet/lisp-cp/packets.c
index 28471b9a82d..3f7cd5e5b5c 100644
--- a/vnet/vnet/lisp-cp/packets.c
+++ b/vnet/vnet/lisp-cp/packets.c
@@ -171,20 +171,27 @@ void *
pkt_push_ipv6 (vlib_main_t * vm, vlib_buffer_t *b, ip6_address_t *src,
ip6_address_t *dst, int proto)
{
- return 0;
-// struct ip6_hdr *ip6h;
-// int len;
-//
-// len = lbuf_size(b);
-// ip6h = lbuf_push_uninit(b, sizeof(struct ip6_hdr));
-//
-// ip6h->ip6_hops = 255;
-// ip6h->ip6_vfc = (IP6VERSION << 4);
-// ip6h->ip6_nxt = proto;
-// ip6h->ip6_plen = clib_host_to_net_u16(len);
-// clib_memcpy(ip6h->ip6_src.s6_addr, src->s6_addr, sizeof(struct in6_addr));
-// clib_memcpy(ip6h->ip6_dst.s6_addr, dst->s6_addr, sizeof(struct in6_addr));
-// return(ip6h);
+ 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 *