|
|
1.1 ! root 1: /* ip.h */ ! 2: /* ! 3: Copyright (C) 1992 Ross Biro ! 4: ! 5: This program is free software; you can redistribute it and/or modify ! 6: it under the terms of the GNU General Public License as published by ! 7: the Free Software Foundation; either version 2, or (at your option) ! 8: any later version. ! 9: ! 10: This program is distributed in the hope that it will be useful, ! 11: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 13: GNU General Public License for more details. ! 14: ! 15: You should have received a copy of the GNU General Public License ! 16: along with this program; if not, write to the Free Software ! 17: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! 18: ! 19: The Author may be reached as [email protected] or ! 20: C/O Department of Mathematics; Stanford University; Stanford, CA 94305 ! 21: */ ! 22: #ifndef _TCP_IP_H ! 23: #define _TCP_IP_H ! 24: ! 25: #include "dev.h" ! 26: #include <linux/sock_ioctl.h> ! 27: #include <netinet/protocols.h> ! 28: ! 29: struct rtable ! 30: { ! 31: unsigned long net; ! 32: unsigned long router; ! 33: struct device *dev; ! 34: struct rtable *next; ! 35: }; ! 36: ! 37: struct route ! 38: { ! 39: char route_size; ! 40: char pointer; ! 41: unsigned long route[MAX_ROUTE]; ! 42: }; ! 43: ! 44: struct timestamp ! 45: { ! 46: unsigned char len; ! 47: unsigned char ptr; ! 48: union ! 49: { ! 50: unsigned char flags:4, overflow:4; ! 51: unsigned char full_char; ! 52: } x; ! 53: unsigned long data[9]; ! 54: }; ! 55: ! 56: struct options ! 57: { ! 58: struct route record_route; ! 59: struct route loose_route; ! 60: struct route strict_route; ! 61: struct timestamp tstamp; ! 62: unsigned short security; ! 63: unsigned short compartment; ! 64: unsigned short handling; ! 65: unsigned short stream; ! 66: unsigned tcc; ! 67: }; ! 68: ! 69: ! 70: ! 71: struct ip_header ! 72: { ! 73: unsigned char ihl:4, version:4; ! 74: unsigned char tos; ! 75: unsigned short tot_len; ! 76: unsigned short id; ! 77: unsigned short frag_off; ! 78: unsigned char ttl; ! 79: unsigned char protocol; ! 80: unsigned short check; ! 81: unsigned long saddr; ! 82: unsigned long daddr; ! 83: /*The options start here. */ ! 84: }; ! 85: ! 86: ! 87: #define IPOPT_END 0 ! 88: #define IPOPT_NOOP 1 ! 89: #define IPOPT_SEC 130 ! 90: #define IPOPT_LSRR 131 ! 91: #define IPOPT_SSRR 137 ! 92: #define IPOPT_RR 7 ! 93: #define IPOPT_SID 136 ! 94: #define IPOPT_TIMESTAMP 68 ! 95: #define IP_LOOPBACK_ADDR 0x0100007f ! 96: ! 97: static inline unsigned short ! 98: net16(unsigned short x) ! 99: { ! 100: __asm__("xchgb %%cl,%%ch": "=c" (x) : "0" (x) : "cx"); ! 101: return (x); ! 102: } ! 103: ! 104: static inline unsigned long ! 105: net32(unsigned long x) ! 106: { ! 107: __asm__("xchgb %%cl,%%ch\n" ! 108: "\t roll $16,%%ecx\n" ! 109: "\t xchgb %%cl,%%ch":"=c" (x):"0"(x):"cx"); ! 110: return (x); ! 111: } ! 112: ! 113: /* change the name of this. */ ! 114: #define MAX_IP_PROTOS 32 /* Must be a power of 2 */ ! 115: ! 116: /* This is used to register protocols. */ ! 117: struct ip_protocol ! 118: { ! 119: int (*handler) (struct sk_buff *skb, struct device *dev, ! 120: struct options *opt, unsigned long daddr, ! 121: unsigned short len, unsigned long saddr, ! 122: int redo, struct ip_protocol *protocol); ! 123: void (*err_handler) (int err, unsigned char *buff, unsigned long daddr, ! 124: unsigned long saddr, struct ip_protocol *ipprot); ! 125: struct ip_protocol *next; ! 126: unsigned char protocol; ! 127: unsigned char copy:1; ! 128: void *data; ! 129: }; ! 130: ! 131: extern struct ip_protocol *ip_protocol_base; ! 132: extern struct ip_protocol *ip_protos[MAX_IP_PROTOS]; ! 133: ! 134: #define MAX_IP_ADDRES 5 ! 135: extern unsigned long ip_addr[MAX_IP_ADDRES]; ! 136: #define MY_IP_ADDR ip_addr[0]; ! 137: int my_ip_addr(unsigned long); ! 138: ! 139: #include "eth.h" ! 140: ! 141: void ! 142: print_iph (struct ip_header *); ! 143: ! 144: void ! 145: print_eth (struct enet_header *); ! 146: ! 147: int ip_set_dev (struct ip_config *); ! 148: ! 149: int ip_build_header(struct sk_buff *skb, unsigned long saddr, ! 150: unsigned long daddr, struct device **dev, int type, ! 151: struct options *opt, int len); ! 152: void ip_queue_xmit (volatile struct sock *sk, struct device *dev, ! 153: struct sk_buff *skb, int free); ! 154: void ip_retransmit(volatile struct sock *sk, int all); ! 155: int ip_rcv(struct sk_buff *buff, struct device *dev, struct packet_type *); ! 156: void add_ip_protocol (struct ip_protocol *); ! 157: int delete_ip_protocol (struct ip_protocol *); ! 158: int ip_handoff (volatile struct sock *sk); ! 159: unsigned short ip_compute_csum (unsigned char *buff, int len); ! 160: int ip_addr_match (unsigned long, unsigned long); ! 161: void add_route (struct rtable *rt); ! 162: void ip_route_check (unsigned long daddr); ! 163: ! 164: #endif ! 165: ! 166: ! 167: ! 168: ! 169: ! 170:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.