Renamed PPPFiniteStateMachine into PPPStateMachine (the name was tooooo long).
Added some more events. Added UpRequested methods to protocols/encapsulators. Worked on actions and events. Also added some checks. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4054 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
class PPPDevice {
|
class PPPDevice {
|
||||||
public:
|
public:
|
||||||
PPPDevice(const char *fName, PPPInterface *interface, driver_parameter *settings);
|
PPPDevice(const char *fName, uint32 overhead, PPPInterface *interface, driver_parameter *settings);
|
||||||
virtual ~PPPDevice();
|
virtual ~PPPDevice();
|
||||||
|
|
||||||
virtual status_t InitCheck() const = 0;
|
virtual status_t InitCheck() const = 0;
|
||||||
@@ -14,6 +14,9 @@ class PPPDevice {
|
|||||||
const char *Name() const
|
const char *Name() const
|
||||||
{ return fName; }
|
{ return fName; }
|
||||||
|
|
||||||
|
uint32 Overhead() const
|
||||||
|
{ return fOverhead; }
|
||||||
|
|
||||||
PPPInterface *Interface() const
|
PPPInterface *Interface() const
|
||||||
{ return fInterface; }
|
{ return fInterface; }
|
||||||
driver_parameter *Settings()
|
driver_parameter *Settings()
|
||||||
@@ -24,8 +27,6 @@ class PPPDevice {
|
|||||||
virtual bool SetMTU(uint32 mtu) = 0;
|
virtual bool SetMTU(uint32 mtu) = 0;
|
||||||
uint32 MTU() const
|
uint32 MTU() const
|
||||||
{ return fMTU; }
|
{ return fMTU; }
|
||||||
virtual bool LockMTU();
|
|
||||||
virtual bool UnlockMTU();
|
|
||||||
virtual uint32 PreferredMTU() const = 0;
|
virtual uint32 PreferredMTU() const = 0;
|
||||||
|
|
||||||
virtual void Up() = 0;
|
virtual void Up() = 0;
|
||||||
@@ -66,11 +67,11 @@ class PPPDevice {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
char *fName;
|
char *fName;
|
||||||
|
uint32 fOverhead;
|
||||||
PPPInterface *fInterface;
|
PPPInterface *fInterface;
|
||||||
driver_parameter *fSettings;
|
driver_parameter *fSettings;
|
||||||
|
|
||||||
uint32 fMTU;
|
uint32 fMTU;
|
||||||
int32 fMTULock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ class PPPEncapsulator {
|
|||||||
|
|
||||||
virtual status_t InitCheck() const = 0;
|
virtual status_t InitCheck() const = 0;
|
||||||
|
|
||||||
void SetEnabled(bool enabled = true);
|
|
||||||
bool IsEnabled() const
|
|
||||||
{ return fEnabled; }
|
|
||||||
|
|
||||||
const char *Name() const
|
const char *Name() const
|
||||||
{ return fName; }
|
{ return fName; }
|
||||||
|
|
||||||
@@ -39,6 +35,14 @@ class PPPEncapsulator {
|
|||||||
int32 Flags() const
|
int32 Flags() const
|
||||||
{ return fFlags; }
|
{ return fFlags; }
|
||||||
|
|
||||||
|
void SetEnabled(bool enabled = true);
|
||||||
|
bool IsEnabled() const
|
||||||
|
{ return fEnabled; }
|
||||||
|
|
||||||
|
void SetUpRequested(bool requested = true);
|
||||||
|
bool IsUpRequested() const
|
||||||
|
{ return fUpRequested; }
|
||||||
|
|
||||||
virtual status_t Control(uint32 op, void *data, size_t length);
|
virtual status_t Control(uint32 op, void *data, size_t length);
|
||||||
|
|
||||||
void SetNext(PPPEncapsulator *next)
|
void SetNext(PPPEncapsulator *next)
|
||||||
@@ -62,7 +66,9 @@ class PPPEncapsulator {
|
|||||||
// call the interface's SendToDevice function
|
// call the interface's SendToDevice function
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetUp(bool isUp);
|
void UpFailedEvent();
|
||||||
|
void UpEvent();
|
||||||
|
void DownEvent();
|
||||||
// report up/down events
|
// report up/down events
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -78,8 +84,9 @@ class PPPEncapsulator {
|
|||||||
|
|
||||||
PPPEncapsulator *fNext;
|
PPPEncapsulator *fNext;
|
||||||
|
|
||||||
bool fIsUp;
|
|
||||||
bool fEnabled;
|
bool fEnabled;
|
||||||
|
bool fUpRequested;
|
||||||
|
bool fIsUp;
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "KPPPDefs.h"
|
#include "KPPPDefs.h"
|
||||||
|
|
||||||
#include "KPPPFiniteStateMachine.h"
|
#include "KPPPStateMachine.h"
|
||||||
#include "KPPPLCP.h"
|
#include "KPPPLCP.h"
|
||||||
|
|
||||||
#include "List.h"
|
#include "List.h"
|
||||||
@@ -32,8 +32,8 @@ class PPPInterface {
|
|||||||
driver_settings* Settings()
|
driver_settings* Settings()
|
||||||
{ return fSettings; }
|
{ return fSettings; }
|
||||||
|
|
||||||
PPPFiniteStateMachine& FiniteStateMachine() const
|
PPPStateMachine& StateMachine() const
|
||||||
{ return fFiniteStateMachine; }
|
{ return fStateMachine; }
|
||||||
PPPLCP& LCP() const
|
PPPLCP& LCP() const
|
||||||
{ return fLCP; }
|
{ return fLCP; }
|
||||||
|
|
||||||
@@ -93,9 +93,9 @@ class PPPInterface {
|
|||||||
{ return fMode; }
|
{ return fMode; }
|
||||||
// client or server mode?
|
// client or server mode?
|
||||||
PPP_STATE State() const
|
PPP_STATE State() const
|
||||||
{ return FiniteStateMachine().State(); }
|
{ return StateMachine().State(); }
|
||||||
PPP_PHASE Phase() const
|
PPP_PHASE Phase() const
|
||||||
{ return FiniteStateMachine().Phase(); }
|
{ return StateMachine().Phase(); }
|
||||||
|
|
||||||
bool Up();
|
bool Up();
|
||||||
// in server mode Up() listens for an incoming connection
|
// in server mode Up() listens for an incoming connection
|
||||||
@@ -131,7 +131,7 @@ class PPPInterface {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
driver_parameter *fSettings;
|
driver_parameter *fSettings;
|
||||||
PPPFiniteStateMachine fFiniteStateMachine;
|
PPPStateMachine fStateMachine;
|
||||||
PPPLCP fLCP;
|
PPPLCP fLCP;
|
||||||
ifnet *fIfnet;
|
ifnet *fIfnet;
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class PPPLCP : public PPPProtocol {
|
|||||||
PPPLCP& operator= (const PPPLCP& copy);
|
PPPLCP& operator= (const PPPLCP& copy);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PPPFiniteStateMachine& FiniteStateMachine() const
|
PPPStateMachine& StateMachine() const
|
||||||
{ return Interface()->FiniteStateMachine(); }
|
{ return Interface()->StateMachine(); }
|
||||||
|
|
||||||
bool AddOptionHandler(PPPOptionHandler *handler);
|
bool AddOptionHandler(PPPOptionHandler *handler);
|
||||||
bool RemoveOptionHandler(PPPOptionHandler *handler);
|
bool RemoveOptionHandler(PPPOptionHandler *handler);
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ class PPPProtocol {
|
|||||||
|
|
||||||
virtual status_t InitCheck() const = 0;
|
virtual status_t InitCheck() const = 0;
|
||||||
|
|
||||||
void SetEnabled(bool enabled = true);
|
|
||||||
bool IsEnabled() const
|
|
||||||
{ return fEnabled; }
|
|
||||||
|
|
||||||
const char *Name() const
|
const char *Name() const
|
||||||
{ return fName; }
|
{ return fName; }
|
||||||
|
|
||||||
@@ -34,6 +30,14 @@ class PPPProtocol {
|
|||||||
int32 Flags() const
|
int32 Flags() const
|
||||||
{ return fFlags; }
|
{ return fFlags; }
|
||||||
|
|
||||||
|
void SetEnabled(bool enabled = true);
|
||||||
|
bool IsEnabled() const
|
||||||
|
{ return fEnabled; }
|
||||||
|
|
||||||
|
void SetUpRequested(bool requested = true);
|
||||||
|
bool IsUpRequested() const
|
||||||
|
{ return fUpRequested; }
|
||||||
|
|
||||||
virtual status_t Control(uint32 op, void *data, size_t length);
|
virtual status_t Control(uint32 op, void *data, size_t length);
|
||||||
|
|
||||||
virtual bool Up() = 0;
|
virtual bool Up() = 0;
|
||||||
@@ -47,7 +51,9 @@ class PPPProtocol {
|
|||||||
virtual status_t Receive(mbuf *packet) = 0;
|
virtual status_t Receive(mbuf *packet) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetUp(bool isUp);
|
void UpFailedEvent();
|
||||||
|
void UpEvent();
|
||||||
|
void DownEvent();
|
||||||
// report up/down events
|
// report up/down events
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -58,8 +64,9 @@ class PPPProtocol {
|
|||||||
PPPInterface fInterface;
|
PPPInterface fInterface;
|
||||||
driver_parameter fSettings;
|
driver_parameter fSettings;
|
||||||
|
|
||||||
bool fIsUp;
|
|
||||||
bool fEnabled;
|
bool fEnabled;
|
||||||
|
bool fUpRequested;
|
||||||
|
bool fIsUp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+26
-8
@@ -1,23 +1,23 @@
|
|||||||
#ifndef _K_PPP_FINITE_STATE_MACHINE__H
|
#ifndef _K_PPP_STATE_MACHINE__H
|
||||||
#define _K_PPP_FINITE_STATE_MACHINE__H
|
#define _K_PPP_STATE_MACHINE__H
|
||||||
|
|
||||||
#include "KPPPLCP.h"
|
#include "KPPPLCP.h"
|
||||||
|
|
||||||
#include "Locker.h"
|
#include "Locker.h"
|
||||||
|
|
||||||
|
|
||||||
class PPPFiniteStateMachine {
|
class PPPStateMachine {
|
||||||
friend class PPPInterface;
|
friend class PPPInterface;
|
||||||
friend class PPPLCP;
|
friend class PPPLCP;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// may only be constructed/destructed by PPPInterface
|
// may only be constructed/destructed by PPPInterface
|
||||||
PPPFiniteStateMachine(PPPInterface& interface);
|
PPPStateMachine(PPPInterface& interface);
|
||||||
~PPPFiniteStateMachine();
|
~PPPStateMachine();
|
||||||
|
|
||||||
// copies are not allowed!
|
// copies are not allowed!
|
||||||
PPPFiniteStateMachine(const PPPFiniteStateMachine& copy);
|
PPPStateMachine(const PPPStateMachine& copy);
|
||||||
PPPFiniteStateMachine& operator= (const PPPFiniteStateMachine& copy);
|
PPPStateMachine& operator= (const PPPStateMachine& copy);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PPPInterface *Interface() const
|
PPPInterface *Interface() const
|
||||||
@@ -50,6 +50,22 @@ class PPPFiniteStateMachine {
|
|||||||
PPP_AUTHENTICATION_STATUS PeerAuthenticationStatus() const
|
PPP_AUTHENTICATION_STATUS PeerAuthenticationStatus() const
|
||||||
{ return fPeerAuthenticationStatus; }
|
{ return fPeerAuthenticationStatus; }
|
||||||
|
|
||||||
|
// sub-interface events
|
||||||
|
void UpFailedEvent(PPPInterface *interface);
|
||||||
|
void UpEvent(PPPInterface *interface);
|
||||||
|
void DownEvent(PPPInterface *interface);
|
||||||
|
|
||||||
|
// protocol events
|
||||||
|
void UpFailedEvent(PPPProtocol *protocol);
|
||||||
|
void UpEvent(PPPProtocol *protocol);
|
||||||
|
void DownEvent(PPPProtocol *protocol);
|
||||||
|
|
||||||
|
// encapsulator events
|
||||||
|
void UpFailedEvent(PPPEncapsulator *encapsulator);
|
||||||
|
void UpEvent(PPPEncapsulator *encapsulator);
|
||||||
|
void DownEvent(PPPEncapsulator *encapsulator);
|
||||||
|
|
||||||
|
// device events
|
||||||
bool TLSNotify();
|
bool TLSNotify();
|
||||||
bool TLFNotify();
|
bool TLFNotify();
|
||||||
void UpFailedEvent();
|
void UpFailedEvent();
|
||||||
@@ -62,7 +78,7 @@ class PPPFiniteStateMachine {
|
|||||||
void LeaveConstructionPhase();
|
void LeaveConstructionPhase();
|
||||||
void EnterDestructionPhase();
|
void EnterDestructionPhase();
|
||||||
|
|
||||||
// private FiniteStateMachine methods
|
// private StateMachine methods
|
||||||
void NewState(PPP_STATE next);
|
void NewState(PPP_STATE next);
|
||||||
|
|
||||||
// private events
|
// private events
|
||||||
@@ -119,6 +135,8 @@ class PPPFiniteStateMachine {
|
|||||||
// counters and timers
|
// counters and timers
|
||||||
int32 fMaxRequest, fMaxTerminate, fMaxNak;
|
int32 fMaxRequest, fMaxTerminate, fMaxNak;
|
||||||
int32 fRequestCounter, fTerminateCounter, fNakCounter;
|
int32 fRequestCounter, fTerminateCounter, fNakCounter;
|
||||||
|
uint8 fRequestID, fTerminateID;
|
||||||
|
// the ID we used for the last configure/terminate request
|
||||||
bigtime_t fTimeout;
|
bigtime_t fTimeout;
|
||||||
// last time we sent a packet
|
// last time we sent a packet
|
||||||
};
|
};
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
PPPInterface::PPPInterface(driver_settings *settings, PPPInterface *parent = NULL)
|
PPPInterface::PPPInterface(driver_settings *settings, PPPInterface *parent = NULL)
|
||||||
: fSettings(dup_driver_settings(settings)),
|
: fSettings(dup_driver_settings(settings)),
|
||||||
FiniteStateMachine(*this), LCP(*this), fIfnet(NULL), fLinkMTU(1500),
|
StateMachine(*this), LCP(*this), fIfnet(NULL), fLinkMTU(1500),
|
||||||
fAccessing(0), fChildrenCount(0), fDevice(NULL), fFirstEncapsulator(NULL),
|
fAccessing(0), fChildrenCount(0), fDevice(NULL), fFirstEncapsulator(NULL),
|
||||||
fGeneralLock(FiniteStateMachine().Locker())
|
fGeneralLock(StateMachine().Locker())
|
||||||
{
|
{
|
||||||
// are we a multilink subinterface?
|
// are we a multilink subinterface?
|
||||||
if(parent && parent->IsMultilink()) {
|
if(parent && parent->IsMultilink()) {
|
||||||
@@ -725,7 +725,7 @@ PPPInterface::Receive(mbuf *packet, uint16 protocol)
|
|||||||
m_free(packet);
|
m_free(packet);
|
||||||
return PPP_DISCARDED;
|
return PPP_DISCARDED;
|
||||||
else {
|
else {
|
||||||
FiniteStateMachine()->RUCEvent(packet, protocol);
|
StateMachine()->RUCEvent(packet, protocol);
|
||||||
return PPP_REJECTED;
|
return PPP_REJECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// - add support for multilink interfaces
|
|
||||||
// (LCP packets may be received over MP encapsulators
|
|
||||||
// so we should return the reply using the same encapsulator)
|
|
||||||
// - add LCP extension handlers
|
// - add LCP extension handlers
|
||||||
|
|
||||||
|
|
||||||
@@ -27,7 +24,7 @@ PPPLCP::AddOptionHandler(PPPOptionHandler *handler)
|
|||||||
if(!handler)
|
if(!handler)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
LockerHelper locker(FiniteStateMachine().Locker());
|
LockerHelper locker(StateMachine().Locker());
|
||||||
|
|
||||||
if(Phase() != PPP_DOWN_PHASE)
|
if(Phase() != PPP_DOWN_PHASE)
|
||||||
return false;
|
return false;
|
||||||
@@ -40,7 +37,7 @@ PPPLCP::AddOptionHandler(PPPOptionHandler *handler)
|
|||||||
bool
|
bool
|
||||||
PPPLCP::RemoveOptionHandler(PPPOptionHandler *handler)
|
PPPLCP::RemoveOptionHandler(PPPOptionHandler *handler)
|
||||||
{
|
{
|
||||||
LockerHelper locker(FiniteStateMachine().Locker());
|
LockerHelper locker(StateMachine().Locker());
|
||||||
|
|
||||||
if(Phase() != PPP_DOWN_PHASE)
|
if(Phase() != PPP_DOWN_PHASE)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+192
-64
@@ -1,31 +1,25 @@
|
|||||||
#include "KPPPFiniteStateMachine.h"
|
#include "KPPPStateMachine.h"
|
||||||
|
|
||||||
|
|
||||||
// TODO:
|
PPPStateMachine::PPPStateMachine(PPPInterface& interface)
|
||||||
// - add support for multilink interfaces
|
|
||||||
// (LCP packets may be received over MP encapsulators
|
|
||||||
// so we should return the reply using the same encapsulator)
|
|
||||||
// - add Up(Failed)/DownEvent for child interfaces + protocols + encapsulators
|
|
||||||
|
|
||||||
PPPFiniteStateMachine::PPPFiniteStateMachine(PPPInterface& interface)
|
|
||||||
: fInterface(&interface), fPhase(PPP_DOWN_PHASE),
|
: fInterface(&interface), fPhase(PPP_DOWN_PHASE),
|
||||||
fState(PPP_INITIAL_STATE), fID(system_time() & 0xFF),
|
fState(PPP_INITIAL_STATE), fID(system_time() & 0xFF),
|
||||||
fAuthenticationStatus(PPP_NOT_AUTHENTICATED),
|
fAuthenticationStatus(PPP_NOT_AUTHENTICATED),
|
||||||
fPeerAuthenticationStatus(PPP_NOT_AUTHENTICATED),
|
fPeerAuthenticationStatus(PPP_NOT_AUTHENTICATED),
|
||||||
fAuthenticatorIndex(-1), fPeerAuthenticatorIndex(-1),
|
fAuthenticatorIndex(-1), fPeerAuthenticatorIndex(-1),
|
||||||
fMaxTerminate(2), fMaxConfigure(10), fMaxNak(5),
|
fMaxTerminate(2), fMaxConfigure(10), fMaxNak(5),
|
||||||
fTimeout(0)
|
fRequestID(0), fTerminateID(0), fTimeout(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PPPFiniteStateMachine::~PPPFiniteStateMachine()
|
PPPStateMachine::~PPPStateMachine()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8
|
uint8
|
||||||
PPPFiniteStateMachine::NextID()
|
PPPStateMachine::NextID()
|
||||||
{
|
{
|
||||||
return (uint8) atomic_add(&fID, 1);
|
return (uint8) atomic_add(&fID, 1);
|
||||||
}
|
}
|
||||||
@@ -34,7 +28,7 @@ PPPFiniteStateMachine::NextID()
|
|||||||
// remember: NewState() must always be called _after_ IllegalEvent()
|
// remember: NewState() must always be called _after_ IllegalEvent()
|
||||||
// because IllegalEvent() also looks at the current state.
|
// because IllegalEvent() also looks at the current state.
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::NewState(PPP_STATE next)
|
PPPStateMachine::NewState(PPP_STATE next)
|
||||||
{
|
{
|
||||||
// if(State() == PPP_OPENED_STATE)
|
// if(State() == PPP_OPENED_STATE)
|
||||||
// ResetOptionHandlers();
|
// ResetOptionHandlers();
|
||||||
@@ -45,68 +39,122 @@ PPPFiniteStateMachine::NewState(PPP_STATE next)
|
|||||||
|
|
||||||
// authentication events
|
// authentication events
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::AuthenticationRequested()
|
PPPStateMachine::AuthenticationRequested()
|
||||||
{
|
{
|
||||||
// IMPLEMENT ME!
|
// IMPLEMENT ME!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::AuthenticationAccepted(const char *name)
|
PPPStateMachine::AuthenticationAccepted(const char *name)
|
||||||
{
|
{
|
||||||
// IMPLEMENT ME!
|
// IMPLEMENT ME!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::AuthenticationDenied(const char *name)
|
PPPStateMachine::AuthenticationDenied(const char *name)
|
||||||
{
|
{
|
||||||
// IMPLEMENT ME!
|
// IMPLEMENT ME!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
PPPFiniteStateMachine::AuthenticationName() const
|
PPPStateMachine::AuthenticationName() const
|
||||||
{
|
{
|
||||||
// IMPLEMENT ME!
|
// IMPLEMENT ME!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::PeerAuthenticationRequested()
|
PPPStateMachine::PeerAuthenticationRequested()
|
||||||
{
|
{
|
||||||
// IMPLEMENT ME!
|
// IMPLEMENT ME!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::PeerAuthenticationAccepted(const char *name)
|
PPPStateMachine::PeerAuthenticationAccepted(const char *name)
|
||||||
{
|
{
|
||||||
// IMPLEMENT ME!
|
// IMPLEMENT ME!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::PeerAuthenticationDenied(const char *name)
|
PPPStateMachine::PeerAuthenticationDenied(const char *name)
|
||||||
{
|
{
|
||||||
// IMPLEMENT ME!
|
// IMPLEMENT ME!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
PPPFiniteStateMachine::PeerAuthenticationName() const
|
PPPStateMachine::PeerAuthenticationName() const
|
||||||
{
|
{
|
||||||
// IMPLEMENT ME!
|
// IMPLEMENT ME!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::UpFailedEvent(PPPInterface *interface)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::UpEvent(PPPInterface *interface)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::DownEvent(PPPInterface *interface)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::UpFailedEvent(PPPProtocol *protocol)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::UpEvent(PPPProtocol *protocol)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::DownEvent(PPPProtocol *protocol)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::UpFailedEvent(PPPEncapsulator *encapsulator)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::UpEvent(PPPEncapsulator *encapsulator)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PPPStateMachine::DownEvent(PPPEncapsulator *encapsulator)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is called by the device to tell us that it entered establishment
|
// This is called by the device to tell us that it entered establishment
|
||||||
// phase. We can use Device::Down() to abort establishment until UpEvent()
|
// phase. We can use Device::Down() to abort establishment until UpEvent()
|
||||||
// is called.
|
// is called.
|
||||||
// The return value says if we are waiting for an UpEvent(). If false is
|
// The return value says if we are waiting for an UpEvent(). If false is
|
||||||
// returned the device should immediately abort its attempt to connect.
|
// returned the device should immediately abort its attempt to connect.
|
||||||
bool
|
bool
|
||||||
PPPFiniteStateMachine::TLSNotify()
|
PPPStateMachine::TLSNotify()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -126,7 +174,7 @@ PPPFiniteStateMachine::TLSNotify()
|
|||||||
// If false is returned we want to stay connected, though we called
|
// If false is returned we want to stay connected, though we called
|
||||||
// Device::Down().
|
// Device::Down().
|
||||||
bool
|
bool
|
||||||
PPPFiniteStateMachine::TLFNotify()
|
PPPStateMachine::TLFNotify()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -144,7 +192,7 @@ PPPFiniteStateMachine::TLFNotify()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::UpFailedEvent()
|
PPPStateMachine::UpFailedEvent()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -172,7 +220,7 @@ PPPFiniteStateMachine::UpFailedEvent()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::UpEvent()
|
PPPStateMachine::UpEvent()
|
||||||
{
|
{
|
||||||
// This call is public, thus, it might not only be called by the device.
|
// This call is public, thus, it might not only be called by the device.
|
||||||
// We must recognize these attempts to fool us and handle them correctly.
|
// We must recognize these attempts to fool us and handle them correctly.
|
||||||
@@ -224,7 +272,7 @@ PPPFiniteStateMachine::UpEvent()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::DownEvent()
|
PPPStateMachine::DownEvent()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -300,7 +348,7 @@ PPPFiniteStateMachine::DownEvent()
|
|||||||
|
|
||||||
// private events
|
// private events
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::OpenEvent()
|
PPPStateMachine::OpenEvent()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -331,7 +379,7 @@ PPPFiniteStateMachine::OpenEvent()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::CloseEvent()
|
PPPStateMachine::CloseEvent()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -378,7 +426,7 @@ PPPFiniteStateMachine::CloseEvent()
|
|||||||
|
|
||||||
// timeout (restart counters are > 0)
|
// timeout (restart counters are > 0)
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::TOGoodEvent()
|
PPPStateMachine::TOGoodEvent()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -406,7 +454,7 @@ PPPFiniteStateMachine::TOGoodEvent()
|
|||||||
|
|
||||||
// timeout (restart counters are <= 0)
|
// timeout (restart counters are <= 0)
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::TOBadEvent()
|
PPPStateMachine::TOBadEvent()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -436,10 +484,13 @@ PPPFiniteStateMachine::TOBadEvent()
|
|||||||
|
|
||||||
// receive configure request (acceptable request)
|
// receive configure request (acceptable request)
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RCRGoodEvent(mbuf *packet)
|
PPPStateMachine::RCRGoodEvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
|
if(fRequestID == mtod(packet, lcp_packet*)->id)
|
||||||
|
fRequestID -= 128;
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
@@ -485,10 +536,14 @@ PPPFiniteStateMachine::RCRGoodEvent(mbuf *packet)
|
|||||||
|
|
||||||
// receive configure request (unacceptable request)
|
// receive configure request (unacceptable request)
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RCRBadEvent(mbuf *nak, mbuf *reject)
|
PPPStateMachine::RCRBadEvent(mbuf *nak, mbuf *reject)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
|
// we should not use the same ID as the peer
|
||||||
|
if(fRequestID == mtod(packet, lcp_packet*)->id)
|
||||||
|
fRequestID -= 128;
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
@@ -530,10 +585,18 @@ PPPFiniteStateMachine::RCRBadEvent(mbuf *nak, mbuf *reject)
|
|||||||
|
|
||||||
// receive configure ack
|
// receive configure ack
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RCAEvent(mbuf *packet)
|
PPPStateMachine::RCAEvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
|
if(fRequestID != mtod(packet, lcp_packet*)->id) {
|
||||||
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// log this event
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PPPOptionHandler *handler;
|
PPPOptionHandler *handler;
|
||||||
PPPConfigurePacket ack(packet);
|
PPPConfigurePacket ack(packet);
|
||||||
|
|
||||||
@@ -584,10 +647,18 @@ PPPFiniteStateMachine::RCAEvent(mbuf *packet)
|
|||||||
|
|
||||||
// receive configure nak/reject
|
// receive configure nak/reject
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RCNEvent(mbuf *packet)
|
PPPStateMachine::RCNEvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
|
if(fRequestID != mtod(packet, lcp_packet*)->id) {
|
||||||
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// log this event
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PPPOptionHandler *handler;
|
PPPOptionHandler *handler;
|
||||||
PPPConfigurePacket nak_reject(packet);
|
PPPConfigurePacket nak_reject(packet);
|
||||||
|
|
||||||
@@ -635,10 +706,14 @@ PPPFiniteStateMachine::RCNEvent(mbuf *packet)
|
|||||||
|
|
||||||
// receive terminate request
|
// receive terminate request
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RTREvent(mbuf *packet)
|
PPPStateMachine::RTREvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
|
// we should not use the same ID as the peer
|
||||||
|
if(fTerminateID == mtod(packet, lcp_packet*)->id)
|
||||||
|
fTerminateID -= 128;
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
@@ -669,10 +744,18 @@ PPPFiniteStateMachine::RTREvent(mbuf *packet)
|
|||||||
|
|
||||||
// receive terminate ack
|
// receive terminate ack
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RTAEvent(mbuf *packet)
|
PPPStateMachine::RTAEvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
|
if(fTerminateID != mtod(packet, lcp_packet*)->id) {
|
||||||
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// log this event
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
@@ -707,7 +790,7 @@ PPPFiniteStateMachine::RTAEvent(mbuf *packet)
|
|||||||
|
|
||||||
// receive unknown code
|
// receive unknown code
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RUCEvent(mbuf *packet, uint16 protocol)
|
PPPStateMachine::RUCEvent(mbuf *packet, uint16 protocol)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -726,7 +809,7 @@ PPPFiniteStateMachine::RUCEvent(mbuf *packet, uint16 protocol)
|
|||||||
|
|
||||||
// receive code/protocol reject (acceptable such as IPX reject)
|
// receive code/protocol reject (acceptable such as IPX reject)
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RXJGoodEvent(mbuf *packet)
|
PPPStateMachine::RXJGoodEvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -745,7 +828,7 @@ PPPFiniteStateMachine::RXJGoodEvent(mbuf *packet)
|
|||||||
|
|
||||||
// receive code/protocol reject (catastrophic such as LCP reject)
|
// receive code/protocol reject (catastrophic such as LCP reject)
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RXJBadEvent(mbuf *packet)
|
PPPStateMachine::RXJBadEvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -787,7 +870,7 @@ PPPFiniteStateMachine::RXJBadEvent(mbuf *packet)
|
|||||||
|
|
||||||
// receive echo request/reply, discard request
|
// receive echo request/reply, discard request
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RXREvent(mbuf *packet)
|
PPPStateMachine::RXREvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -809,11 +892,29 @@ PPPFiniteStateMachine::RXREvent(mbuf *packet)
|
|||||||
|
|
||||||
// general events (for Good/Bad events)
|
// general events (for Good/Bad events)
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::TimerEvent()
|
PPPStateMachine::TimerEvent()
|
||||||
{
|
{
|
||||||
// TODO:
|
LockerHelper locker(fLock);
|
||||||
// check which counter expired
|
|
||||||
// call TOGood/TOBad
|
switch(State()) {
|
||||||
|
case PPP_CLOSING_STATE:
|
||||||
|
case PPP_STOPPTING_STATE:
|
||||||
|
if(fTerminateCounter <= 0)
|
||||||
|
TOBadEvent();
|
||||||
|
else
|
||||||
|
TOGoodEvent();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PPP_REQ_SENT_STATE:
|
||||||
|
case PPP_ACK_RCVD_STATE:
|
||||||
|
case PPP_ACK_SENT_STATE:
|
||||||
|
if(fConfigureCounter <= 0)
|
||||||
|
TOBadEvent();
|
||||||
|
else
|
||||||
|
TOGoodEvent();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -821,7 +922,7 @@ PPPFiniteStateMachine::TimerEvent()
|
|||||||
// Here we get a configure-request packet from LCP and aks all OptionHandlers
|
// Here we get a configure-request packet from LCP and aks all OptionHandlers
|
||||||
// if its values are acceptable. From here we call our Good/Bad counterparts.
|
// if its values are acceptable. From here we call our Good/Bad counterparts.
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RCREvent(mbuf *packet)
|
PPPStateMachine::RCREvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
PPPConfigurePacket request(packet), nak(PPP_CONFIGURE_NAK),
|
PPPConfigurePacket request(packet), nak(PPP_CONFIGURE_NAK),
|
||||||
reject(PPP_CONFIGURE_REJECT);
|
reject(PPP_CONFIGURE_REJECT);
|
||||||
@@ -874,7 +975,7 @@ PPPFiniteStateMachine::RCREvent(mbuf *packet)
|
|||||||
// LCP received a code-reject packet and we look if it is acceptable.
|
// LCP received a code-reject packet and we look if it is acceptable.
|
||||||
// From here we call our Good/Bad counterparts.
|
// From here we call our Good/Bad counterparts.
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::RXJEvent(mbuf *packet)
|
PPPStateMachine::RXJEvent(mbuf *packet)
|
||||||
{
|
{
|
||||||
lcp_packet *reject mtod(packet, lcp_packet*);
|
lcp_packet *reject mtod(packet, lcp_packet*);
|
||||||
|
|
||||||
@@ -916,7 +1017,7 @@ PPPFiniteStateMachine::RXJEvent(mbuf *packet)
|
|||||||
|
|
||||||
// actions (all private)
|
// actions (all private)
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::IllegalEvent(PPP_EVENT event)
|
PPPStateMachine::IllegalEvent(PPP_EVENT event)
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
// update error statistics
|
// update error statistics
|
||||||
@@ -924,7 +1025,7 @@ PPPFiniteStateMachine::IllegalEvent(PPP_EVENT event)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::ThisLayerUp()
|
PPPStateMachine::ThisLayerUp()
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
// bring all P/Es up
|
// bring all P/Es up
|
||||||
@@ -935,7 +1036,7 @@ PPPFiniteStateMachine::ThisLayerUp()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::ThisLayerDown()
|
PPPStateMachine::ThisLayerDown()
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
// DownProtocols();
|
// DownProtocols();
|
||||||
@@ -948,7 +1049,7 @@ PPPFiniteStateMachine::ThisLayerDown()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::ThisLayerStarted()
|
PPPStateMachine::ThisLayerStarted()
|
||||||
{
|
{
|
||||||
if(Interface()->Device())
|
if(Interface()->Device())
|
||||||
Interface()->Device()->Up();
|
Interface()->Device()->Up();
|
||||||
@@ -956,7 +1057,7 @@ PPPFiniteStateMachine::ThisLayerStarted()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::ThisLayerFinished()
|
PPPStateMachine::ThisLayerFinished()
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
// ResetProtocols();
|
// ResetProtocols();
|
||||||
@@ -968,7 +1069,7 @@ PPPFiniteStateMachine::ThisLayerFinished()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::InitializeRestartCount()
|
PPPStateMachine::InitializeRestartCount()
|
||||||
{
|
{
|
||||||
fConfigureCounter = fMaxConfigure;
|
fConfigureCounter = fMaxConfigure;
|
||||||
fTerminateCounter = fMaxTerminate;
|
fTerminateCounter = fMaxTerminate;
|
||||||
@@ -980,7 +1081,7 @@ PPPFiniteStateMachine::InitializeRestartCount()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::ZeroRestartCount()
|
PPPStateMachine::ZeroRestartCount()
|
||||||
{
|
{
|
||||||
fConfigureCounter = 0;
|
fConfigureCounter = 0;
|
||||||
fTerminateCounter = 0;
|
fTerminateCounter = 0;
|
||||||
@@ -992,17 +1093,13 @@ PPPFiniteStateMachine::ZeroRestartCount()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::SendConfigureRequest()
|
PPPStateMachine::SendConfigureRequest()
|
||||||
{
|
{
|
||||||
if(fConfigureCounter == 0) {
|
|
||||||
CloseEvent();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
--fConfigureCounter;
|
--fConfigureCounter;
|
||||||
|
|
||||||
PPPConfigurePacket request(PPP_CONFIGURE_REQUEST);
|
PPPConfigurePacket request(PPP_CONFIGURE_REQUEST);
|
||||||
request.SetID(NextID());
|
request.SetID(NextID());
|
||||||
|
fConfigureID = request.ID();
|
||||||
|
|
||||||
for(int32 i = 0; i < LCP().CountOptionHandlers(); i++) {
|
for(int32 i = 0; i < LCP().CountOptionHandlers(); i++) {
|
||||||
// add all items
|
// add all items
|
||||||
@@ -1019,7 +1116,7 @@ PPPFiniteStateMachine::SendConfigureRequest()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::SendConfigureAck(mbuf *packet)
|
PPPStateMachine::SendConfigureAck(mbuf *packet)
|
||||||
{
|
{
|
||||||
mtod(packet, lcp_packet*)->code = PPP_CONFIGURE_ACK;
|
mtod(packet, lcp_packet*)->code = PPP_CONFIGURE_ACK;
|
||||||
PPPConfigurePacket ack(packet);
|
PPPConfigurePacket ack(packet);
|
||||||
@@ -1032,7 +1129,7 @@ PPPFiniteStateMachine::SendConfigureAck(mbuf *packet)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::SendConfigureNak(mbuf *packet)
|
PPPStateMachine::SendConfigureNak(mbuf *packet)
|
||||||
{
|
{
|
||||||
lcp_packet *nak = mtod(packet, lcp_packet*);
|
lcp_packet *nak = mtod(packet, lcp_packet*);
|
||||||
if(nak->code == PPP_CONFIGURE_NAK) {
|
if(nak->code == PPP_CONFIGURE_NAK) {
|
||||||
@@ -1048,24 +1145,55 @@ PPPFiniteStateMachine::SendConfigureNak(mbuf *packet)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::SendTerminateRequest()
|
PPPStateMachine::SendTerminateRequest()
|
||||||
{
|
{
|
||||||
|
mbuf *m = m_gethdr(MT_DATA);
|
||||||
|
if(!request)
|
||||||
|
return;
|
||||||
|
|
||||||
|
--fTerminateCounter;
|
||||||
|
|
||||||
|
// reserve some space for other protocols
|
||||||
|
m->m_data += PPP_PROTOCOL_OVERHEAD;
|
||||||
|
if(LCP().Encapsulator())
|
||||||
|
m->m_data += LCP().Encapsulator()->Overhead();
|
||||||
|
if(Interface()->Device())
|
||||||
|
m->m_data += Interface()->Device()->Overhead();
|
||||||
|
|
||||||
|
lcp_packet *request = mtod(m, lcp_packet*);
|
||||||
|
request->code = PPP_TERMINATE_REQUEST;
|
||||||
|
request->id = fTerminateID = NextID();
|
||||||
|
request->length = 4;
|
||||||
|
|
||||||
|
LCP().Send(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::SendTerminateAck(mbuf *request)
|
PPPStateMachine::SendTerminateAck(mbuf *request)
|
||||||
{
|
{
|
||||||
|
lcp_packet *ack = mtod(request, lcp_packet*);
|
||||||
|
reply->code = PPP_TERMINATE_ACK;
|
||||||
|
// the request becomes an ack
|
||||||
|
|
||||||
|
LCP().Send(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::SendCodeReject(mbuf *packet, uint16 protocol)
|
PPPStateMachine::SendCodeReject(mbuf *packet, uint16 protocol)
|
||||||
{
|
{
|
||||||
|
// TODO:
|
||||||
|
// add the packet to the reject and truncate it if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPFiniteStateMachine::SendEchoReply(mbuf *request)
|
PPPStateMachine::SendEchoReply(mbuf *request)
|
||||||
{
|
{
|
||||||
|
lcp_packet *reply = mtod(request, lcp_packet*);
|
||||||
|
reply->code = PPP_ECHO_REPLY;
|
||||||
|
// the request becomes a reply
|
||||||
|
|
||||||
|
LCP().Send(request);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user