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

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