/* * link.h - Self explanitory * Copyright (C) 1997-2000 SpellCaster Telecommunications Inc. * $Id: link.h,v 1.12 2004/10/20 05:09:54 bcrl Exp $ * Released under the GNU Public License. See LICENSE file for details. */ #ifndef LINK_H #define LINK_H #include #include "debug.h" #include "packet.h" #include "config.h" #include "d_aps_if.h" #include "lcp.h" #include "pap.h" #include "chap.h" #include "babd.h" #include "selectops.h" #include "queue.h" #include "mlcp.h" #include "timer.h" /* * Link Phases */ enum Phase { PHASE_DEAD, PHASE_DISCONNECTING, PHASE_DIALING, PHASE_CONNECTED, PHASE_ESTABLISH, PHASE_AUTHENTICATE, PHASE_MLCP, PHASE_TERMINATE, PHASE_NETWORK }; /* * The maximum number of times we susspect a loopback'd * connection before terminating */ #define MAX_LOOP_COUNT 3 class CInterface; class CLcpProtocol; class l2tp_session_t; class ctrlfd_t; class dfs_object_t; class l2tp_packet_t; class CLink; class CLinkInterimUpdateTimer : public CTimer { public: CLink *m_link; void TimerExpired(void); }; class CLink : public CDebugBase, public SelectEventHandler { public: CLinkInterimUpdateTimer m_interim_update_timer; CLink(channel_t *ch = NULL); virtual ~CLink(); void remove_disc_chans(void); void remove_multihop_link(void); public: CLink *multihop_link; unsigned m_hard_mru, m_hard_mtu; /* Used for weird channels like PPPoE which have a non-1500 default. */ virtual unsigned DefaultMRU(void) { return 1500; } // Link Options policy_t m_policy; /* Link policy options */ policy_t m_npolicy; /* Link policy options we're negotiating */ policy_t m_rpolicy; /* Link policy negotiated by the remote */ policy_t m_lpolicy; /* Link policy negotiated by us */ // Channel we're bound to channel_t *m_channel; int m_fd; l2tp_packet_t *m_iccn_pkt; // Interface we're bound to CInterface *m_interface; OptionSet_t ifOptions; // Link level protocol objects CLcpProtocol m_lcpProto; CPapProtocol m_papProto; CChapProtocol m_chapProto; CMlcpProtocol m_mlcpProto; u8 m_wereAcked; u8 m_peerAcked; // State registers and counters enum Phase m_phase; int m_loop_count; u32 m_ident; // Next link is the global list of links CLink *m_next; CLink **m_prevp; // Next link in the bundle we belong to CLink *m_nextBundled; // Unique link descriptor u16 m_ldisc; // ConnectComplete() sets the status for the link going down int m_lastStatus; int m_nrLCPRestartForMRRU; void SetDownReason(const char *reason); // State transition members virtual void Close(int status, const char *response); virtual void Open(); virtual void Down(); virtual void Up(); virtual void ConnectComplete(int); void AuthReady(); void Ready(); friend int Hangup(char *, int); // Link data processing int Output(CPppPacket *, int pri = 0); void Input(u8 *, int); virtual int HardOutput(CPppPacket *, int pri = 0); virtual int JoinBundle(int ndev_id); virtual int ch_ioctl(unsigned int cmd, unsigned long arg); virtual void Hangup(void); virtual void HardHangup(void); int Connect(const char *num, u32 calltype); virtual int HardConnect(const char *num, u32 calltype); virtual void GetConfig(void (*cbf)(void *, OptionSet_t *), void *obj, OptionSet_t *options); virtual void GotConfigTunnelGroup(OptionSet_t *os); int GotConfigFromAuth(OptionSet_t *os, CPapProtocol *auth_proto); // Accounting data unsigned int octets_in; unsigned int octets_out; unsigned int packets_in; unsigned int packets_out; /* Reason for shutdown */ char *m_reason; int disc_chans_index; TimeVal m_lastouttime; int reopen(int answer); void chclose(void); virtual void SelectEvent(int fd, SelectEventType event); void LinkCancelGetConfig(void); void dump_CLink(ctrlfd_t *cfd); const char *get_name(void) { return m_channel->device_name; } struct timespec m_connect_time; void SetTimeConnected(void); void dfs_restore(dfs_object_t *obj); virtual const char *get_multihop_name(void); virtual const char *get_user(void); virtual const char *get_class(void) { return m_channel->dev_class; } long get_connected_time(void); virtual void multihop_unlink(void); }; extern CLink *linkListHead; extern void dump_clinks(ctrlfd_t *cfd); extern int SetPolicy(u8, const char *, policy_t *); #ifndef IFACE_H #include "iface.h" #endif #endif // LINK_H