From 499929d54cbf9ac8706f4740207ebedd26ce1e27 Mon Sep 17 00:00:00 2001 From: Andrej Kozemcak Date: Tue, 26 Apr 2016 08:18:33 +0200 Subject: LISP IPv6 control support, create IPv6 header Change-Id: I50d2946df8f5de0142b76f4023d8bd60ee6d2f0d Signed-off-by: Andrej Kozemcak --- vnet/vnet/lisp-cp/control.c | 1 - vnet/vnet/lisp-cp/packets.c | 35 +++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'vnet') diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c index f067cf6d..a1d21be7 100644 --- a/vnet/vnet/lisp-cp/control.c +++ b/vnet/vnet/lisp-cp/control.c @@ -1681,7 +1681,6 @@ lisp_cp_init (vlib_main_t *vm) lcm->vlib_main = 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 */ diff --git a/vnet/vnet/lisp-cp/packets.c b/vnet/vnet/lisp-cp/packets.c index 28471b9a..3f7cd5e5 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 * -- cgit 1.2.3-korg