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