The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet/ip_dummynet.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 1998 Luigi Rizzo
    3  *
    4  * Redistribution and use in source forms, with and without modification,
    5  * are permitted provided that this entire comment appears intact.
    6  *
    7  * Redistribution in binary form may occur without any restrictions.
    8  * Obviously, it would be nice if you gave credit where credit is due
    9  * but requiring it would be too onerous.
   10  *
   11  * This software is provided ``AS IS'' without any warranties of any kind.
   12  *
   13  * $FreeBSD: src/sys/netinet/ip_dummynet.h,v 1.1.2.3 1999/09/05 08:18:27 peter Exp $
   14  */
   15 
   16 #ifndef _IP_DUMMYNET_H
   17 #define _IP_DUMMYNET_H
   18 
   19 /*
   20  * Definition of dummynet data structures.
   21  * Dummynet handles a list of pipes, each one identified by a unique
   22  * number (hopefully the list is short so we use a linked list).
   23  *
   24  * Each list contains a set of parameters identifying the pipe, and
   25  * a set of packets queued on the pipe itself.
   26  *
   27  * I could have used queue macros, but the management i have
   28  * is pretty simple and this makes the code more portable.
   29  */
   30 
   31 /*
   32  * struct dn_pkt identifies a packet in the dummynet queue. The
   33  * first part is really an m_hdr for implementation purposes, and some
   34  * fields are saved there. When passing the packet back to the ip_input/
   35  * ip_output(), the struct is prepended to the mbuf chain with type
   36  * MT_DUMMYNET, and contains the pointer to the matching rule.
   37  */
   38 struct dn_pkt {
   39         struct m_hdr hdr ;
   40 #define dn_next hdr.mh_nextpkt  /* next element in queue */
   41 #define dn_m    hdr.mh_next     /* packet to be forwarded */
   42 #define dn_dst  hdr.mh_len      /* dst, for ip_output                   */
   43 #define dn_dir  hdr.mh_flags    /* IP_FW_F_IN or IP_FW_F_OUT            */
   44         int     delay;          /* stays queued until delay=0           */
   45         struct ifnet *ifp;      /* interface, for ip_output             */
   46         struct route ro;        /* route, for ip_output. MUST COPY      */
   47 
   48 #ifdef   DUMMYNET_DEBUG
   49         struct timeval beg, mid;        /* testing only */
   50         int     act_delay;      /* testing only */
   51         int     in_delay;       /* testing only */
   52 #endif
   53 };
   54 
   55 struct dn_queue {
   56         struct dn_pkt *head, *tail;
   57 } ;
   58 
   59 /*
   60  * descriptor of a pipe. The flags field will be used to speed up the
   61  * forwarding code paths, in case some of the parameters are not
   62  * used.
   63  */
   64 struct dn_pipe {                        /* a pipe */
   65         struct dn_pipe *next ;
   66 
   67         u_short pipe_nr ;               /* number       */
   68         u_short flags ;                 /* to speed up things   */
   69 #define DN_HAVE_BW      1
   70 #define DN_HAVE_QUEUE   2
   71 #define DN_HAVE_DELAY   4
   72         int     bandwidth;              /* really, bytes/tick.  */
   73         int     queue_size ;
   74         int     queue_size_bytes ;
   75         int     delay ;                 /* really, ticks        */
   76         int     plr ;           /* pkt loss rate (2^31-1 means 100%) */
   77 
   78         struct  dn_queue r;
   79         int     r_len;                  /* elements in r_queue */
   80         int     r_len_bytes;            /* bytes in r_queue */
   81         int     r_drops;                /* drops from r_queue */
   82         struct  dn_queue p ;
   83         int     ticks_from_last_insert;
   84         long    numbytes;               /* which can send or receive */
   85                 /* 990421 -- numbytes is scaled by 8*hz */
   86 };
   87 
   88 /*
   89  * The following is used to define a new mbuf type that is
   90  * prepended to the packet when it comes out of a pipe. The definition
   91  * ought to go in /sys/sys/mbuf.h but here it is less intrusive.
   92  */
   93 
   94 #define MT_DUMMYNET MT_CONTROL
   95 
   96 /*
   97  * what to do of a packet when it comes out of a pipe
   98  */
   99 #define DN_TO_IP_OUT    1
  100 #define DN_TO_IP_IN     2
  101 #define DN_TO_BDG_FWD   3
  102 #ifdef KERNEL
  103 void ip_dn_init(void);  /* called in ip_input.c */
  104 void dn_rule_delete(void *r);           /* used in ip_fw.c */
  105 int dummynet_io(int pipe, int dir,
  106         struct mbuf *m, struct ifnet *ifp, struct route *ro,
  107         struct sockaddr_in * dst,
  108         struct ip_fw_chain *rule);
  109 #endif
  110 #endif /* _IP_DUMMYNET_H */

Cache object: 61b4ad4e0aa15deaf2481f336b837e46


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.