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