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

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