Annotation of embedaddon/mpd/src/iface.h, revision 1.1.1.2
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,
55: IFACE_CONF_TCPMSSFIX,
56: IFACE_CONF_TEE,
57: IFACE_CONF_NAT,
58: IFACE_CONF_NETFLOW_IN,
59: IFACE_CONF_NETFLOW_OUT,
60: IFACE_CONF_NETFLOW_ONCE,
61: IFACE_CONF_IPACCT
62: };
63:
64: /* Dial-on-demand packet cache */
65: struct dodcache {
66: Mbuf pkt;
67: time_t ts;
68: u_short proto;
69: };
70:
71: #define MAX_DOD_CACHE_DELAY 30
72:
73: struct ifaceconf {
74: struct u_range self_addr; /* Interface's IP address */
75: struct u_addr peer_addr; /* Peer's IP address */
76: struct u_addr self_ipv6_addr;
77: struct u_addr peer_ipv6_addr;
78: u_char self_addr_force;
79: u_char peer_addr_force;
80: u_char self_ipv6_addr_force;
81: u_char peer_ipv6_addr_force;
82: char ifname[IFNAMSIZ]; /* Name of my interface */
83: #ifdef SIOCSIFDESCR
1.1.1.2 ! misho 84: char *ifdescr; /* Interface description template */
1.1 misho 85: #endif
86: #ifdef SIOCAIFGROUP
87: char ifgroup[IFNAMSIZ]; /* Group of my interface */
88: #endif
89: };
90:
91: struct ifaceroute {
92: struct u_range dest; /* Destination of route */
93: u_char ok; /* Route installed OK */
94: SLIST_ENTRY(ifaceroute) next;
95: };
96: typedef struct ifaceroute *IfaceRoute;
97:
98: struct ifacestate {
99: char ifname[IFNAMSIZ]; /* Name of my interface */
100: char ngname[IFNAMSIZ]; /* Name of my Netgraph node */
101: uint ifindex; /* System interface index */
102: #ifdef SIOCSIFDESCR
1.1.1.2 ! misho 103: char *ifdescr; /* Interface description */
1.1 misho 104: #endif
105: struct ifaceconf conf;
106: u_char traffic[IFACE_IDLE_SPLIT]; /* Mark any traffic */
107: u_short mtu; /* Interface MTU */
108: u_short max_mtu; /* Configured maximum MTU */
109: struct optinfo options; /* Configuration options */
110: u_int idle_timeout; /* Idle timeout */
111: u_int session_timeout; /* Session timeout */
112: SLIST_HEAD(, ifaceroute) routes;
113: #ifdef USE_IPFW
114: struct acl *tables; /* List of IP added to tables by iface */
115: #endif
116: struct u_range self_addr; /* Interface's IP address */
117: struct u_addr peer_addr; /* Peer's IP address */
118: struct u_addr proxy_addr; /* Proxied IP address */
119: struct u_addr self_ipv6_addr;
120: struct u_addr peer_ipv6_addr;
121: struct pppTimer idleTimer; /* Idle timer */
122: struct pppTimer sessionTimer; /* Session timer */
123: char up_script[IFACE_MAX_SCRIPT];
124: char down_script[IFACE_MAX_SCRIPT];
125: #ifdef USE_NG_BPF
126: ng_ID_t limitID; /* ID of limit (bpf) node */
127: SLIST_HEAD(, svcs) ss[ACL_DIRS]; /* Where to get service stats */
128: struct svcstat prevstats; /* Stats from gone layers */
129: #endif
130: time_t last_up; /* Time this iface last got up */
131: u_char open:1; /* In an open state */
132: u_char dod:1; /* Interface flagged -link0 */
133: u_char up:1; /* interface is up */
134: u_char ip_up:1; /* IP interface is up */
135: u_char ipv6_up:1; /* IPv6 interface is up */
136: u_char nat_up:1; /* NAT is up */
137: u_char tee_up:1; /* TEE is up */
138: u_char tee6_up:1; /* TEE6 is up */
139: u_char nfin_up:1; /* NFIN is up */
140: u_char nfout_up:1; /* NFOUT is up */
141: u_char mss_up:1; /* MSS is up */
142: u_char ipacct_up:1; /* IPACCT is up */
143:
144: struct dodcache dodCache; /* Dial-on-demand cache */
145:
146: #ifdef USE_NG_NAT
147: struct natstate nat; /* NAT config */
148: #endif
149:
150: struct ng_ppp_link_stat64 idleStats; /* Statistics for idle timeout */
151: };
152: typedef struct ifacestate *IfaceState;
153:
154: #ifdef USE_IPFW
155: struct acl_pool { /* Pool of used ACL numbers */
156: char ifname[IFNAMSIZ]; /* Name of interface */
157: unsigned short acl_number; /* ACL number given by RADIUS unique on this interface */
158: unsigned short real_number; /* Real ACL number unique on this system */
159: struct acl_pool *next;
160: };
161: #endif
162:
163: /*
164: * VARIABLES
165: */
166:
167: extern const struct cmdtab IfaceSetCmds[];
168:
169: #ifdef USE_IPFW
170: extern struct acl_pool * rule_pool; /* Pointer to the first element in the list of rules */
171: extern struct acl_pool * pipe_pool; /* Pointer to the first element in the list of pipes */
172: extern struct acl_pool * queue_pool; /* Pointer to the first element in the list of queues */
173: extern struct acl_pool * table_pool; /* Pointer to the first element in the list of tables */
174: extern int rule_pool_start; /* Initial number of ipfw rules pool */
175: extern int pipe_pool_start; /* Initial number of ipfw dummynet pipe pool */
176: extern int queue_pool_start; /* Initial number of ipfw dummynet queue pool */
177: extern int table_pool_start; /* Initial number of ipfw tables pool */
178: #endif
179:
180: /*
181: * FUNCTIONS
182: */
183:
184: extern void IfaceInit(Bund b);
185: extern void IfaceInst(Bund b, Bund bt);
186: extern void IfaceDestroy(Bund b);
187: extern void IfaceOpen(Bund b);
188: extern void IfaceClose(Bund b);
189: extern int IfaceOpenCmd(Context ctx);
190: extern int IfaceCloseCmd(Context ctx);
191: extern int IfaceIpIfaceUp(Bund b, int ready);
192: extern void IfaceIpIfaceDown(Bund b);
193: extern int IfaceIpv6IfaceUp(Bund b, int ready);
194: extern void IfaceIpv6IfaceDown(Bund b);
195: extern void IfaceUp(Bund b, int ready);
196: extern void IfaceDown(Bund b);
197: extern int IfaceStat(Context ctx, int ac, char *av[], void *arg);
198:
199: extern void IfaceListenInput(Bund b, int proto, Mbuf pkt);
1.1.1.2 ! misho 200: #ifndef USE_NG_TCPMSS
1.1 misho 201: extern void IfaceCorrectMSS(Mbuf pkt, uint16_t maxmss);
1.1.1.2 ! misho 202: #endif
1.1 misho 203: extern void IfaceSetMTU(Bund b, int mtu);
204: extern void IfaceChangeFlags(Bund b, int clear, int set);
205: extern int IfaceChangeAddr(Bund b, int add, struct u_range *self, struct u_addr *peer);
206: extern int IfaceSetRoute(Bund b, int cmd, struct u_range *dst, struct u_addr *gw);
207:
208: #ifdef USE_NG_BPF
209: extern void IfaceGetStats(Bund b, struct svcstat *stat);
210: extern void IfaceAddStats(struct svcstat *stat1, struct svcstat *stat2);
211: extern void IfaceFreeStats(struct svcstat *stat);
212: #endif
213:
214: #endif
215:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>