1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 * 26 * Internal IPv4 implementation-specific definitions 27 */ 28 29 #ifndef _IPV4_IMPL_H 30 #define _IPV4_IMPL_H 31 32 #pragma ident "%Z%%M% %I% %E% SMI" 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #define FRAG_MAX (40) /* max number of IP fragments per datagram */ 39 #define FRAG_SUCCESS (0) /* datagram reassembled ok */ 40 #define FRAG_DUP (1) /* duplicate ip fragment */ 41 #define FRAG_NOSLOTS (2) /* no more ip fragment slots */ 42 #define FRAG_ATTEMPTS 1 /* Try twice to get all the fragments */ 43 44 /* 45 * IP fragmentation data structure 46 */ 47 struct ip_frag { 48 int16_t more; /* Fragment bit (TRUE == MF, FALSE == No more */ 49 int16_t offset; /* Offset within the encapsulated datagram */ 50 mblk_t *mp; /* Fragment including IP header */ 51 uint16_t ipid; /* fragment ident */ 52 int16_t iplen; /* IP datagram's length */ 53 int16_t iphlen; /* Len of IP header */ 54 uint8_t ipp; /* IP protocol */ 55 }; 56 57 /* 58 * true offset is in 8 octet units. The high order 3 bits of the IP header 59 * offset field are therefore used for fragmentation flags. Shift these 60 * bits off to produce the true offset. The high order flag bit is unused 61 * (what would be considered the sign bit). Still, we cast the callers 62 * value as an unsigned quantity to ensure it is treated as positive. 63 */ 64 #define IPV4_OFFSET(a) ((uint16_t)(a) << 3) 65 66 #define IPV4_VERSION 4 67 #define IPH_HDR_LENGTH(iph) (((struct ip *)(iph))->ip_hl << 2) 68 69 /* ECN code points for IPv4 TOS byte and IPv6 traffic class octet. */ 70 #define IPH_ECN_NECT 0x0 /* Not ECN-Capabable Transport */ 71 #define IPH_ECN_ECT1 0x1 /* ECN-Capable Transport, ECT(1) */ 72 #define IPH_ECN_ECT0 0x2 /* ECN-Capable Transport, ECT(0) */ 73 #define IPH_ECN_CE 0x3 /* ECN-Congestion Experienced (CE) */ 74 75 #define IPV4_VERSION 4 76 #define IP_VERSION IPV4_VERSION 77 #define IP_SIMPLE_HDR_LENGTH_IN_WORDS 5 78 #define IP_SIMPLE_HDR_LENGTH 20 79 #define IP_MAX_HDR_LENGTH 60 80 81 #define IP_MIN_MTU (IP_MAX_HDR_LENGTH + 8) /* 68 bytes */ 82 83 /* 84 * IP routing table. IP addresses are in network-order. 85 */ 86 struct routing { 87 struct in_addr dest; 88 struct in_addr gateway; 89 uint8_t flag; 90 }; 91 92 extern void ipv4_raw_socket(struct inetboot_socket *, uint8_t); 93 extern void ipv4_socket_init(struct inetboot_socket *); 94 extern int ipv4_header_len(struct inetgram *); 95 extern int ipv4_input(int); 96 extern int ipv4_output(int, struct inetgram *); 97 extern int ipv4_tcp_output(int, mblk_t *); 98 extern struct in_addr *ipv4_get_route(uint8_t, struct in_addr *, 99 struct in_addr *); 100 101 #ifdef __cplusplus 102 } 103 #endif 104 105 #endif /* _IPV4_IMPL_H */ 106