File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / mpd / src / iface.h
Revision 1.1.1.5 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:39:23 2021 UTC (3 years, 3 months ago) by misho
Branches: mpd, MAIN
CVS tags: v5_9p16, v5_9, HEAD
mpd 5.9

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>