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_nat.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) 1995-1997 by Darren Reed.
    3  *
    4  * Redistribution and use in source and binary forms are permitted
    5  * provided that this notice is preserved and due credit is given
    6  * to the original author and the contributors.
    7  *
    8  * @(#)ip_nat.h 1.5 2/4/96
    9  * $FreeBSD$
   10  */
   11 
   12 #ifndef __IP_NAT_H__
   13 #define __IP_NAT_H__
   14 
   15 #ifndef SOLARIS
   16 #define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
   17 #endif
   18 
   19 #if defined(__STDC__) || defined(__GNUC__)
   20 #define SIOCADNAT       _IOW('r', 80, struct ipnat)
   21 #define SIOCRMNAT       _IOW('r', 81, struct ipnat)
   22 #define SIOCGNATS       _IOR('r', 82, struct natstat)
   23 #define SIOCGNATL       _IOWR('r', 83, struct natlookup)
   24 #define SIOCGFRST       _IOR('r', 84, struct ipfrstat)
   25 #define SIOCGIPST       _IOR('r', 85, struct ips_stat)
   26 #define SIOCFLNAT       _IOWR('r', 86, int)
   27 #define SIOCCNATL       _IOWR('r', 87, int)
   28 #else
   29 #define SIOCADNAT       _IOW(r, 80, struct ipnat)
   30 #define SIOCRMNAT       _IOW(r, 81, struct ipnat)
   31 #define SIOCGNATS       _IOR(r, 82, struct natstat)
   32 #define SIOCGNATL       _IOWR(r, 83, struct natlookup)
   33 #define SIOCGFRST       _IOR(r, 84, struct ipfrstat)
   34 #define SIOCGIPST       _IOR(r, 85, struct ips_stat)
   35 #define SIOCFLNAT       _IOWR(r, 86, int)
   36 #define SIOCCNATL       _IOWR(r, 87, int)
   37 #endif
   38 
   39 #define NAT_SIZE        367
   40 #ifndef APR_LABELLEN
   41 #define APR_LABELLEN    16
   42 #endif
   43 
   44 typedef struct  nat     {
   45         u_long  nat_age;
   46         int     nat_flags;
   47         u_32_t  nat_sumd;
   48         u_32_t  nat_ipsumd;
   49         void    *nat_data;
   50         struct  in_addr nat_inip;
   51         struct  in_addr nat_outip;
   52         struct  in_addr nat_oip;        /* other ip */
   53         U_QUAD_T        nat_pkts;
   54         U_QUAD_T        nat_bytes;
   55         u_short nat_oport;      /* other port */
   56         u_short nat_inport;
   57         u_short nat_outport;
   58         u_short nat_use;
   59         u_char  nat_state[2];
   60         struct  ipnat   *nat_ptr;
   61         struct  nat     *nat_next;
   62         struct  nat     *nat_hnext[2];
   63         struct  nat     **nat_hstart[2];
   64         void    *nat_ifp;
   65         int     nat_dir;
   66 } nat_t;
   67 
   68 typedef struct  ipnat   {
   69         struct  ipnat   *in_next;
   70         void    *in_ifp;
   71         void    *in_apr;
   72         u_int   in_space;
   73         u_int   in_use;
   74         struct  in_addr in_nextip;
   75         u_short in_pnext;
   76         u_short in_flags;
   77         u_short in_port[2];
   78         struct  in_addr in_in[2];
   79         struct  in_addr in_out[2];
   80         int     in_redir; /* 0 if it's a mapping, 1 if it's a hard redir */
   81         char    in_ifname[IFNAMSIZ];
   82         char    in_plabel[APR_LABELLEN];        /* proxy label */
   83         char    in_p;   /* protocol */
   84         u_short in_dport;
   85 } ipnat_t;
   86 
   87 #define in_pmin         in_port[0]      /* Also holds static redir port */
   88 #define in_pmax         in_port[1]
   89 #define in_nip          in_nextip.s_addr
   90 #define in_inip         in_in[0].s_addr
   91 #define in_inmsk        in_in[1].s_addr
   92 #define in_outip        in_out[0].s_addr
   93 #define in_outmsk       in_out[1].s_addr
   94 
   95 #define NAT_OUTBOUND    0
   96 #define NAT_INBOUND     1
   97 
   98 #define NAT_MAP         0x01
   99 #define NAT_REDIRECT    0x02
  100 #define NAT_BIMAP       (NAT_MAP|NAT_REDIRECT)
  101 
  102 #define IPN_CMPSIZ      (sizeof(struct in_addr) * 4 + sizeof(u_short) * 3 + \
  103                          sizeof(int) + IFNAMSIZ + APR_LABELLEN + sizeof(char))
  104 
  105 typedef struct  natlookup {
  106         struct  in_addr nl_inip;
  107         struct  in_addr nl_outip;
  108         struct  in_addr nl_realip;
  109         int     nl_flags;
  110         u_short nl_inport;
  111         u_short nl_outport;
  112         u_short nl_realport;
  113 } natlookup_t;
  114 
  115 typedef struct  natstat {
  116         u_long  ns_mapped[2];
  117         u_long  ns_rules;
  118         u_long  ns_added;
  119         u_long  ns_expire;
  120         u_long  ns_inuse;
  121         u_long  ns_logged;
  122         u_long  ns_logfail;
  123         nat_t   **ns_table[2];
  124         ipnat_t *ns_list;
  125 } natstat_t;
  126 
  127 #define IPN_ANY         0x00
  128 #define IPN_TCP         0x01
  129 #define IPN_UDP         0x02
  130 #define IPN_TCPUDP      0x03
  131 #define IPN_DELETE      0x04
  132 #define IPN_ICMPERR     0x08
  133 
  134 
  135 typedef struct  natlog {
  136         struct  in_addr nl_origip;
  137         struct  in_addr nl_outip;
  138         struct  in_addr nl_inip;
  139         u_short nl_origport;
  140         u_short nl_outport;
  141         u_short nl_inport;
  142         u_short nl_type;
  143         int     nl_rule;
  144         U_QUAD_T        nl_pkts;
  145         U_QUAD_T        nl_bytes;
  146 } natlog_t;
  147 
  148 
  149 #define NL_NEWMAP       NAT_MAP
  150 #define NL_NEWRDR       NAT_REDIRECT
  151 #define NL_EXPIRE       0xffff
  152 
  153 
  154 extern  void    ip_natsync __P((void *));
  155 extern  u_long  fr_defnatage;
  156 extern  u_long  fr_defnaticmpage;
  157 extern  nat_t   *nat_table[2][NAT_SIZE];
  158 #if defined(__NetBSD__) || defined(__OpenBSD__) || (__FreeBSD_version >= 300003)
  159 extern  int     nat_ioctl __P((caddr_t, u_long, int));
  160 #else
  161 extern  int     nat_ioctl __P((caddr_t, int, int));
  162 #endif
  163 extern  nat_t   *nat_new __P((ipnat_t *, ip_t *, fr_info_t *, u_short, int));
  164 extern  nat_t   *nat_outlookup __P((void *, int, struct in_addr, u_short,
  165                                  struct in_addr, u_short));
  166 extern  nat_t   *nat_inlookup __P((void *, int, struct in_addr, u_short,
  167                                 struct in_addr, u_short));
  168 extern  nat_t   *nat_lookupredir __P((natlookup_t *));
  169 extern  nat_t   *nat_lookupmapip __P((void *, int, struct in_addr, u_short,
  170                                    struct in_addr, u_short));
  171 extern  nat_t   *nat_icmpinlookup __P((ip_t *, fr_info_t *));
  172 extern  nat_t   *nat_icmpin __P((ip_t *, fr_info_t *, int *));
  173 
  174 extern  int     ip_natout __P((ip_t *, int, fr_info_t *));
  175 extern  int     ip_natin __P((ip_t *, int, fr_info_t *));
  176 extern  void    ip_natunload __P((void)), ip_natexpire __P((void));
  177 extern  void    nat_log __P((struct nat *, u_short));
  178 extern  void    fix_incksum __P((u_short *, u_32_t));
  179 extern  void    fix_outcksum __P((u_short *, u_32_t));
  180 
  181 #endif /* __IP_NAT_H__ */

Cache object: e00b0ff053671f058f89e5bcabbf92f6


[ 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.