1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 1982, 1986, 1990, 1993 3 * The Regents of the University of California. 4 * Copyright(c) 2010-2014 Intel Corporation. 5 * Copyright(c) 2014 6WIND S.A. 6 * All rights reserved. 7 */ 8 9 #ifndef _RTE_IP_H_ 10 #define _RTE_IP_H_ 11 12 /** 13 * @file 14 * 15 * IP-related defines 16 */ 17 18 #include <stdint.h> 19 20 #ifdef RTE_EXEC_ENV_WINDOWS 21 #include <ws2tcpip.h> 22 #else 23 #include <sys/socket.h> 24 #include <sys/types.h> 25 #include <netinet/in.h> 26 #include <arpa/inet.h> 27 #include <netinet/ip.h> 28 #include <netinet/ip6.h> 29 #endif 30 31 #include <rte_byteorder.h> 32 #include <rte_mbuf.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /** 39 * IPv4 Header 40 */ 41 struct rte_ipv4_hdr { 42 uint8_t version_ihl; /**< version and header length */ 43 uint8_t type_of_service; /**< type of service */ 44 rte_be16_t total_length; /**< length of packet */ 45 rte_be16_t packet_id; /**< packet ID */ 46 rte_be16_t fragment_offset; /**< fragmentation offset */ 47 uint8_t time_to_live; /**< time to live */ 48 uint8_t next_proto_id; /**< protocol ID */ 49 rte_be16_t hdr_checksum; /**< header checksum */ 50 rte_be32_t src_addr; /**< source address */ 51 rte_be32_t dst_addr; /**< destination address */ 52 } __rte_packed; 53 54 /** Create IPv4 address */ 55 #define RTE_IPV4(a, b, c, d) ((uint32_t)(((a) & 0xff) << 24) | \ 56 (((b) & 0xff) << 16) | \ 57 (((c) & 0xff) << 8) | \ 58 ((d) & 0xff)) 59 60 /** Maximal IPv4 packet length (including a header) */ 61 #define RTE_IPV4_MAX_PKT_LEN 65535 62 63 /** Internet header length mask for version_ihl field */ 64 #define RTE_IPV4_HDR_IHL_MASK (0x0f) 65 /** 66 * Internet header length field multiplier (IHL field specifies overall header 67 * length in number of 4-byte words) 68 */ 69 #define RTE_IPV4_IHL_MULTIPLIER (4) 70 71 /* Type of Service fields */ 72 #define RTE_IPV4_HDR_DSCP_MASK (0xfc) 73 #define RTE_IPV4_HDR_ECN_MASK (0x03) 74 #define RTE_IPV4_HDR_ECN_CE RTE_IPV4_HDR_ECN_MASK 75 76 /* Fragment Offset * Flags. */ 77 #define RTE_IPV4_HDR_DF_SHIFT 14 78 #define RTE_IPV4_HDR_MF_SHIFT 13 79 #define RTE_IPV4_HDR_FO_SHIFT 3 80 81 #define RTE_IPV4_HDR_DF_FLAG (1 << RTE_IPV4_HDR_DF_SHIFT) 82 #define RTE_IPV4_HDR_MF_FLAG (1 << RTE_IPV4_HDR_MF_SHIFT) 83 84 #define RTE_IPV4_HDR_OFFSET_MASK ((1 << RTE_IPV4_HDR_MF_SHIFT) - 1) 85 86 #define RTE_IPV4_HDR_OFFSET_UNITS 8 87 88 /* 89 * IPv4 address types 90 */ 91 #define RTE_IPV4_ANY ((uint32_t)0x00000000) /**< 0.0.0.0 */ 92 #define RTE_IPV4_LOOPBACK ((uint32_t)0x7f000001) /**< 127.0.0.1 */ 93 #define RTE_IPV4_BROADCAST ((uint32_t)0xe0000000) /**< 224.0.0.0 */ 94 #define RTE_IPV4_ALLHOSTS_GROUP ((uint32_t)0xe0000001) /**< 224.0.0.1 */ 95 #define RTE_IPV4_ALLRTRS_GROUP ((uint32_t)0xe0000002) /**< 224.0.0.2 */ 96 #define RTE_IPV4_MAX_LOCAL_GROUP ((uint32_t)0xe00000ff) /**< 224.0.0.255 */ 97 98 /* 99 * IPv4 Multicast-related macros 100 */ 101 #define RTE_IPV4_MIN_MCAST \ 102 RTE_IPV4(224, 0, 0, 0) /**< Minimal IPv4-multicast address */ 103 #define RTE_IPV4_MAX_MCAST \ 104 RTE_IPV4(239, 255, 255, 255) /**< Maximum IPv4 multicast address */ 105 106 #define RTE_IS_IPV4_MCAST(x) \ 107 ((x) >= RTE_IPV4_MIN_MCAST && (x) <= RTE_IPV4_MAX_MCAST) 108 /**< check if IPv4 address is multicast */ 109 110 /* IPv4 default fields values */ 111 #define RTE_IPV4_MIN_IHL (0x5) 112 #define RTE_IPV4_VHL_DEF ((IPVERSION << 4) | RTE_IPV4_MIN_IHL) 113 114 /** 115 * Get the length of an IPv4 header. 116 * 117 * @param ipv4_hdr 118 * Pointer to the IPv4 header. 119 * @return 120 * The length of the IPv4 header (with options if present) in bytes. 121 */ 122 static inline uint8_t 123 rte_ipv4_hdr_len(const struct rte_ipv4_hdr *ipv4_hdr) 124 { 125 return (uint8_t)((ipv4_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK) * 126 RTE_IPV4_IHL_MULTIPLIER); 127 } 128 129 /** 130 * @internal Calculate a sum of all words in the buffer. 131 * Helper routine for the rte_raw_cksum(). 132 * 133 * @param buf 134 * Pointer to the buffer. 135 * @param len 136 * Length of the buffer. 137 * @param sum 138 * Initial value of the sum. 139 * @return 140 * sum += Sum of all words in the buffer. 141 */ 142 static inline uint32_t 143 __rte_raw_cksum(const void *buf, size_t len, uint32_t sum) 144 { 145 /* workaround gcc strict-aliasing warning */ 146 uintptr_t ptr = (uintptr_t)buf; 147 typedef uint16_t __attribute__((__may_alias__)) u16_p; 148 const u16_p *u16_buf = (const u16_p *)ptr; 149 150 while (len >= (sizeof(*u16_buf) * 4)) { 151 sum += u16_buf[0]; 152 sum += u16_buf[1]; 153 sum += u16_buf[2]; 154 sum += u16_buf[3]; 155 len -= sizeof(*u16_buf) * 4; 156 u16_buf += 4; 157 } 158 while (len >= sizeof(*u16_buf)) { 159 sum += *u16_buf; 160 len -= sizeof(*u16_buf); 161 u16_buf += 1; 162 } 163 164 /* if length is in odd bytes */ 165 if (len == 1) { 166 uint16_t left = 0; 167 *(uint8_t *)&left = *(const uint8_t *)u16_buf; 168 sum += left; 169 } 170 171 return sum; 172 } 173 174 /** 175 * @internal Reduce a sum to the non-complemented checksum. 176 * Helper routine for the rte_raw_cksum(). 177 * 178 * @param sum 179 * Value of the sum. 180 * @return 181 * The non-complemented checksum. 182 */ 183 static inline uint16_t 184 __rte_raw_cksum_reduce(uint32_t sum) 185 { 186 sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff); 187 sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff); 188 return (uint16_t)sum; 189 } 190 191 /** 192 * Process the non-complemented checksum of a buffer. 193 * 194 * @param buf 195 * Pointer to the buffer. 196 * @param len 197 * Length of the buffer. 198 * @return 199 * The non-complemented checksum. 200 */ 201 static inline uint16_t 202 rte_raw_cksum(const void *buf, size_t len) 203 { 204 uint32_t sum; 205 206 sum = __rte_raw_cksum(buf, len, 0); 207 return __rte_raw_cksum_reduce(sum); 208 } 209 210 /** 211 * Compute the raw (non complemented) checksum of a packet. 212 * 213 * @param m 214 * The pointer to the mbuf. 215 * @param off 216 * The offset in bytes to start the checksum. 217 * @param len 218 * The length in bytes of the data to checksum. 219 * @param cksum 220 * A pointer to the checksum, filled on success. 221 * @return 222 * 0 on success, -1 on error (bad length or offset). 223 */ 224 static inline int 225 rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t off, uint32_t len, 226 uint16_t *cksum) 227 { 228 const struct rte_mbuf *seg; 229 const char *buf; 230 uint32_t sum, tmp; 231 uint32_t seglen, done; 232 233 /* easy case: all data in the first segment */ 234 if (off + len <= rte_pktmbuf_data_len(m)) { 235 *cksum = rte_raw_cksum(rte_pktmbuf_mtod_offset(m, 236 const char *, off), len); 237 return 0; 238 } 239 240 if (unlikely(off + len > rte_pktmbuf_pkt_len(m))) 241 return -1; /* invalid params, return a dummy value */ 242 243 /* else browse the segment to find offset */ 244 seglen = 0; 245 for (seg = m; seg != NULL; seg = seg->next) { 246 seglen = rte_pktmbuf_data_len(seg); 247 if (off < seglen) 248 break; 249 off -= seglen; 250 } 251 RTE_ASSERT(seg != NULL); 252 if (seg == NULL) 253 return -1; 254 seglen -= off; 255 buf = rte_pktmbuf_mtod_offset(seg, const char *, off); 256 if (seglen >= len) { 257 /* all in one segment */ 258 *cksum = rte_raw_cksum(buf, len); 259 return 0; 260 } 261 262 /* hard case: process checksum of several segments */ 263 sum = 0; 264 done = 0; 265 for (;;) { 266 tmp = __rte_raw_cksum(buf, seglen, 0); 267 if (done & 1) 268 tmp = rte_bswap16((uint16_t)tmp); 269 sum += tmp; 270 done += seglen; 271 if (done == len) 272 break; 273 seg = seg->next; 274 buf = rte_pktmbuf_mtod(seg, const char *); 275 seglen = rte_pktmbuf_data_len(seg); 276 if (seglen > len - done) 277 seglen = len - done; 278 } 279 280 *cksum = __rte_raw_cksum_reduce(sum); 281 return 0; 282 } 283 284 /** 285 * Process the IPv4 checksum of an IPv4 header. 286 * 287 * The checksum field must be set to 0 by the caller. 288 * 289 * @param ipv4_hdr 290 * The pointer to the contiguous IPv4 header. 291 * @return 292 * The complemented checksum to set in the IP packet. 293 */ 294 static inline uint16_t 295 rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr) 296 { 297 uint16_t cksum; 298 cksum = rte_raw_cksum(ipv4_hdr, rte_ipv4_hdr_len(ipv4_hdr)); 299 return (uint16_t)~cksum; 300 } 301 302 /** 303 * Process the pseudo-header checksum of an IPv4 header. 304 * 305 * The checksum field must be set to 0 by the caller. 306 * 307 * Depending on the ol_flags, the pseudo-header checksum expected by the 308 * drivers is not the same. For instance, when TSO is enabled, the IP 309 * payload length must not be included in the packet. 310 * 311 * When ol_flags is 0, it computes the standard pseudo-header checksum. 312 * 313 * @param ipv4_hdr 314 * The pointer to the contiguous IPv4 header. 315 * @param ol_flags 316 * The ol_flags of the associated mbuf. 317 * @return 318 * The non-complemented checksum to set in the L4 header. 319 */ 320 static inline uint16_t 321 rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags) 322 { 323 struct ipv4_psd_header { 324 uint32_t src_addr; /* IP address of source host. */ 325 uint32_t dst_addr; /* IP address of destination host. */ 326 uint8_t zero; /* zero. */ 327 uint8_t proto; /* L4 protocol type. */ 328 uint16_t len; /* L4 length. */ 329 } psd_hdr; 330 331 uint32_t l3_len; 332 333 psd_hdr.src_addr = ipv4_hdr->src_addr; 334 psd_hdr.dst_addr = ipv4_hdr->dst_addr; 335 psd_hdr.zero = 0; 336 psd_hdr.proto = ipv4_hdr->next_proto_id; 337 if (ol_flags & PKT_TX_TCP_SEG) { 338 psd_hdr.len = 0; 339 } else { 340 l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length); 341 psd_hdr.len = rte_cpu_to_be_16((uint16_t)(l3_len - 342 rte_ipv4_hdr_len(ipv4_hdr))); 343 } 344 return rte_raw_cksum(&psd_hdr, sizeof(psd_hdr)); 345 } 346 347 /** 348 * @internal Calculate the non-complemented IPv4 L4 checksum 349 */ 350 static inline uint16_t 351 __rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) 352 { 353 uint32_t cksum; 354 uint32_t l3_len, l4_len; 355 uint8_t ip_hdr_len; 356 357 ip_hdr_len = rte_ipv4_hdr_len(ipv4_hdr); 358 l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length); 359 if (l3_len < ip_hdr_len) 360 return 0; 361 362 l4_len = l3_len - ip_hdr_len; 363 364 cksum = rte_raw_cksum(l4_hdr, l4_len); 365 cksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0); 366 367 cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); 368 369 return (uint16_t)cksum; 370 } 371 372 /** 373 * Process the IPv4 UDP or TCP checksum. 374 * 375 * The layer 4 checksum must be set to 0 in the L4 header by the caller. 376 * 377 * @param ipv4_hdr 378 * The pointer to the contiguous IPv4 header. 379 * @param l4_hdr 380 * The pointer to the beginning of the L4 header. 381 * @return 382 * The complemented checksum to set in the L4 header. 383 */ 384 static inline uint16_t 385 rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) 386 { 387 uint16_t cksum = __rte_ipv4_udptcp_cksum(ipv4_hdr, l4_hdr); 388 389 cksum = ~cksum; 390 391 /* 392 * Per RFC 768: If the computed checksum is zero for UDP, 393 * it is transmitted as all ones 394 * (the equivalent in one's complement arithmetic). 395 */ 396 if (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP) 397 cksum = 0xffff; 398 399 return cksum; 400 } 401 402 /** 403 * Validate the IPv4 UDP or TCP checksum. 404 * 405 * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0 406 * (i.e. no checksum). 407 * 408 * @param ipv4_hdr 409 * The pointer to the contiguous IPv4 header. 410 * @param l4_hdr 411 * The pointer to the beginning of the L4 header. 412 * @return 413 * Return 0 if the checksum is correct, else -1. 414 */ 415 __rte_experimental 416 static inline int 417 rte_ipv4_udptcp_cksum_verify(const struct rte_ipv4_hdr *ipv4_hdr, 418 const void *l4_hdr) 419 { 420 uint16_t cksum = __rte_ipv4_udptcp_cksum(ipv4_hdr, l4_hdr); 421 422 if (cksum != 0xffff) 423 return -1; 424 425 return 0; 426 } 427 428 /** 429 * IPv6 Header 430 */ 431 struct rte_ipv6_hdr { 432 rte_be32_t vtc_flow; /**< IP version, traffic class & flow label. */ 433 rte_be16_t payload_len; /**< IP payload size, including ext. headers */ 434 uint8_t proto; /**< Protocol, next header. */ 435 uint8_t hop_limits; /**< Hop limits. */ 436 uint8_t src_addr[16]; /**< IP address of source host. */ 437 uint8_t dst_addr[16]; /**< IP address of destination host(s). */ 438 } __rte_packed; 439 440 /* IPv6 vtc_flow: IPv / TC / flow_label */ 441 #define RTE_IPV6_HDR_FL_SHIFT 0 442 #define RTE_IPV6_HDR_TC_SHIFT 20 443 #define RTE_IPV6_HDR_FL_MASK ((1u << RTE_IPV6_HDR_TC_SHIFT) - 1) 444 #define RTE_IPV6_HDR_TC_MASK (0xff << RTE_IPV6_HDR_TC_SHIFT) 445 #define RTE_IPV6_HDR_DSCP_MASK (0xfc << RTE_IPV6_HDR_TC_SHIFT) 446 #define RTE_IPV6_HDR_ECN_MASK (0x03 << RTE_IPV6_HDR_TC_SHIFT) 447 #define RTE_IPV6_HDR_ECN_CE RTE_IPV6_HDR_ECN_MASK 448 449 #define RTE_IPV6_MIN_MTU 1280 /**< Minimum MTU for IPv6, see RFC 8200. */ 450 451 /** 452 * Process the pseudo-header checksum of an IPv6 header. 453 * 454 * Depending on the ol_flags, the pseudo-header checksum expected by the 455 * drivers is not the same. For instance, when TSO is enabled, the IPv6 456 * payload length must not be included in the packet. 457 * 458 * When ol_flags is 0, it computes the standard pseudo-header checksum. 459 * 460 * @param ipv6_hdr 461 * The pointer to the contiguous IPv6 header. 462 * @param ol_flags 463 * The ol_flags of the associated mbuf. 464 * @return 465 * The non-complemented checksum to set in the L4 header. 466 */ 467 static inline uint16_t 468 rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags) 469 { 470 uint32_t sum; 471 struct { 472 rte_be32_t len; /* L4 length. */ 473 rte_be32_t proto; /* L4 protocol - top 3 bytes must be zero */ 474 } psd_hdr; 475 476 psd_hdr.proto = (uint32_t)(ipv6_hdr->proto << 24); 477 if (ol_flags & PKT_TX_TCP_SEG) { 478 psd_hdr.len = 0; 479 } else { 480 psd_hdr.len = ipv6_hdr->payload_len; 481 } 482 483 sum = __rte_raw_cksum(ipv6_hdr->src_addr, 484 sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr), 485 0); 486 sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum); 487 return __rte_raw_cksum_reduce(sum); 488 } 489 490 /** 491 * @internal Calculate the non-complemented IPv6 L4 checksum 492 */ 493 static inline uint16_t 494 __rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) 495 { 496 uint32_t cksum; 497 uint32_t l4_len; 498 499 l4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len); 500 501 cksum = rte_raw_cksum(l4_hdr, l4_len); 502 cksum += rte_ipv6_phdr_cksum(ipv6_hdr, 0); 503 504 cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); 505 506 return (uint16_t)cksum; 507 } 508 509 /** 510 * Process the IPv6 UDP or TCP checksum. 511 * 512 * The IPv6 header must not be followed by extension headers. The layer 4 513 * checksum must be set to 0 in the L4 header by the caller. 514 * 515 * @param ipv6_hdr 516 * The pointer to the contiguous IPv6 header. 517 * @param l4_hdr 518 * The pointer to the beginning of the L4 header. 519 * @return 520 * The complemented checksum to set in the L4 header. 521 */ 522 static inline uint16_t 523 rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) 524 { 525 uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr); 526 527 cksum = ~cksum; 528 529 /* 530 * Per RFC 768: If the computed checksum is zero for UDP, 531 * it is transmitted as all ones 532 * (the equivalent in one's complement arithmetic). 533 */ 534 if (cksum == 0 && ipv6_hdr->proto == IPPROTO_UDP) 535 cksum = 0xffff; 536 537 return cksum; 538 } 539 540 /** 541 * Validate the IPv6 UDP or TCP checksum. 542 * 543 * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0: 544 * this is either invalid or means no checksum in some situations. See 8.1 545 * (Upper-Layer Checksums) in RFC 8200. 546 * 547 * @param ipv6_hdr 548 * The pointer to the contiguous IPv6 header. 549 * @param l4_hdr 550 * The pointer to the beginning of the L4 header. 551 * @return 552 * Return 0 if the checksum is correct, else -1. 553 */ 554 __rte_experimental 555 static inline int 556 rte_ipv6_udptcp_cksum_verify(const struct rte_ipv6_hdr *ipv6_hdr, 557 const void *l4_hdr) 558 { 559 uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr); 560 561 if (cksum != 0xffff) 562 return -1; 563 564 return 0; 565 } 566 567 /** IPv6 fragment extension header. */ 568 #define RTE_IPV6_EHDR_MF_SHIFT 0 569 #define RTE_IPV6_EHDR_MF_MASK 1 570 #define RTE_IPV6_EHDR_FO_SHIFT 3 571 #define RTE_IPV6_EHDR_FO_MASK (~((1 << RTE_IPV6_EHDR_FO_SHIFT) - 1)) 572 #define RTE_IPV6_EHDR_FO_ALIGN (1 << RTE_IPV6_EHDR_FO_SHIFT) 573 574 #define RTE_IPV6_FRAG_USED_MASK (RTE_IPV6_EHDR_MF_MASK | RTE_IPV6_EHDR_FO_MASK) 575 576 #define RTE_IPV6_GET_MF(x) ((x) & RTE_IPV6_EHDR_MF_MASK) 577 #define RTE_IPV6_GET_FO(x) ((x) >> RTE_IPV6_EHDR_FO_SHIFT) 578 579 #define RTE_IPV6_SET_FRAG_DATA(fo, mf) \ 580 (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK)) 581 582 struct rte_ipv6_fragment_ext { 583 uint8_t next_header; /**< Next header type */ 584 uint8_t reserved; /**< Reserved */ 585 rte_be16_t frag_data; /**< All fragmentation data */ 586 rte_be32_t id; /**< Packet ID */ 587 } __rte_packed; 588 589 /* IPv6 fragment extension header size */ 590 #define RTE_IPV6_FRAG_HDR_SIZE sizeof(struct rte_ipv6_fragment_ext) 591 592 /** 593 * Parse next IPv6 header extension 594 * 595 * This function checks if proto number is an IPv6 extensions and parses its 596 * data if so, providing information on next header and extension length. 597 * 598 * @param p 599 * Pointer to an extension raw data. 600 * @param proto 601 * Protocol number extracted from the "next header" field from 602 * the IPv6 header or the previous extension. 603 * @param ext_len 604 * Extension data length. 605 * @return 606 * next protocol number if proto is an IPv6 extension, -EINVAL otherwise 607 */ 608 __rte_experimental 609 static inline int 610 rte_ipv6_get_next_ext(const uint8_t *p, int proto, size_t *ext_len) 611 { 612 int next_proto; 613 614 switch (proto) { 615 case IPPROTO_AH: 616 next_proto = *p++; 617 *ext_len = (*p + 2) * sizeof(uint32_t); 618 break; 619 620 case IPPROTO_HOPOPTS: 621 case IPPROTO_ROUTING: 622 case IPPROTO_DSTOPTS: 623 next_proto = *p++; 624 *ext_len = (*p + 1) * sizeof(uint64_t); 625 break; 626 627 case IPPROTO_FRAGMENT: 628 next_proto = *p; 629 *ext_len = RTE_IPV6_FRAG_HDR_SIZE; 630 break; 631 632 default: 633 return -EINVAL; 634 } 635 636 return next_proto; 637 } 638 639 #ifdef __cplusplus 640 } 641 #endif 642 643 #endif /* _RTE_IP_H_ */ 644