Annotation of embedaddon/mpd/src/iface.h, revision 1.1.1.4
1.1 misho 1:
2: /*
3: * iface.h
4: *
5: * Written by Archie Cobbs <archie@freebsd.org>
6: * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
7: * See ``COPYRIGHT.whistle''
8: */
9:
10: #ifndef _IFACE_H_
11: #define _IFACE_H_
12:
13: #include <sys/types.h>
14: #include <sys/time.h>
15: #include <sys/ioctl.h>
16: #include <net/if_dl.h>
17: #include <net/bpf.h>
18: #include <netinet/ip.h>
19: #include <netinet/tcp.h>
20: #include <netgraph/ng_message.h>
21: #include <netgraph/ng_ppp.h>
22: #ifdef USE_NG_BPF
23: #include <netgraph/ng_bpf.h>
24: #endif
25: #include "mbuf.h"
26: #include "timer.h"
27: #ifdef USE_NG_NAT
28: #include "nat.h"
29: #endif
30: #include "vars.h"
31:
32: /*
33: * DEFINITIONS
34: */
35:
36: #define IFACE_MAX_ROUTES 32
37: #define IFACE_MAX_SCRIPT 128
38:
39: #define IFACE_IDLE_SPLIT 4
40:
41: #define IFACE_MIN_MTU 296
42: #define IFACE_MAX_MTU 65536
43:
44: /*
45: * We are in a liberal position about MSS
46: * (RFC 879, section 7).
47: */
48: #define MAXMSS(mtu) (mtu - sizeof(struct ip) - sizeof(struct tcphdr))
49:
50: /* Configuration options */
51:
52: enum {
53: IFACE_CONF_ONDEMAND,
54: IFACE_CONF_PROXY,
1.1.1.3 misho 55: IFACE_CONF_KEEP_TIMEOUT,
1.1 misho 56: IFACE_CONF_TCPMSSFIX,
57: IFACE_CONF_TEE,
58: IFACE_CONF_NAT,
59: IFACE_CONF_NETFLOW_IN,
60: IFACE_CONF_NETFLOW_OUT,
61: IFACE_CONF_NETFLOW_ONCE,
62: IFACE_CONF_IPACCT
63: };
64:
65: /* Dial-on-demand packet cache */
66: struct dodcache {
67: Mbuf pkt;
68: time_t ts;
69: u_short proto;
70: };
71:
72: #define MAX_DOD_CACHE_DELAY 30
73:
74: struct ifaceconf {
75: struct u_range self_addr; /* Interface's IP address */
76: struct u_addr peer_addr; /* Peer's IP address */
77: struct u_addr self_ipv6_addr;
78: struct u_addr peer_ipv6_addr;
79: u_char self_addr_force;
80: u_char peer_addr_force;
81: u_char self_ipv6_addr_force;
82: u_char peer_ipv6_addr_force;
83: char ifname[IFNAMSIZ]; /* Name of my interface */
84: #ifdef SIOCSIFDESCR
1.1.1.2 misho 85: char *ifdescr; /* Interface description template */
1.1 misho 86: #endif
87: #ifdef SIOCAIFGROUP
88: char ifgroup[IFNAMSIZ]; /* Group of my interface */
89: #endif
90: };
91:
92: struct ifaceroute {
93: struct u_range dest; /* Destination of route */
94: u_char ok; /* Route installed OK */
95: SLIST_ENTRY(ifaceroute) next;
96: };
97: typedef struct ifaceroute *IfaceRoute;
98:
99: struct ifacestate {
100: char ifname[IFNAMSIZ]; /* Name of my interface */
101: char ngname[IFNAMSIZ]; /* Name of my Netgraph node */
102: uint ifindex; /* System interface index */
103: #ifdef SIOCSIFDESCR
1.1.1.2 misho 104: char *ifdescr; /* Interface description */
1.1 misho 105: #endif
106: struct ifaceconf conf;
107: u_char traffic[IFACE_IDLE_SPLIT]; /* Mark any traffic */
108: u_short mtu; /* Interface MTU */
109: u_short max_mtu; /* Configured maximum MTU */
1.1.1.4 ! misho 110: u_short mtu_override; /* Configured MTU override */
1.1 misho 111: struct optinfo options; /* Configuration options */
112: u_int idle_timeout; /* Idle timeout */
113: u_int session_timeout; /* Session timeout */
114: SLIST_HEAD(, ifaceroute) routes;
115: #ifdef USE_IPFW
116: struct acl *tables; /* List of IP added to tables by iface */
117: #endif
118: struct u_range self_addr; /* Interface's IP address */
119: struct u_addr peer_addr; /* Peer's IP address */
120: struct u_addr proxy_addr; /* Proxied IP address */
121: struct u_addr self_ipv6_addr;
122: struct u_addr peer_ipv6_addr;
123: struct pppTimer idleTimer; /* Idle timer */
124: struct pppTimer sessionTimer; /* Session timer */
125: char up_script[IFACE_MAX_SCRIPT];
126: char down_script[IFACE_MAX_SCRIPT];
127: #ifdef USE_NG_BPF
128: ng_ID_t limitID; /* ID of limit (bpf) node */
129: SLIST_HEAD(, svcs) ss[ACL_DIRS]; /* Where to get service stats */
130: struct svcstat prevstats; /* Stats from gone layers */
131: #endif
132: time_t last_up; /* Time this iface last got up */
133: u_char open:1; /* In an open state */
134: u_char dod:1; /* Interface flagged -link0 */
135: u_char up:1; /* interface is up */
136: u_char ip_up:1; /* IP interface is up */
137: u_char ipv6_up:1; /* IPv6 interface is up */
138: u_char nat_up:1; /* NAT is up */
139: u_char tee_up:1; /* TEE is up */
140: u_char tee6_up:1; /* TEE6 is up */
141: u_char nfin_up:1; /* NFIN is up */
142: u_char nfout_up:1; /* NFOUT is up */
143: u_char mss_up:1; /* MSS is up */
144: u_char ipacct_up:1; /* IPACCT is up */
145:
146: struct dodcache dodCache; /* Dial-on-demand cache */
147:
148: #ifdef USE_NG_NAT
149: struct natstate nat; /* NAT config */
150: #endif
151:
152: struct ng_ppp_link_stat64 idleStats; /* Statistics for idle timeout */
153: };
154: typedef struct ifacestate *IfaceState;
155:
156: #ifdef USE_IPFW
157: struct acl_pool { /* Pool of used ACL numbers */
158: char ifname[IFNAMSIZ]; /* Name of interface */
159: unsigned short acl_number; /* ACL number given by RADIUS unique on this interface */
160: unsigned short real_number; /* Real ACL number unique on this system */
161: struct acl_pool *next;
162: };
163: #endif
164:
165: /*
166: * VARIABLES
167: */
168:
169: extern const struct cmdtab IfaceSetCmds[];
170:
171: #ifdef USE_IPFW
172: extern struct acl_pool * rule_pool; /* Pointer to the first element in the list of rules */
173: extern struct acl_pool * pipe_pool; /* Pointer to the first element in the list of pipes */
174: extern struct acl_pool * queue_pool; /* Pointer to the first element in the list of queues */
175: extern struct acl_pool * table_pool; /* Pointer to the first element in the list of tables */
176: extern int rule_pool_start; /* Initial number of ipfw rules pool */
177: extern int pipe_pool_start; /* Initial number of ipfw dummynet pipe pool */
178: extern int queue_pool_start; /* Initial number of ipfw dummynet queue pool */
179: extern int table_pool_start; /* Initial number of ipfw tables pool */
180: #endif
181:
182: /*
183: * FUNCTIONS
184: */
185:
186: extern void IfaceInit(Bund b);
187: extern void IfaceInst(Bund b, Bund bt);
188: extern void IfaceDestroy(Bund b);
189: extern void IfaceOpen(Bund b);
190: extern void IfaceClose(Bund b);
191: extern int IfaceOpenCmd(Context ctx);
192: extern int IfaceCloseCmd(Context ctx);
193: extern int IfaceIpIfaceUp(Bund b, int ready);
194: extern void IfaceIpIfaceDown(Bund b);
195: extern int IfaceIpv6IfaceUp(Bund b, int ready);
196: extern void IfaceIpv6IfaceDown(Bund b);
197: extern void IfaceUp(Bund b, int ready);
198: extern void IfaceDown(Bund b);
199: extern int IfaceStat(Context ctx, int ac, char *av[], void *arg);
200:
201: extern void IfaceListenInput(Bund b, int proto, Mbuf pkt);
1.1.1.2 misho 202: #ifndef USE_NG_TCPMSS
1.1 misho 203: extern void IfaceCorrectMSS(Mbuf pkt, uint16_t maxmss);
1.1.1.2 misho 204: #endif
1.1 misho 205: extern void IfaceSetMTU(Bund b, int mtu);
206: extern void IfaceChangeFlags(Bund b, int clear, int set);
207: extern int IfaceChangeAddr(Bund b, int add, struct u_range *self, struct u_addr *peer);
208: extern int IfaceSetRoute(Bund b, int cmd, struct u_range *dst, struct u_addr *gw);
209:
210: #ifdef USE_NG_BPF
211: extern void IfaceGetStats(Bund b, struct svcstat *stat);
212: extern void IfaceAddStats(struct svcstat *stat1, struct svcstat *stat2);
213: extern void IfaceFreeStats(struct svcstat *stat);
214: #endif
215:
216: #endif
217:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>