1 /****************************************************************************** 2 * 3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * You should have received a copy of the GNU General Public License along with 15 * this program; if not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 17 * 18 * 19 ******************************************************************************/ 20 #ifndef _LINUX_IP_H 21 #define _LINUX_IP_H 22 23 /* SOL_IP socket options */ 24 25 #define IPTOS_TOS_MASK 0x1E 26 #define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK) 27 #define IPTOS_LOWDELAY 0x10 28 #define IPTOS_THROUGHPUT 0x08 29 #define IPTOS_RELIABILITY 0x04 30 #define IPTOS_MINCOST 0x02 31 32 #define IPTOS_PREC_MASK 0xE0 33 #define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK) 34 #define IPTOS_PREC_NETCONTROL 0xe0 35 #define IPTOS_PREC_INTERNETCONTROL 0xc0 36 #define IPTOS_PREC_CRITIC_ECP 0xa0 37 #define IPTOS_PREC_FLASHOVERRIDE 0x80 38 #define IPTOS_PREC_FLASH 0x60 39 #define IPTOS_PREC_IMMEDIATE 0x40 40 #define IPTOS_PREC_PRIORITY 0x20 41 #define IPTOS_PREC_ROUTINE 0x00 42 43 44 /* IP options */ 45 #define IPOPT_COPY 0x80 46 #define IPOPT_CLASS_MASK 0x60 47 #define IPOPT_NUMBER_MASK 0x1f 48 49 #define IPOPT_COPIED(o) ((o)&IPOPT_COPY) 50 #define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK) 51 #define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK) 52 53 #define IPOPT_CONTROL 0x00 54 #define IPOPT_RESERVED1 0x20 55 #define IPOPT_MEASUREMENT 0x40 56 #define IPOPT_RESERVED2 0x60 57 58 #define IPOPT_END (0 |IPOPT_CONTROL) 59 #define IPOPT_NOOP (1 |IPOPT_CONTROL) 60 #define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY) 61 #define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY) 62 #define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT) 63 #define IPOPT_RR (7 |IPOPT_CONTROL) 64 #define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY) 65 #define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY) 66 #define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY) 67 68 #define IPVERSION 4 69 #define MAXTTL 255 70 #define IPDEFTTL 64 71 72 /* struct timestamp, struct route and MAX_ROUTES are removed. 73 74 REASONS: it is clear that nobody used them because: 75 - MAX_ROUTES value was wrong. 76 - "struct route" was wrong. 77 - "struct timestamp" had fatally misaligned bitfields and was completely unusable. 78 */ 79 80 #define IPOPT_OPTVAL 0 81 #define IPOPT_OLEN 1 82 #define IPOPT_OFFSET 2 83 #define IPOPT_MINOFF 4 84 #define MAX_IPOPTLEN 40 85 #define IPOPT_NOP IPOPT_NOOP 86 #define IPOPT_EOL IPOPT_END 87 #define IPOPT_TS IPOPT_TIMESTAMP 88 89 #define IPOPT_TS_TSONLY 0 /* timestamps only */ 90 #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 91 #define IPOPT_TS_PRESPEC 3 /* specified modules only */ 92 93 #ifdef PLATFORM_LINUX 94 95 struct ip_options { 96 __u32 faddr; /* Saved first hop address */ 97 unsigned char optlen; 98 unsigned char srr; 99 unsigned char rr; 100 unsigned char ts; 101 unsigned char is_setbyuser:1, /* Set by setsockopt? */ 102 is_data:1, /* Options in __data, rather than skb */ 103 is_strictroute:1, /* Strict source route */ 104 srr_is_hit:1, /* Packet destination addr was our one */ 105 is_changed:1, /* IP checksum more not valid */ 106 rr_needaddr:1, /* Need to record addr of outgoing dev */ 107 ts_needtime:1, /* Need to record timestamp */ 108 ts_needaddr:1; /* Need to record addr of outgoing dev */ 109 unsigned char router_alert; 110 unsigned char __pad1; 111 unsigned char __pad2; 112 unsigned char __data[0]; 113 }; 114 115 #define optlength(opt) (sizeof(struct ip_options) + opt->optlen) 116 #endif 117 118 struct iphdr { 119 #if defined(__LITTLE_ENDIAN_BITFIELD) 120 __u8 ihl:4, 121 version:4; 122 #elif defined (__BIG_ENDIAN_BITFIELD) 123 __u8 version:4, 124 ihl:4; 125 #else 126 #error "Please fix <asm/byteorder.h>" 127 #endif 128 __u8 tos; 129 __u16 tot_len; 130 __u16 id; 131 __u16 frag_off; 132 __u8 ttl; 133 __u8 protocol; 134 __u16 check; 135 __u32 saddr; 136 __u32 daddr; 137 /*The options start here. */ 138 }; 139 140 #endif /* _LINUX_IP_H */ 141 142