Annotation of Gnu-Mach/linux/src/include/net/ip_masq.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  *     IP masquerading functionality definitions
                      3:  */
                      4: 
                      5: #ifndef _IP_MASQ_H
                      6: #define _IP_MASQ_H
                      7: 
                      8: #include <linux/types.h>
                      9: #include <linux/netdevice.h>
                     10: #include <linux/skbuff.h>
                     11: #include <linux/config.h>
                     12: 
                     13: /*
                     14:  * This define affects the number of ports that can be handled
                     15:  * by each of the protocol helper modules.
                     16:  */
                     17: #define MAX_MASQ_APP_PORTS 12
                     18: 
                     19: /*
                     20:  *     Linux ports don't normally get allocated above 32K.
                     21:  *     I used an extra 4K port-space
                     22:  */
                     23: 
                     24: #define PORT_MASQ_BEGIN        61000
                     25: #define PORT_MASQ_END  (PORT_MASQ_BEGIN+4096)
                     26: 
                     27: /*
                     28:  * Default timeouts for masquerade functions The control channels now
                     29:  * expire the same as TCP channels (other than being updated by
                     30:  * packets on their associated data channels.
                     31:  */
                     32: #define MASQUERADE_EXPIRE_TCP     15*60*HZ
                     33: #define MASQUERADE_EXPIRE_TCP_FIN  2*60*HZ
                     34: #define MASQUERADE_EXPIRE_UDP      5*60*HZ
                     35: /* 
                     36:  * ICMP can no longer be modified on the fly using an ioctl - this
                     37:  * define is the only way to change the timeouts 
                     38:  */
                     39: #define MASQUERADE_EXPIRE_ICMP      125*HZ
                     40: 
                     41: #define IP_AUTOFW_EXPIRE            15*HZ
                     42: 
                     43: #define IP_MASQ_F_OUT_SEQ                      0x01    /* must do output seq adjust */
                     44: #define IP_MASQ_F_IN_SEQ               0x02    /* must do input seq adjust */
                     45: #define IP_MASQ_F_NO_DPORT             0x04    /* no dport set yet */
                     46: #define IP_MASQ_F_NO_DADDR             0x08    /* no daddr yet */
                     47: #define IP_MASQ_F_HASHED               0x10    /* hashed entry */
                     48: #define IP_MASQ_F_SAW_RST              0x20    /* tcp rst pkt seen */
                     49: #define IP_MASQ_F_SAW_FIN_IN           0x40    /* tcp fin pkt seen incoming */
                     50: #define IP_MASQ_F_SAW_FIN_OUT          0x80    /* tcp fin pkt seen outgoing */
                     51: #define IP_MASQ_F_SAW_FIN              (IP_MASQ_F_SAW_FIN_IN | \
                     52:                                         IP_MASQ_F_SAW_FIN_OUT)
                     53:                                                /* tcp fin pkts seen */
                     54: #define IP_MASQ_F_CONTROL              0x100   /* this is a control channel */
                     55: #define IP_MASQ_F_NO_SPORT             0x200   /* no sport set yet */
                     56: #define IP_MASQ_F_FTP_PASV             0x400   /* ftp PASV command just issued */
                     57: #define IP_MASQ_F_NO_REPLY             0x800   /* no reply yet from outside */
                     58: #define IP_MASQ_F_AFW_PORT            0x1000
                     59: 
                     60: #ifdef __KERNEL__
                     61: 
                     62: /*
                     63:  *     Delta seq. info structure
                     64:  *     Each MASQ struct has 2 (output AND input seq. changes).
                     65:  */
                     66: 
                     67: struct ip_masq_seq {
                     68:         __u32          init_seq;       /* Add delta from this seq */
                     69:         short          delta;          /* Delta in sequence numbers */
                     70:         short          previous_delta; /* Delta in sequence numbers before last resized pkt */
                     71: };
                     72: 
                     73: /*
                     74:  *     MASQ structure allocated for each masqueraded association
                     75:  */
                     76: struct ip_masq {
                     77:         struct ip_masq  *m_link, *s_link; /* hashed link ptrs */
                     78:        struct timer_list timer;        /* Expiration timer */
                     79:        __u16           protocol;       /* Which protocol are we talking? */
                     80:        __u16           sport, dport, mport;    /* src, dst & masq ports */
                     81:        __u32           saddr, daddr, maddr;    /* src, dst & masq addresses */
                     82:         struct ip_masq_seq out_seq, in_seq;
                     83:        struct ip_masq_app *app;        /* bound ip_masq_app object */
                     84:        void            *app_data;      /* Application private data */
                     85:        unsigned  flags;                /* status flags */
                     86:        struct ip_masq  *control;       /* Corresponding control connection */
                     87: };
                     88: 
                     89: /*
                     90:  *     timeout values
                     91:  */
                     92: 
                     93: struct ip_fw_masq {
                     94:         int tcp_timeout;
                     95:         int tcp_fin_timeout;
                     96:         int udp_timeout;
                     97: };
                     98: 
                     99: extern struct ip_fw_masq *ip_masq_expire;
                    100: 
                    101: /*
                    102:  *     [0]: UDP free_ports
                    103:  *     [1]: TCP free_ports
                    104:  *     [2]: ICMP free ids
                    105:  */
                    106: 
                    107: extern int ip_masq_free_ports[3];
                    108: 
                    109: /*
                    110:  *     ip_masq initializer (registers symbols and /proc/net entries)
                    111:  */
                    112: extern int ip_masq_init(void);
                    113: 
                    114: /*
                    115:  *     functions called from ip layer
                    116:  */
                    117: extern int ip_fw_masquerade(struct sk_buff **, struct device *);
                    118: extern int ip_fw_masq_icmp(struct sk_buff **, struct device *);
                    119: extern int ip_fw_demasquerade(struct sk_buff **, struct device *);
                    120: 
                    121: /*
                    122:  *     ip_masq obj creation/deletion functions.
                    123:  */
                    124: extern struct ip_masq *ip_masq_new(struct device *dev, int proto, __u32 saddr, __u16 sport, __u32 daddr, __u16 dport, unsigned flags);
                    125: extern void ip_masq_set_expire(struct ip_masq *ms, unsigned long tout);
                    126: 
                    127: #ifdef CONFIG_IP_MASQUERADE_IPAUTOFW
                    128: extern void ip_autofw_expire(unsigned long data);
                    129: #endif
                    130: 
                    131: /*
                    132:  *     
                    133:  *     IP_MASQ_APP: IP application masquerading definitions 
                    134:  *
                    135:  */
                    136: 
                    137: struct ip_masq_app
                    138: {
                    139:         struct ip_masq_app *next;
                    140:        char *name;             /* name of application proxy */
                    141:         unsigned type;          /* type = proto<<16 | port (host byte order)*/
                    142:         int n_attach;
                    143:         int (*masq_init_1)      /* ip_masq initializer */
                    144:                 (struct ip_masq_app *, struct ip_masq *);
                    145:         int (*masq_done_1)      /* ip_masq fin. */
                    146:                 (struct ip_masq_app *, struct ip_masq *);
                    147:         int (*pkt_out)          /* output (masquerading) hook */
                    148:                 (struct ip_masq_app *, struct ip_masq *, struct sk_buff **, struct device *);
                    149:         int (*pkt_in)           /* input (demasq) hook */
                    150:                 (struct ip_masq_app *, struct ip_masq *, struct sk_buff **, struct device *);
                    151: };
                    152: 
                    153: /*
                    154:  *     ip_masq_app initializer
                    155:  */
                    156: extern int ip_masq_app_init(void);
                    157: 
                    158: /*
                    159:  *     ip_masq_app object registration functions (port: host byte order)
                    160:  */
                    161: extern int register_ip_masq_app(struct ip_masq_app *mapp, unsigned short proto, __u16 port);
                    162: extern int unregister_ip_masq_app(struct ip_masq_app *mapp);
                    163: 
                    164: /*
                    165:  *     get ip_masq_app obj by proto,port(net_byte_order)
                    166:  */
                    167: extern struct ip_masq_app * ip_masq_app_get(unsigned short proto, __u16 port);
                    168: 
                    169: /*
                    170:  *     ip_masq TO ip_masq_app (un)binding functions.
                    171:  */
                    172: extern struct ip_masq_app * ip_masq_bind_app(struct ip_masq *ms);
                    173: extern int ip_masq_unbind_app(struct ip_masq *ms);
                    174: 
                    175: /*
                    176:  *     output and input app. masquerading hooks.
                    177:  *     
                    178:  */
                    179: extern int ip_masq_app_pkt_out(struct ip_masq *, struct sk_buff **skb_p, struct device *dev);
                    180: extern int ip_masq_app_pkt_in(struct ip_masq *, struct sk_buff **skb_p, struct device *dev);
                    181: 
                    182: /*
                    183:  *     service routine(s).
                    184:  */
                    185: extern struct ip_masq * ip_masq_out_get_2(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port);
                    186: extern struct ip_masq * ip_masq_in_get_2(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port);
                    187: 
                    188: /*
                    189:  *     /proc/net entry
                    190:  */
                    191: extern int ip_masq_app_getinfo(char *buffer, char **start, off_t offset, int length, int dummy);
                    192: 
                    193: /*
                    194:  *     skb_replace function used by "client" modules to replace
                    195:  *     a segment of skb.
                    196:  */
                    197: extern struct sk_buff * ip_masq_skb_replace(struct sk_buff *skb, int pri, char *o_buf, int o_len, char *n_buf, int n_len);
                    198: 
                    199: #ifdef CONFIG_IP_MASQUERADE_IPAUTOFW
                    200: extern struct ip_autofw * ip_autofw_hosts;
                    201: #endif /* CONFIG_IP_MASQUERADE_IPAUTOFW */
                    202: 
                    203: #endif /* __KERNEL__ */
                    204: 
                    205: #endif /* _IP_MASQ_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.