/* * iface.h - Self explanitory * Copyright (C) 1997-2000 SpellCaster Telecommunications Inc. * $Id: iface.h,v 1.5 2004/10/16 22:56:45 bcrl Exp $ * Released under the GNU Public License. See LICENSE file for details. */ #ifndef IFACE_H #define IFACE_H #include "kernel.h" #include "debug.h" #include "packet.h" #ifndef LINK_H #include "link.h" #endif #include "ipcp.h" #include "ipv6cp.h" //#include "bacp.h" //#include "bap.h" #include "queue.h" #define MAX_SEQNO 0x00FFFFFF #define MAX_SSEQNO 0x0FFF #define MP_BEGIN 0x80000000 #define MP_END 0x40000000 #define MP_SBEGIN 0x8000 #define MP_SEND 0x4000 #define MAX_FRAG_BUFS 3 #define IFACE_MAX_DIALS 4 extern char *iface_name(void *, char *); extern OptionSet_t *get_iface_options(void *); extern CInterface *FindIfaceDialing(Call *call); extern CInterface *FindIfaceName(const char *name); extern void RemoveLinkDialing(Call *call); class CDeadIface; class dfs_object_t; class bvirt_ns_t; class CInterface : public CDebugBase { public: CInterface(CLink *link, const char *username); virtual ~CInterface(); void dfs_restore(dfs_object_t *obj); void dump_full_state(ctrlfd_t *cfd); CInterface **m_prevp; CInterface *next; CDeadIface *m_dead; bvirt_ns_t *m_netns; unsigned m_ifindex; virtual void Close(int cause, const char *reason); virtual void Open(); virtual void Down(); virtual void Up(); virtual void AddLink(CLink *, int already_present = 0); virtual void DropLink(CLink *link, int cause, const char *reason = NULL); void SendAcctMsg(CLink *link, int cause, const char *reason, unsigned type, const char *iface_name); void ReadyPrepareName(struct ifreq *req, int sock_fd); void Ready(OptionSet_t *opts); void ReadyIpv6(u64 local_token, u64 remote_token); void KissOfDeath(); void RedialTimeout(void); int OutputNoQ(CPppPacket *); int OutputQ(CPppPacket *); int OutputDelete(CPppPacket *); void Input(CPppPacket *); void RcvRejIpv6(void); friend CInterface *FindIfaceDialing(Call *call); friend void killIfaces(void); friend void RemoveLinkDialing(Call *call); friend void NetDevDown(void *iface); void do_dial(void); friend void write_link_state(int fd, CLink *link, int verbose); friend void CLink::Ready(); friend void link_query_dev(int fd, char *name, int verbose); friend void link_dev_options(int fd, char *name); void set_min_frags(ctrlfd_t *cfd, unsigned long num); void set_max_frags(ctrlfd_t *cfd, unsigned long num); int get_min_frags(void); int get_max_frags(void); void GetName(char *str, size_t len, int verbose = 1); char *GetName(int verbose = 1); void async_create_bundle_complete(int ret); int async_create_bundle_in_progress; unsigned m_iface_was_up : 1; /* Have we received our IFF_UP? */ private: int ndev_id, ndev_fd; CLink *links; int nr_links; unsigned is_up : 1, name_has_ip : 1, m_has_bundle : 1, m_have_ipv6 : 1, m_trying_ip : 1, m_trying_ipv6 : 1; int have_ip; unsigned long last_rx_bytes, last_tx_bytes; time_t last_time, last_io_time; CTimer redialTimer; int min_links; // set to number of links to try to keep up int max_links; int rx_drop_bpls, rx_raise_bpls, tx_drop_bpls, tx_raise_bpls; int redial_interval; int idle_secs; int links_dialing; // number of active 'dial' requests unsigned dial_offset; // offset into number list for next dial attempt int is_static; // interface is 'static' - up always unsigned long last_dial_jiffies; unsigned long last_io_jiffies; // last time a packet was sent/received int m_throttled; Call *calls[IFACE_MAX_DIALS]; OptionSet_t m_lcfg; policy_t m_rpolicy; // copy of m_rpolicy from first link in bundle CIpcpProtocol m_ipcpProto; CIpv6cpProtocol m_ipv6cpProto; // CBacpProtocol m_bacpProto; // CBapProtocol m_bapProto; const char *m_phone; const char *m_site; const char *m_closeReason; // This is an ugly workaround for a bug that is not our fault int lflags; // local Link flags int rflags; // remote Link flags CLink *linkFlags; // Link we need to set flags on int ndev_ioctl(unsigned int cmd, unsigned long arg); int ndev_created; int create_bundle(CLink *link, unsigned long ndev_id); int async_create_bundle(CLink *link, unsigned long ndev_id); void wait_for_ndev(void); friend void ip_Input(CInterface *iface, CPppPacket *pkt); void release_dyn_ips(void); void AddIpv6Route(int sock6_fd, RouteIpv6_t *route, u64 remote_token, int index); void SendAcctStart(CLink *link); friend int async_create_bundle_rpc(void *arg1, void *arg2); int set_ipv4_rp_filter(long val); }; extern CInterface *ifListHead; extern u32 iface_fixed_local_ip; extern u32 radius_local_ip; #endif // IFACE_H