root/net/inet/ip.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ip_fast_csum

   1 /*
   2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
   3  *              operating system.  INET is implemented using the  BSD Socket
   4  *              interface as the means of communication with the user level.
   5  *
   6  *              Definitions for the IP module.
   7  *
   8  * Version:     @(#)ip.h        1.0.2   05/07/93
   9  *
  10  * Authors:     Ross Biro, <bir7@leland.Stanford.Edu>
  11  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12  *              Alan Cox, <gw4pts@gw4pts.ampr.org>
  13  *
  14  *              This program is free software; you can redistribute it and/or
  15  *              modify it under the terms of the GNU General Public License
  16  *              as published by the Free Software Foundation; either version
  17  *              2 of the License, or (at your option) any later version.
  18  */
  19 #ifndef _IP_H
  20 #define _IP_H
  21 
  22 
  23 #include <linux/ip.h>
  24 #include <linux/config.h>
  25 
  26 #ifndef _SNMP_H
  27 #include "snmp.h"
  28 #endif
  29 
  30 #include "sock.h"       /* struct sock */
  31 
  32 /* IP flags. */
  33 #define IP_CE           0x8000          /* Flag: "Congestion"           */
  34 #define IP_DF           0x4000          /* Flag: "Don't Fragment"       */
  35 #define IP_MF           0x2000          /* Flag: "More Fragments"       */
  36 #define IP_OFFSET       0x1FFF          /* "Fragment Offset" part       */
  37 
  38 #define IP_FRAG_TIME    (30 * HZ)               /* fragment lifetime    */
  39 
  40 #ifdef CONFIG_IP_MULTICAST
  41 extern void             ip_mc_dropsocket(struct sock *);
  42 extern void             ip_mc_dropdevice(struct device *dev);
  43 extern int              ip_mc_procinfo(char *, char **, off_t, int);
  44 #define MULTICAST(x)    (IN_MULTICAST(htonl(x)))
  45 #endif
  46  
  47 
  48 /* Describe an IP fragment. */
  49 struct ipfrag {
  50   int           offset;         /* offset of fragment in IP datagram    */
  51   int           end;            /* last byte of data in datagram        */
  52   int           len;            /* length of this fragment              */
  53   struct sk_buff *skb;                  /* complete received fragment           */
  54   unsigned char         *ptr;           /* pointer into real fragment data      */
  55   struct ipfrag         *next;          /* linked list pointers                 */
  56   struct ipfrag         *prev;
  57 };
  58 
  59 /* Describe an entry in the "incomplete datagrams" queue. */
  60 struct ipq       {
  61   unsigned char         *mac;           /* pointer to MAC header                */
  62   struct iphdr  *iph;           /* pointer to IP header                 */
  63   int           len;            /* total length of original datagram    */
  64   short                 ihlen;          /* length of the IP header              */
  65   short         maclen;         /* length of the MAC header             */
  66   struct timer_list timer;      /* when will this queue expire?         */
  67   struct ipfrag         *fragments;     /* linked list of received fragments    */
  68   struct ipq    *next;          /* linked list pointers                 */
  69   struct ipq    *prev;
  70   struct device *dev;           /* Device - for icmp replies */
  71 };
  72 
  73 
  74 extern int              backoff(int n);
  75 
  76 extern void             ip_print(const struct iphdr *ip);
  77 extern int              ip_ioctl(struct sock *sk, int cmd,
  78                                  unsigned long arg);
  79 extern void             ip_route_check(unsigned long daddr);
  80 extern int              ip_build_header(struct sk_buff *skb,
  81                                         unsigned long saddr,
  82                                         unsigned long daddr,
  83                                         struct device **dev, int type,
  84                                         struct options *opt, int len,
  85                                         int tos,int ttl);
  86 extern unsigned short   ip_compute_csum(unsigned char * buff, int len);
  87 extern int              ip_rcv(struct sk_buff *skb, struct device *dev,
  88                                struct packet_type *pt);
  89 extern void             ip_send_check(struct iphdr *ip);
  90 extern int              ip_id_count;                      
  91 extern void             ip_queue_xmit(struct sock *sk,
  92                                       struct device *dev, struct sk_buff *skb,
  93                                       int free);
  94 extern int              ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen);
  95 extern int              ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen);
  96 extern void             ip_init(void);
  97 
  98 extern struct ip_mib    ip_statistics;
  99 
 100 /*
 101  *      This is a version of ip_compute_csum() optimized for IP headers, which
 102  *      always checksum on 4 octet boundaries.
 103  *      Used by ip.c and slhc.c (the net driver module)
 104  *      (Moved to here by bj0rn@blox.se)
 105  */
 106 
 107 static inline unsigned short ip_fast_csum(unsigned char * buff, int wlen)
     /* [previous][next][first][last][top][bottom][index][help] */
 108 {
 109         unsigned long sum = 0;
 110 
 111         if (wlen)
 112         {
 113         unsigned long bogus;
 114          __asm__("clc\n"
 115                 "1:\t"
 116                 "lodsl\n\t"
 117                 "adcl %3, %0\n\t"
 118                 "decl %2\n\t"
 119                 "jne 1b\n\t"
 120                 "adcl $0, %0\n\t"
 121                 "movl %0, %3\n\t"
 122                 "shrl $16, %3\n\t"
 123                 "addw %w3, %w0\n\t"
 124                 "adcw $0, %w0"
 125             : "=r" (sum), "=S" (buff), "=r" (wlen), "=a" (bogus)
 126             : "0"  (sum),  "1" (buff),  "2" (wlen));
 127         }
 128         return (~sum) & 0xffff;
 129 }
 130 #endif  /* _IP_H */

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