X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vnet%2Fvnet%2Flisp-cp%2Fpackets.c;h=f67164df84b07ec3da957871f3000b09414052e3;hb=a5abdeb296f3e395708e89d29093ab37fb6cae2f;hp=aa246a9dc3d3905c14df21388d961ac6054df7cc;hpb=f1213b82771ce929c076339c24a777cfd59690e6;p=vpp.git diff --git a/vnet/vnet/lisp-cp/packets.c b/vnet/vnet/lisp-cp/packets.c index aa246a9dc3d..f67164df84b 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 * @@ -193,7 +200,7 @@ pkt_push_ip (vlib_main_t * vm, vlib_buffer_t *b, ip_address_t *src, { if (ip_addr_version (src) != ip_addr_version(dst)) { - clib_warning("src %s and dst %s IP have different AFI! Discarding!", + clib_warning("src %U and dst %U IP have different AFI! Discarding!", format_ip_address, src, format_ip_address, dst); return 0; } @@ -225,7 +232,7 @@ pkt_push_udp_and_ip (vlib_main_t * vm, vlib_buffer_t *b, u16 sp, u16 dp, udpsum = udp_checksum (uh, clib_net_to_host_u16 (uh->length), ih, ip_addr_version(sip)); - if (udpsum == -1) + if (udpsum == (u16) ~0) { clib_warning("Failed UDP checksum! Discarding"); return 0;