Annotation of embedaddon/mpd/src/iface.h, revision 1.1.1.3
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 */
110: struct optinfo options; /* Configuration options */
111: u_int idle_timeout; /* Idle timeout */
112: u_int session_timeout; /* Session timeout */
113: SLIST_HEAD(, ifaceroute) routes;
114: #ifdef USE_IPFW
115: struct acl *tables; /* List of IP added to tables by iface */
116: #endif
117: struct u_range self_addr; /* Interface's IP address */
118: struct u_addr peer_addr; /* Peer's IP address */
119: struct u_addr proxy_addr; /* Proxied IP address */
120: struct u_addr self_ipv6_addr;
121: struct u_addr peer_ipv6_addr;
122: struct pppTimer idleTimer; /* Idle timer */
123: struct pppTimer sessionTimer; /* Session timer */
124: char up_script[IFACE_MAX_SCRIPT];
125: char down_script[IFACE_MAX_SCRIPT];
126: #ifdef USE_NG_BPF
127: ng_ID_t limitID; /* ID of limit (bpf) node */
128: SLIST_HEAD(, svcs) ss[ACL_DIRS]; /* Where to get service stats */
129: struct svcstat prevstats; /* Stats from gone layers */
130: #endif
131: time_t last_up; /* Time this iface last got up */
132: u_char open:1; /* In an open state */
133: u_char dod:1; /* Interface flagged -link0 */
134: u_char up:1; /* interface is up */
135: u_char ip_up:1; /* IP interface is up */
136: u_char ipv6_up:1; /* IPv6 interface is up */
137: u_char nat_up:1; /* NAT is up */
138: u_char tee_up:1; /* TEE is up */
139: u_char tee6_up:1; /* TEE6 is up */
140: u_char nfin_up:1; /* NFIN is up */
141: u_char nfout_up:1; /* NFOUT is up */
142: u_char mss_up:1; /* MSS is up */
143: u_char ipacct_up:1; /* IPACCT is up */
144:
145: struct dodcache dodCache; /* Dial-on-demand cache */
146:
147: #ifdef USE_NG_NAT
148: struct natstate nat; /* NAT config */
149: #endif
150:
151: struct ng_ppp_link_stat64 idleStats; /* Statistics for idle timeout */
152: };
153: typedef struct ifacestate *IfaceState;
154:
155: #ifdef USE_IPFW
156: struct acl_pool { /* Pool of used ACL numbers */
157: char ifname[IFNAMSIZ]; /* Name of interface */
158: unsigned short acl_number; /* ACL number given by RADIUS unique on this interface */
159: unsigned short real_number; /* Real ACL number unique on this system */
160: struct acl_pool *next;
161: };
162: #endif
163:
164: /*
165: * VARIABLES
166: */
167:
168: extern const struct cmdtab IfaceSetCmds[];
169:
170: #ifdef USE_IPFW
171: extern struct acl_pool * rule_pool; /* Pointer to the first element in the list of rules */
172: extern struct acl_pool * pipe_pool; /* Pointer to the first element in the list of pipes */
173: extern struct acl_pool * queue_pool; /* Pointer to the first element in the list of queues */
174: extern struct acl_pool * table_pool; /* Pointer to the first element in the list of tables */
175: extern int rule_pool_start; /* Initial number of ipfw rules pool */
176: extern int pipe_pool_start; /* Initial number of ipfw dummynet pipe pool */
177: extern int queue_pool_start; /* Initial number of ipfw dummynet queue pool */
178: extern int table_pool_start; /* Initial number of ipfw tables pool */
179: #endif
180:
181: /*
182: * FUNCTIONS
183: */
184:
185: extern void IfaceInit(Bund b);
186: extern void IfaceInst(Bund b, Bund bt);
187: extern void IfaceDestroy(Bund b);
188: extern void IfaceOpen(Bund b);
189: extern void IfaceClose(Bund b);
190: extern int IfaceOpenCmd(Context ctx);
191: extern int IfaceCloseCmd(Context ctx);
192: extern int IfaceIpIfaceUp(Bund b, int ready);
193: extern void IfaceIpIfaceDown(Bund b);
194: extern int IfaceIpv6IfaceUp(Bund b, int ready);
195: extern void IfaceIpv6IfaceDown(Bund b);
196: extern void IfaceUp(Bund b, int ready);
197: extern void IfaceDown(Bund b);
198: extern int IfaceStat(Context ctx, int ac, char *av[], void *arg);
199:
200: extern void IfaceListenInput(Bund b, int proto, Mbuf pkt);
1.1.1.2 misho 201: #ifndef USE_NG_TCPMSS
1.1 misho 202: extern void IfaceCorrectMSS(Mbuf pkt, uint16_t maxmss);
1.1.1.2 misho 203: #endif
1.1 misho 204: extern void IfaceSetMTU(Bund b, int mtu);
205: extern void IfaceChangeFlags(Bund b, int clear, int set);
206: extern int IfaceChangeAddr(Bund b, int add, struct u_range *self, struct u_addr *peer);
207: extern int IfaceSetRoute(Bund b, int cmd, struct u_range *dst, struct u_addr *gw);
208:
209: #ifdef USE_NG_BPF
210: extern void IfaceGetStats(Bund b, struct svcstat *stat);
211: extern void IfaceAddStats(struct svcstat *stat1, struct svcstat *stat2);
212: extern void IfaceFreeStats(struct svcstat *stat);
213: #endif
214:
215: #endif
216:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>