root/net/tcp/ip.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. net16
  2. net32

   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 bir7@leland.stanford.edu or
  20     C/O Department of Mathematics; Stanford University; Stanford, CA 94305
  21 */
  22 /* $Id: ip.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $ */
  23 /* $Log: ip.h,v $
  24  * Revision 0.8.4.1  1992/11/10  00:17:18  bir7
  25  * version change only.
  26  *
  27  * Revision 0.8.3.2  1992/11/10  00:14:47  bir7
  28  * Changed malloc to kmalloc and added $iId$ and $Log: ip.h,v $
  29  * Revision 0.8.4.1  1992/11/10  00:17:18  bir7
  30  * version change only.
  31  *.
  32  * */
  33 
  34 #ifndef _TCP_IP_H
  35 #define _TCP_IP_H
  36 
  37 #include "dev.h"
  38 #include <linux/sock_ioctl.h>
  39 /* #include <netinet/protocols.h>*/
  40 #include <netinet/in.h>
  41 
  42 struct rtable
  43 {
  44   unsigned long net;
  45   unsigned long router;
  46   struct device *dev;
  47   struct rtable *next;
  48 };
  49 
  50 struct route
  51 {
  52   char route_size;
  53   char pointer;
  54   unsigned long route[MAX_ROUTE];
  55 };
  56 
  57 struct timestamp
  58 {
  59   unsigned char len;
  60   unsigned char ptr;
  61   union
  62     {
  63       unsigned char flags:4, overflow:4;
  64       unsigned char full_char;
  65     } x;
  66   unsigned long data[9];
  67 };
  68 
  69 struct options
  70 {
  71   struct route record_route;
  72   struct route loose_route;
  73   struct route strict_route;
  74   struct timestamp tstamp;
  75   unsigned short security;
  76   unsigned short compartment;
  77   unsigned short handling;
  78   unsigned short stream;
  79   unsigned tcc;
  80 };
  81 
  82 
  83 
  84 struct ip_header
  85 {
  86   unsigned char ihl:4, version:4;
  87   unsigned char tos;
  88   unsigned short tot_len;
  89   unsigned short id;
  90   unsigned short frag_off;
  91   unsigned char ttl;
  92   unsigned char protocol;
  93   unsigned short check;
  94   unsigned long saddr;
  95   unsigned long daddr;
  96   /*The options start here. */
  97 };
  98 
  99 
 100 #define IPOPT_END 0
 101 #define IPOPT_NOOP 1
 102 #define IPOPT_SEC 130
 103 #define IPOPT_LSRR 131
 104 #define IPOPT_SSRR 137
 105 #define IPOPT_RR 7
 106 #define IPOPT_SID 136
 107 #define IPOPT_TIMESTAMP 68
 108 #define IP_LOOPBACK_ADDR 0x0100007f
 109  
 110 static inline unsigned short
 111 net16(unsigned short x)
     /* [previous][next][first][last][top][bottom][index][help] */
 112 {
 113   __asm__("xchgb %%cl,%%ch": "=c" (x) : "0" (x) : "cx");
 114   return (x);
 115 }
 116 
 117 static inline unsigned long
 118 net32(unsigned long x)
     /* [previous][next][first][last][top][bottom][index][help] */
 119 {
 120   __asm__("xchgb %%cl,%%ch\n"
 121           "\t roll $16,%%ecx\n"
 122           "\t xchgb %%cl,%%ch":"=c" (x):"0"(x):"cx");
 123   return (x);
 124 }
 125 
 126 /* change the name of this. */
 127 #define MAX_IP_PROTOS 32 /* Must be a power of 2 */
 128 
 129 /* This is used to register protocols. */
 130 struct ip_protocol 
 131 {
 132    int (*handler) (struct sk_buff *skb, struct device *dev,
 133                    struct options *opt, unsigned long daddr,
 134                    unsigned short len, unsigned long saddr,
 135                    int redo, struct ip_protocol *protocol);
 136    void (*err_handler) (int err, unsigned char *buff, unsigned long daddr,
 137                         unsigned long saddr, struct ip_protocol *ipprot);
 138    struct ip_protocol *next;
 139    unsigned char protocol;
 140    unsigned char copy:1;
 141    void *data;
 142 };
 143 
 144 extern struct ip_protocol *ip_protocol_base;
 145 extern struct ip_protocol *ip_protos[MAX_IP_PROTOS];
 146 
 147 #define MAX_IP_ADDRES 5
 148 extern unsigned long ip_addr[MAX_IP_ADDRES];
 149 #define MY_IP_ADDR ip_addr[0];
 150 int my_ip_addr(unsigned long);
 151 
 152 #include "eth.h"
 153 
 154 void
 155 print_iph (struct ip_header *);
 156 
 157 void
 158 print_eth (struct enet_header *);
 159 
 160 int ip_set_dev (struct ip_config *);
 161 
 162 int ip_build_header(struct sk_buff *skb, unsigned long saddr,
 163                     unsigned long daddr, struct device **dev, int type,
 164                     struct options *opt, int len);
 165 void ip_queue_xmit (volatile struct sock *sk, struct device *dev, 
 166                     struct sk_buff *skb, int free);
 167 void ip_retransmit(volatile struct sock *sk, int all);
 168 int ip_rcv(struct sk_buff *buff, struct device *dev, struct packet_type *);
 169 void add_ip_protocol (struct ip_protocol *);
 170 int delete_ip_protocol (struct ip_protocol *);
 171 int ip_handoff (volatile struct sock *sk);
 172 unsigned short ip_compute_csum (unsigned char *buff, int len);
 173 int ip_addr_match (unsigned long, unsigned long);
 174 void add_route (struct rtable *rt);
 175 void ip_route_check (unsigned long daddr);
 176 
 177 #endif
 178 
 179 
 180 
 181 
 182 
 183 

/* [previous][next][first][last][top][bottom][index][help] */