* Made the PPP code more single-threaded.
* Removed ppp_up code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18161 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7212229343
commit
2f13f213de
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -87,16 +87,6 @@ PPPManager::~PPPManager()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// also delete all ppp_up references
|
|
||||||
ppp_app_entry *app = NULL;
|
|
||||||
for(int32 index = 0; index < fApps.CountItems(); index++) {
|
|
||||||
app = fApps.ItemAt(index);
|
|
||||||
if(app) {
|
|
||||||
free(app->interfaceName);
|
|
||||||
delete app;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(fDefaultInterface);
|
free(fDefaultInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +232,7 @@ PPPManager::DeleteInterface(ppp_interface_id ID)
|
|||||||
|
|
||||||
if(entry->deleting)
|
if(entry->deleting)
|
||||||
return true;
|
return true;
|
||||||
// this check prevents a dead-lock
|
// this prevents an endless loop between Delete() and interface->Down()
|
||||||
|
|
||||||
entry->deleting = true;
|
entry->deleting = true;
|
||||||
atomic_add(&entry->accessing, 1);
|
atomic_add(&entry->accessing, 1);
|
||||||
@ -695,23 +685,6 @@ PPPManager::EntryFor(const driver_settings *settings) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ppp_app_entry*
|
|
||||||
PPPManager::AppFor(const char *name) const
|
|
||||||
{
|
|
||||||
if(!name)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ppp_app_entry *app;
|
|
||||||
for(int32 index = 0; index < fApps.CountItems(); index++) {
|
|
||||||
app = fApps.ItemAt(index);
|
|
||||||
if(app && !strcmp(app->interfaceName, name))
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PPPManager::SettingsChanged()
|
PPPManager::SettingsChanged()
|
||||||
{
|
{
|
||||||
@ -794,26 +767,8 @@ PPPManager::_CreateInterface(const char *name,
|
|||||||
return PPP_UNDEFINED_INTERFACE_ID;
|
return PPP_UNDEFINED_INTERFACE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find an existing ppp_up entry or create a new one otherwise
|
// hidden/child interfaces should never bother the user
|
||||||
if(entry->name) {
|
if(!entry->name)
|
||||||
ppp_app_entry *app = AppFor(entry->name);
|
|
||||||
thread_info info;
|
|
||||||
if(!app || get_thread_info(app->thread, &info) != B_OK) {
|
|
||||||
if(!app) {
|
|
||||||
app = new ppp_app_entry;
|
|
||||||
app->interfaceName = strdup(entry->name);
|
|
||||||
fApps.AddItem(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
// run new ppp_up instance
|
|
||||||
const char *argv[] = { "/boot/beos/bin/ppp_up", entry->name, NULL };
|
|
||||||
const char *env[] = { NULL };
|
|
||||||
app->thread = load_image(2, argv, env);
|
|
||||||
if(app->thread < 0)
|
|
||||||
ERROR("KPPPInterface::Up(): Error: could not load ppp_up!\n");
|
|
||||||
resume_thread(app->thread);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
entry->interface->SetAskBeforeConnecting(false);
|
entry->interface->SetAskBeforeConnecting(false);
|
||||||
|
|
||||||
locker.UnlockNow();
|
locker.UnlockNow();
|
||||||
@ -890,19 +845,6 @@ PPPManager::DeleterThreadEvent()
|
|||||||
delete entry;
|
delete entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove dead ppp_up entries
|
|
||||||
ppp_app_entry *app;
|
|
||||||
thread_info info;
|
|
||||||
for(int32 index = 0; index < fApps.CountItems(); index++) {
|
|
||||||
app = fApps.ItemAt(index);
|
|
||||||
if(app && get_thread_info(app->thread, &info) != B_OK) {
|
|
||||||
fApps.RemoveItem(index);
|
|
||||||
--index;
|
|
||||||
free(app->interfaceName);
|
|
||||||
delete app;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,13 +11,6 @@
|
|||||||
#include <core_funcs.h>
|
#include <core_funcs.h>
|
||||||
|
|
||||||
|
|
||||||
// used to identify a ppp_up instance
|
|
||||||
typedef struct ppp_app_entry {
|
|
||||||
char *interfaceName;
|
|
||||||
thread_id thread;
|
|
||||||
} ppp_app_entry;
|
|
||||||
|
|
||||||
|
|
||||||
// these functions are defined in ppp.cpp
|
// these functions are defined in ppp.cpp
|
||||||
extern int ppp_ifnet_stop(ifnet *ifp);
|
extern int ppp_ifnet_stop(ifnet *ifp);
|
||||||
extern int ppp_ifnet_output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
extern int ppp_ifnet_output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
||||||
@ -65,7 +58,6 @@ class PPPManager {
|
|||||||
ppp_interface_entry *EntryFor(ifnet *ifp, int32 *saveIndex = NULL) const;
|
ppp_interface_entry *EntryFor(ifnet *ifp, int32 *saveIndex = NULL) const;
|
||||||
ppp_interface_entry *EntryFor(const char *name, int32 *saveIndex = NULL) const;
|
ppp_interface_entry *EntryFor(const char *name, int32 *saveIndex = NULL) const;
|
||||||
ppp_interface_entry *EntryFor(const driver_settings *settings) const;
|
ppp_interface_entry *EntryFor(const driver_settings *settings) const;
|
||||||
ppp_app_entry *AppFor(const char *name) const;
|
|
||||||
|
|
||||||
void SettingsChanged();
|
void SettingsChanged();
|
||||||
|
|
||||||
@ -85,7 +77,6 @@ class PPPManager {
|
|||||||
char *fDefaultInterface;
|
char *fDefaultInterface;
|
||||||
KPPPReportManager fReportManager;
|
KPPPReportManager fReportManager;
|
||||||
TemplateList<ppp_interface_entry*> fEntries;
|
TemplateList<ppp_interface_entry*> fEntries;
|
||||||
TemplateList<ppp_app_entry*> fApps;
|
|
||||||
ppp_interface_id fNextID;
|
ppp_interface_id fNextID;
|
||||||
thread_id fDeleterThread, fPulseTimer;
|
thread_id fDeleterThread, fPulseTimer;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -13,8 +13,6 @@
|
|||||||
#include <KPPPInterface.h>
|
#include <KPPPInterface.h>
|
||||||
#include <settings_tools.h>
|
#include <settings_tools.h>
|
||||||
|
|
||||||
#include <LockerHelper.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <netinet/in_var.h>
|
#include <netinet/in_var.h>
|
||||||
#include <core_funcs.h>
|
#include <core_funcs.h>
|
||||||
@ -72,8 +70,7 @@ IPCP::IPCP(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
fMaxNak(5),
|
fMaxNak(5),
|
||||||
fRequestID(0),
|
fRequestID(0),
|
||||||
fTerminateID(0),
|
fTerminateID(0),
|
||||||
fNextTimeout(0),
|
fNextTimeout(0)
|
||||||
fLock("IPCP")
|
|
||||||
{
|
{
|
||||||
// reset configurations
|
// reset configurations
|
||||||
memset(&fLocalConfiguration, 0, sizeof(ipcp_configuration));
|
memset(&fLocalConfiguration, 0, sizeof(ipcp_configuration));
|
||||||
@ -151,13 +148,10 @@ IPCP::Up()
|
|||||||
if(Interface().Mode() == PPP_SERVER_MODE)
|
if(Interface().Mode() == PPP_SERVER_MODE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -174,13 +168,10 @@ IPCP::Down()
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: Down() state=%d\n", State());
|
TRACE("IPCP: Down() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(Interface().Phase()) {
|
switch(Interface().Phase()) {
|
||||||
case PPP_DOWN_PHASE:
|
case PPP_DOWN_PHASE:
|
||||||
// interface finished terminating
|
// interface finished terminating
|
||||||
NewState(PPP_INITIAL_STATE);
|
NewState(PPP_INITIAL_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ReportDownEvent();
|
ReportDownEvent();
|
||||||
// this will also reset and update addresses
|
// this will also reset and update addresses
|
||||||
break;
|
break;
|
||||||
@ -198,7 +189,6 @@ IPCP::Down()
|
|||||||
if(State() != PPP_INITIAL_STATE && State() != PPP_CLOSING_STATE) {
|
if(State() != PPP_INITIAL_STATE && State() != PPP_CLOSING_STATE) {
|
||||||
NewState(PPP_CLOSING_STATE);
|
NewState(PPP_CLOSING_STATE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateRequest();
|
SendTerminateRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,11 +315,9 @@ IPCP::ReceiveIPPacket(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
void
|
void
|
||||||
IPCP::Pulse()
|
IPCP::Pulse()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
|
||||||
if(fNextTimeout == 0 || fNextTimeout > system_time())
|
if(fNextTimeout == 0 || fNextTimeout > system_time())
|
||||||
return;
|
return;
|
||||||
fNextTimeout = 0;
|
fNextTimeout = 0;
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
@ -539,11 +527,8 @@ IPCP::TOGoodEvent()
|
|||||||
printf("IPCP: TOGoodEvent() state=%d\n", State());
|
printf("IPCP: TOGoodEvent() state=%d\n", State());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateRequest();
|
SendTerminateRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -552,7 +537,6 @@ printf("IPCP: TOGoodEvent() state=%d\n", State());
|
|||||||
|
|
||||||
case PPP_REQ_SENT_STATE:
|
case PPP_REQ_SENT_STATE:
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -567,12 +551,9 @@ IPCP::TOBadEvent()
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: TOBadEvent() state=%d\n", State());
|
TRACE("IPCP: TOBadEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
NewState(PPP_INITIAL_STATE);
|
NewState(PPP_INITIAL_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ReportDownEvent();
|
ReportDownEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -580,7 +561,6 @@ IPCP::TOBadEvent()
|
|||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
NewState(PPP_INITIAL_STATE);
|
NewState(PPP_INITIAL_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ReportUpFailedEvent();
|
ReportUpFailedEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -701,13 +681,10 @@ IPCP::RCRGoodEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: RCRGoodEvent() state=%d\n", State());
|
TRACE("IPCP: RCRGoodEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
NewState(PPP_ACK_SENT_STATE);
|
NewState(PPP_ACK_SENT_STATE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
SendConfigureAck(packet);
|
SendConfigureAck(packet);
|
||||||
break;
|
break;
|
||||||
@ -716,20 +693,17 @@ IPCP::RCRGoodEvent(struct mbuf *packet)
|
|||||||
NewState(PPP_ACK_SENT_STATE);
|
NewState(PPP_ACK_SENT_STATE);
|
||||||
|
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureAck(packet);
|
SendConfigureAck(packet);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
NewState(PPP_OPENED_STATE);
|
NewState(PPP_OPENED_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureAck(packet);
|
SendConfigureAck(packet);
|
||||||
ReportUpEvent();
|
ReportUpEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_OPENED_STATE:
|
case PPP_OPENED_STATE:
|
||||||
NewState(PPP_ACK_SENT_STATE);
|
NewState(PPP_ACK_SENT_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
SendConfigureAck(packet);
|
SendConfigureAck(packet);
|
||||||
break;
|
break;
|
||||||
@ -745,12 +719,9 @@ IPCP::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: RCRBadEvent() state=%d\n", State());
|
TRACE("IPCP: RCRBadEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_OPENED_STATE:
|
case PPP_OPENED_STATE:
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
|
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
@ -761,7 +732,6 @@ IPCP::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
|||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_REQ_SENT_STATE:
|
case PPP_REQ_SENT_STATE:
|
||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
if(nak && ntohs(mtod(nak, ppp_lcp_packet*)->length) > 3)
|
if(nak && ntohs(mtod(nak, ppp_lcp_packet*)->length) > 3)
|
||||||
SendConfigureNak(nak);
|
SendConfigureNak(nak);
|
||||||
else if(reject && ntohs(mtod(reject, ppp_lcp_packet*)->length) > 3)
|
else if(reject && ntohs(mtod(reject, ppp_lcp_packet*)->length) > 3)
|
||||||
@ -785,8 +755,6 @@ IPCP::RCAEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: RCAEvent() state=%d\n", State());
|
TRACE("IPCP: RCAEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
||||||
// this packet is not a reply to our request
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
@ -863,20 +831,17 @@ IPCP::RCAEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
NewState(PPP_OPENED_STATE);
|
NewState(PPP_OPENED_STATE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
ReportUpEvent();
|
ReportUpEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_OPENED_STATE:
|
case PPP_OPENED_STATE:
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -893,8 +858,6 @@ IPCP::RCNEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: RCNEvent() state=%d\n", State());
|
TRACE("IPCP: RCNEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
||||||
// this packet is not a reply to our request
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
@ -992,7 +955,6 @@ IPCP::RCNEvent(struct mbuf *packet)
|
|||||||
case PPP_OPENED_STATE:
|
case PPP_OPENED_STATE:
|
||||||
if(State() == PPP_ACK_RCVD_STATE || State() == PPP_OPENED_STATE)
|
if(State() == PPP_ACK_RCVD_STATE || State() == PPP_OPENED_STATE)
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1009,8 +971,6 @@ IPCP::RTREvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: RTREvent() state=%d\n", State());
|
TRACE("IPCP: RTREvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
// we should not use the same ID as the peer
|
// we should not use the same ID as the peer
|
||||||
if(fID == mtod(packet, ppp_lcp_packet*)->id)
|
if(fID == mtod(packet, ppp_lcp_packet*)->id)
|
||||||
fID -= 128;
|
fID -= 128;
|
||||||
@ -1026,15 +986,13 @@ IPCP::RTREvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
case PPP_REQ_SENT_STATE:
|
case PPP_REQ_SENT_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateAck(packet);
|
SendTerminateAck(packet);
|
||||||
return;
|
return;
|
||||||
// do not m_freem() packet
|
// do not m_freem() packet
|
||||||
|
|
||||||
case PPP_OPENED_STATE:
|
case PPP_OPENED_STATE:
|
||||||
NewState(PPP_CLOSING_STATE);
|
NewState(PPP_CLOSING_STATE);
|
||||||
ZeroRestartCount();
|
ResetRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateAck(packet);
|
SendTerminateAck(packet);
|
||||||
return;
|
return;
|
||||||
// do not m_freem() packet
|
// do not m_freem() packet
|
||||||
@ -1052,8 +1010,6 @@ IPCP::RTAEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: RTAEvent() state=%d\n", State());
|
TRACE("IPCP: RTAEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(fTerminateID != mtod(packet, ppp_lcp_packet*)->id) {
|
if(fTerminateID != mtod(packet, ppp_lcp_packet*)->id) {
|
||||||
// this packet is not a reply to our request
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
@ -1069,7 +1025,6 @@ IPCP::RTAEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
NewState(PPP_INITIAL_STATE);
|
NewState(PPP_INITIAL_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ReportDownEvent();
|
ReportDownEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1079,7 +1034,6 @@ IPCP::RTAEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_OPENED_STATE:
|
case PPP_OPENED_STATE:
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1105,8 +1059,6 @@ IPCP::RXJBadEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: RXJBadEvent() state=%d\n", State());
|
TRACE("IPCP: RXJBadEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
IllegalEvent(PPP_RXJ_BAD_EVENT);
|
IllegalEvent(PPP_RXJ_BAD_EVENT);
|
||||||
@ -1114,7 +1066,6 @@ IPCP::RXJBadEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
NewState(PPP_INITIAL_STATE);
|
NewState(PPP_INITIAL_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ReportDownEvent();
|
ReportDownEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1122,14 +1073,12 @@ IPCP::RXJBadEvent(struct mbuf *packet)
|
|||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
NewState(PPP_INITIAL_STATE);
|
NewState(PPP_INITIAL_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ReportUpFailedEvent();
|
ReportUpFailedEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_OPENED_STATE:
|
case PPP_OPENED_STATE:
|
||||||
NewState(PPP_CLOSING_STATE);
|
NewState(PPP_CLOSING_STATE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateRequest();
|
SendTerminateRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1195,7 +1144,7 @@ IPCP::InitializeRestartCount()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IPCP::ZeroRestartCount()
|
IPCP::ResetRestartCount()
|
||||||
{
|
{
|
||||||
fRequestCounter = 0;
|
fRequestCounter = 0;
|
||||||
fTerminateCounter = 0;
|
fTerminateCounter = 0;
|
||||||
@ -1208,10 +1157,8 @@ IPCP::SendConfigureRequest()
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: SendConfigureRequest() state=%d\n", State());
|
TRACE("IPCP: SendConfigureRequest() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
--fRequestCounter;
|
--fRequestCounter;
|
||||||
fNextTimeout = system_time() + kIPCPStateMachineTimeout;
|
fNextTimeout = system_time() + kIPCPStateMachineTimeout;
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
KPPPConfigurePacket request(PPP_CONFIGURE_REQUEST);
|
KPPPConfigurePacket request(PPP_CONFIGURE_REQUEST);
|
||||||
request.SetID(NextID());
|
request.SetID(NextID());
|
||||||
@ -1349,10 +1296,8 @@ IPCP::SendTerminateRequest()
|
|||||||
{
|
{
|
||||||
TRACE("IPCP: SendTerminateRequest() state=%d\n", State());
|
TRACE("IPCP: SendTerminateRequest() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
--fTerminateCounter;
|
--fTerminateCounter;
|
||||||
fNextTimeout = system_time() + kIPCPStateMachineTimeout;
|
fNextTimeout = system_time() + kIPCPStateMachineTimeout;
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
struct mbuf *packet = m_gethdr(MT_DATA);
|
struct mbuf *packet = m_gethdr(MT_DATA);
|
||||||
if(!packet)
|
if(!packet)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ class IPCP : public KPPPProtocol {
|
|||||||
void ReportUpEvent();
|
void ReportUpEvent();
|
||||||
void ReportDownEvent();
|
void ReportDownEvent();
|
||||||
void InitializeRestartCount();
|
void InitializeRestartCount();
|
||||||
void ZeroRestartCount();
|
void ResetRestartCount();
|
||||||
bool SendConfigureRequest();
|
bool SendConfigureRequest();
|
||||||
bool SendConfigureAck(struct mbuf *packet);
|
bool SendConfigureAck(struct mbuf *packet);
|
||||||
bool SendConfigureNak(struct mbuf *packet);
|
bool SendConfigureNak(struct mbuf *packet);
|
||||||
@ -135,8 +135,6 @@ class IPCP : public KPPPProtocol {
|
|||||||
uint8 fRequestID, fTerminateID;
|
uint8 fRequestID, fTerminateID;
|
||||||
// the ID we used for the last configure/terminate request
|
// the ID we used for the last configure/terminate request
|
||||||
bigtime_t fNextTimeout;
|
bigtime_t fNextTimeout;
|
||||||
|
|
||||||
BLocker fLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
// from libkernelppp
|
// from libkernelppp
|
||||||
#include <settings_tools.h>
|
#include <settings_tools.h>
|
||||||
#include <LockerHelper.h>
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@ -185,8 +184,7 @@ ModemDevice::ModemDevice(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
fHandle(-1),
|
fHandle(-1),
|
||||||
fWorkerThread(-1),
|
fWorkerThread(-1),
|
||||||
fOutputBytes(0),
|
fOutputBytes(0),
|
||||||
fState(INITIAL),
|
fState(INITIAL)
|
||||||
fLock("ModemDevice")
|
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
TRACE("ModemDevice: Constructor\n");
|
TRACE("ModemDevice: Constructor\n");
|
||||||
@ -239,8 +237,6 @@ ModemDevice::Up()
|
|||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(IsUp())
|
if(IsUp())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -277,8 +273,6 @@ ModemDevice::Down()
|
|||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fState = TERMINATING;
|
fState = TERMINATING;
|
||||||
|
|
||||||
if(!IsUp()) {
|
if(!IsUp()) {
|
||||||
@ -293,7 +287,6 @@ ModemDevice::Down()
|
|||||||
|
|
||||||
// worker_thread will notice that we are terminating (IsUp() == false)
|
// worker_thread will notice that we are terminating (IsUp() == false)
|
||||||
// ConnectionLost() will be called so we can terminate the connection there.
|
// ConnectionLost() will be called so we can terminate the connection there.
|
||||||
locker.UnlockNow();
|
|
||||||
int32 tmp;
|
int32 tmp;
|
||||||
wait_for_thread(fWorkerThread, &tmp);
|
wait_for_thread(fWorkerThread, &tmp);
|
||||||
|
|
||||||
@ -336,8 +329,6 @@ ModemDevice::CountOutputBytes() const
|
|||||||
void
|
void
|
||||||
ModemDevice::OpenModem()
|
ModemDevice::OpenModem()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(Handle() >= 0)
|
if(Handle() >= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -370,8 +361,6 @@ ModemDevice::OpenModem()
|
|||||||
void
|
void
|
||||||
ModemDevice::CloseModem()
|
ModemDevice::CloseModem()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(Handle() >= 0)
|
if(Handle() >= 0)
|
||||||
close(Handle());
|
close(Handle());
|
||||||
|
|
||||||
@ -382,8 +371,6 @@ ModemDevice::CloseModem()
|
|||||||
void
|
void
|
||||||
ModemDevice::FinishedDialing()
|
ModemDevice::FinishedDialing()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fOutputBytes = 0;
|
fOutputBytes = 0;
|
||||||
fState = OPENED;
|
fState = OPENED;
|
||||||
UpEvent();
|
UpEvent();
|
||||||
@ -393,8 +380,6 @@ ModemDevice::FinishedDialing()
|
|||||||
void
|
void
|
||||||
ModemDevice::FailedDialing()
|
ModemDevice::FailedDialing()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fWorkerThread = -1;
|
fWorkerThread = -1;
|
||||||
fState = INITIAL;
|
fState = INITIAL;
|
||||||
CloseModem();
|
CloseModem();
|
||||||
@ -405,8 +390,6 @@ ModemDevice::FailedDialing()
|
|||||||
void
|
void
|
||||||
ModemDevice::ConnectionLost()
|
ModemDevice::ConnectionLost()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
// switch to command mode and disconnect
|
// switch to command mode and disconnect
|
||||||
fWorkerThread = -1;
|
fWorkerThread = -1;
|
||||||
fOutputBytes = 0;
|
fOutputBytes = 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -77,8 +77,6 @@ class ModemDevice : public KPPPDevice {
|
|||||||
modem_state fState;
|
modem_state fState;
|
||||||
|
|
||||||
ACFCHandler *fACFC;
|
ACFCHandler *fACFC;
|
||||||
|
|
||||||
BLocker fLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -7,8 +7,6 @@
|
|||||||
#include <KPPPConfigurePacket.h>
|
#include <KPPPConfigurePacket.h>
|
||||||
#include <KPPPInterface.h>
|
#include <KPPPInterface.h>
|
||||||
|
|
||||||
#include <LockerHelper.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <core_funcs.h>
|
#include <core_funcs.h>
|
||||||
@ -81,8 +79,7 @@ PAP::PAP(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
fID(system_time() & 0xFF),
|
fID(system_time() & 0xFF),
|
||||||
fMaxRequest(3),
|
fMaxRequest(3),
|
||||||
fRequestID(0),
|
fRequestID(0),
|
||||||
fNextTimeout(0),
|
fNextTimeout(0)
|
||||||
fLock("PAP")
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,14 +104,11 @@ PAP::Up()
|
|||||||
{
|
{
|
||||||
TRACE("PAP: Up() state=%d\n", State());
|
TRACE("PAP: Up() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case INITIAL:
|
case INITIAL:
|
||||||
if(Side() == PPP_LOCAL_SIDE) {
|
if(Side() == PPP_LOCAL_SIDE) {
|
||||||
NewState(REQ_SENT);
|
NewState(REQ_SENT);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendRequest();
|
SendRequest();
|
||||||
} else if(Side() == PPP_PEER_SIDE) {
|
} else if(Side() == PPP_PEER_SIDE) {
|
||||||
NewState(WAITING_FOR_REQ);
|
NewState(WAITING_FOR_REQ);
|
||||||
@ -139,15 +133,12 @@ PAP::Down()
|
|||||||
{
|
{
|
||||||
TRACE("PAP: Down() state=%d\n", State());
|
TRACE("PAP: Down() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(Interface().Phase()) {
|
switch(Interface().Phase()) {
|
||||||
case PPP_DOWN_PHASE:
|
case PPP_DOWN_PHASE:
|
||||||
// interface finished terminating
|
// interface finished terminating
|
||||||
case PPP_ESTABLISHED_PHASE:
|
case PPP_ESTABLISHED_PHASE:
|
||||||
// terminate this NCP individually (block until we finished terminating)
|
// terminate this NCP individually (block until we finished terminating)
|
||||||
NewState(INITIAL);
|
NewState(INITIAL);
|
||||||
locker.UnlockNow();
|
|
||||||
DownEvent();
|
DownEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -233,11 +224,9 @@ PAP::Receive(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
void
|
void
|
||||||
PAP::Pulse()
|
PAP::Pulse()
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
|
||||||
if(fNextTimeout == 0 || fNextTimeout > system_time())
|
if(fNextTimeout == 0 || fNextTimeout > system_time())
|
||||||
return;
|
return;
|
||||||
fNextTimeout = 0;
|
fNextTimeout = 0;
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case REQ_SENT:
|
case REQ_SENT:
|
||||||
@ -290,11 +279,8 @@ PAP::TOGoodEvent()
|
|||||||
{
|
{
|
||||||
TRACE("PAP: TOGoodEvent() state=%d\n", State());
|
TRACE("PAP: TOGoodEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case REQ_SENT:
|
case REQ_SENT:
|
||||||
locker.UnlockNow();
|
|
||||||
SendRequest();
|
SendRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -313,13 +299,10 @@ PAP::TOBadEvent()
|
|||||||
{
|
{
|
||||||
TRACE("PAP: TOBadEvent() state=%d\n", State());
|
TRACE("PAP: TOBadEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case REQ_SENT:
|
case REQ_SENT:
|
||||||
case WAITING_FOR_REQ:
|
case WAITING_FOR_REQ:
|
||||||
NewState(INITIAL);
|
NewState(INITIAL);
|
||||||
locker.UnlockNow();
|
|
||||||
if(State() == REQ_SENT)
|
if(State() == REQ_SENT)
|
||||||
Interface().StateMachine().LocalAuthenticationDenied(
|
Interface().StateMachine().LocalAuthenticationDenied(
|
||||||
Interface().Username());
|
Interface().Username());
|
||||||
@ -341,8 +324,6 @@ PAP::RREvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("PAP: RREvent() state=%d\n", State());
|
TRACE("PAP: RREvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
ppp_lcp_packet *request = mtod(packet, ppp_lcp_packet*);
|
ppp_lcp_packet *request = mtod(packet, ppp_lcp_packet*);
|
||||||
int32 length = ntohs(request->length);
|
int32 length = ntohs(request->length);
|
||||||
uint8 *data = request->data;
|
uint8 *data = request->data;
|
||||||
@ -363,13 +344,11 @@ PAP::RREvent(struct mbuf *packet)
|
|||||||
&& !strncmp(peerUsername, username, *userLength)
|
&& !strncmp(peerUsername, username, *userLength)
|
||||||
&& !strncmp(peerPassword, password, *passwordLength)) {
|
&& !strncmp(peerPassword, password, *passwordLength)) {
|
||||||
NewState(ACCEPTED);
|
NewState(ACCEPTED);
|
||||||
locker.UnlockNow();
|
|
||||||
Interface().StateMachine().PeerAuthenticationAccepted(username);
|
Interface().StateMachine().PeerAuthenticationAccepted(username);
|
||||||
UpEvent();
|
UpEvent();
|
||||||
SendAck(packet);
|
SendAck(packet);
|
||||||
} else {
|
} else {
|
||||||
NewState(INITIAL);
|
NewState(INITIAL);
|
||||||
locker.UnlockNow();
|
|
||||||
Interface().StateMachine().PeerAuthenticationDenied(username);
|
Interface().StateMachine().PeerAuthenticationDenied(username);
|
||||||
UpFailedEvent();
|
UpFailedEvent();
|
||||||
SendNak(packet);
|
SendNak(packet);
|
||||||
@ -382,8 +361,6 @@ PAP::RAEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("PAP: RAEvent() state=%d\n", State());
|
TRACE("PAP: RAEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
||||||
// this packet is not a reply to our request
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
@ -395,7 +372,6 @@ PAP::RAEvent(struct mbuf *packet)
|
|||||||
switch(State()) {
|
switch(State()) {
|
||||||
case REQ_SENT:
|
case REQ_SENT:
|
||||||
NewState(ACCEPTED);
|
NewState(ACCEPTED);
|
||||||
locker.UnlockNow();
|
|
||||||
Interface().StateMachine().LocalAuthenticationAccepted(
|
Interface().StateMachine().LocalAuthenticationAccepted(
|
||||||
Interface().Username());
|
Interface().Username());
|
||||||
UpEvent();
|
UpEvent();
|
||||||
@ -414,8 +390,6 @@ PAP::RNEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("PAP: RNEvent() state=%d\n", State());
|
TRACE("PAP: RNEvent() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
||||||
// this packet is not a reply to our request
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
@ -427,7 +401,6 @@ PAP::RNEvent(struct mbuf *packet)
|
|||||||
switch(State()) {
|
switch(State()) {
|
||||||
case REQ_SENT:
|
case REQ_SENT:
|
||||||
NewState(INITIAL);
|
NewState(INITIAL);
|
||||||
locker.UnlockNow();
|
|
||||||
Interface().StateMachine().LocalAuthenticationDenied(
|
Interface().StateMachine().LocalAuthenticationDenied(
|
||||||
Interface().Username());
|
Interface().Username());
|
||||||
UpFailedEvent();
|
UpFailedEvent();
|
||||||
@ -453,10 +426,8 @@ PAP::SendRequest()
|
|||||||
{
|
{
|
||||||
TRACE("PAP: SendRequest() state=%d\n", State());
|
TRACE("PAP: SendRequest() state=%d\n", State());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
--fRequestCounter;
|
--fRequestCounter;
|
||||||
fNextTimeout = system_time() + kPAPTimeout;
|
fNextTimeout = system_time() + kPAPTimeout;
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
struct mbuf *packet = m_gethdr(MT_DATA);
|
struct mbuf *packet = m_gethdr(MT_DATA);
|
||||||
if(!packet)
|
if(!packet)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -94,8 +94,6 @@ class PAP : public KPPPProtocol {
|
|||||||
uint8 fRequestID;
|
uint8 fRequestID;
|
||||||
// the ID we used for the last configure/terminate request
|
// the ID we used for the last configure/terminate request
|
||||||
bigtime_t fNextTimeout;
|
bigtime_t fNextTimeout;
|
||||||
|
|
||||||
BLocker fLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
// from libkernelppp
|
// from libkernelppp
|
||||||
#include <settings_tools.h>
|
#include <settings_tools.h>
|
||||||
#include <LockerHelper.h>
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@ -51,8 +50,7 @@ PPPoEDevice::PPPoEDevice(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
fServiceName(NULL),
|
fServiceName(NULL),
|
||||||
fAttempts(0),
|
fAttempts(0),
|
||||||
fNextTimeout(0),
|
fNextTimeout(0),
|
||||||
fState(INITIAL),
|
fState(INITIAL)
|
||||||
fLock("PPPoEDevice")
|
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
TRACE("PPPoEDevice: Constructor\n");
|
TRACE("PPPoEDevice: Constructor\n");
|
||||||
@ -81,16 +79,6 @@ PPPoEDevice::PPPoEDevice(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
if(!fEthernetIfnet)
|
if(!fEthernetIfnet)
|
||||||
TRACE("PPPoEDevice::ctor: could not find ethernet interface\n");
|
TRACE("PPPoEDevice::ctor: could not find ethernet interface\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
add_device(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PPPoEDevice::~PPPoEDevice()
|
|
||||||
{
|
|
||||||
TRACE("PPPoEDevice: Destructor\n");
|
|
||||||
|
|
||||||
remove_device(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -110,11 +98,11 @@ PPPoEDevice::Up()
|
|||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(IsUp())
|
if(IsUp())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
add_device(this);
|
||||||
|
|
||||||
fState = INITIAL;
|
fState = INITIAL;
|
||||||
// reset state
|
// reset state
|
||||||
|
|
||||||
@ -154,6 +142,7 @@ PPPoEDevice::Up()
|
|||||||
// check if we are allowed to go up now (user intervention might disallow that)
|
// check if we are allowed to go up now (user intervention might disallow that)
|
||||||
if(fAttempts > 0 && !UpStarted()) {
|
if(fAttempts > 0 && !UpStarted()) {
|
||||||
fAttempts = 0;
|
fAttempts = 0;
|
||||||
|
remove_device(this);
|
||||||
DownEvent();
|
DownEvent();
|
||||||
return true;
|
return true;
|
||||||
// there was no error
|
// there was no error
|
||||||
@ -180,11 +169,11 @@ PPPoEDevice::Down()
|
|||||||
{
|
{
|
||||||
TRACE("PPPoEDevice: Down()\n");
|
TRACE("PPPoEDevice: Down()\n");
|
||||||
|
|
||||||
|
remove_device(this);
|
||||||
|
|
||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fState = INITIAL;
|
fState = INITIAL;
|
||||||
fAttempts = 0;
|
fAttempts = 0;
|
||||||
fNextTimeout = 0;
|
fNextTimeout = 0;
|
||||||
@ -267,8 +256,6 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(!IsUp()) {
|
if(!IsUp()) {
|
||||||
ERROR("PPPoEDevice::Send(): no connection!\n");
|
ERROR("PPPoEDevice::Send(): no connection!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
@ -296,13 +283,12 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
ethernetHeader->ether_type = ETHERTYPE_PPPOE;
|
ethernetHeader->ether_type = ETHERTYPE_PPPOE;
|
||||||
memcpy(ethernetHeader->ether_dhost, fPeer, sizeof(fPeer));
|
memcpy(ethernetHeader->ether_dhost, fPeer, sizeof(fPeer));
|
||||||
|
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
if(!packet || !mtod(packet, pppoe_header*))
|
if(!packet || !mtod(packet, pppoe_header*))
|
||||||
ERROR("PPPoEDevice::Send(): packet is NULL!\n");
|
ERROR("PPPoEDevice::Send(): packet is NULL!\n");
|
||||||
|
|
||||||
if(EthernetIfnet()->output(EthernetIfnet(), packet, &destination, NULL) != B_OK) {
|
if(EthernetIfnet()->output(EthernetIfnet(), packet, &destination, NULL) != B_OK) {
|
||||||
ERROR("PPPoEDevice::Send(): EthernetIfnet()->output() failed!\n");
|
ERROR("PPPoEDevice::Send(): EthernetIfnet()->output() failed!\n");
|
||||||
|
remove_device(this);
|
||||||
DownEvent();
|
DownEvent();
|
||||||
// DownEvent() without DownStarted() indicates connection lost
|
// DownEvent() without DownStarted() indicates connection lost
|
||||||
return PPP_NO_CONNECTION;
|
return PPP_NO_CONNECTION;
|
||||||
@ -354,8 +340,6 @@ PPPoEDevice::Receive(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(IsDown()) {
|
if(IsDown()) {
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@ -476,6 +460,7 @@ PPPoEDevice::Receive(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
fAttempts = 0;
|
fAttempts = 0;
|
||||||
fSessionID = 0;
|
fSessionID = 0;
|
||||||
fNextTimeout = 0;
|
fNextTimeout = 0;
|
||||||
|
remove_device(this);
|
||||||
DownEvent();
|
DownEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -499,8 +484,6 @@ PPPoEDevice::Pulse()
|
|||||||
if(fNextTimeout == 0 || IsUp() || IsDown())
|
if(fNextTimeout == 0 || IsUp() || IsDown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
// check if timed out
|
// check if timed out
|
||||||
if(system_time() >= fNextTimeout) {
|
if(system_time() >= fNextTimeout) {
|
||||||
if(!Up())
|
if(!Up())
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -24,7 +24,6 @@ enum pppoe_state {
|
|||||||
class PPPoEDevice : public KPPPDevice {
|
class PPPoEDevice : public KPPPDevice {
|
||||||
public:
|
public:
|
||||||
PPPoEDevice(KPPPInterface& interface, driver_parameter *settings);
|
PPPoEDevice(KPPPInterface& interface, driver_parameter *settings);
|
||||||
virtual ~PPPoEDevice();
|
|
||||||
|
|
||||||
ifnet *EthernetIfnet() const
|
ifnet *EthernetIfnet() const
|
||||||
{ return fEthernetIfnet; }
|
{ return fEthernetIfnet; }
|
||||||
@ -66,8 +65,6 @@ class PPPoEDevice : public KPPPDevice {
|
|||||||
uint32 fAttempts;
|
uint32 fAttempts;
|
||||||
bigtime_t fNextTimeout;
|
bigtime_t fNextTimeout;
|
||||||
pppoe_state fState;
|
pppoe_state fState;
|
||||||
|
|
||||||
BLocker fLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -106,6 +106,7 @@ add_device(PPPoEDevice *device)
|
|||||||
TRACE("PPPoE: add_device()\n");
|
TRACE("PPPoE: add_device()\n");
|
||||||
|
|
||||||
LockerHelper locker(sLock);
|
LockerHelper locker(sLock);
|
||||||
|
if(!sDevices->HasItem(device))
|
||||||
sDevices->AddItem(device);
|
sDevices->AddItem(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -235,8 +235,6 @@ KPPPInterface::~KPPPInterface()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPInterface: Destructor\n");
|
TRACE("KPPPInterface: Destructor\n");
|
||||||
|
|
||||||
++fDeleteCounter;
|
|
||||||
|
|
||||||
// tell protocols to uninit (remove routes, etc.)
|
// tell protocols to uninit (remove routes, etc.)
|
||||||
KPPPProtocol *protocol = FirstProtocol();
|
KPPPProtocol *protocol = FirstProtocol();
|
||||||
for(; protocol; protocol = protocol->NextProtocol())
|
for(; protocol; protocol = protocol->NextProtocol())
|
||||||
@ -298,22 +296,17 @@ KPPPInterface::~KPPPInterface()
|
|||||||
void
|
void
|
||||||
KPPPInterface::Delete()
|
KPPPInterface::Delete()
|
||||||
{
|
{
|
||||||
if(atomic_add(&fDeleteCounter, 1) > 0)
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
|
if(fDeleteCounter > 0)
|
||||||
return;
|
return;
|
||||||
// only one thread should delete us!
|
// only one thread should delete us!
|
||||||
|
|
||||||
if(fManager)
|
fDeleteCounter = 1;
|
||||||
|
|
||||||
fManager->DeleteInterface(ID());
|
fManager->DeleteInterface(ID());
|
||||||
// This will mark us for deletion.
|
// This will mark us for deletion.
|
||||||
// Any subsequent calls to delete_interface() will do nothing.
|
// Any subsequent calls to delete_interface() will do nothing.
|
||||||
else {
|
|
||||||
// We were not created by the manager.
|
|
||||||
// Spawn a thread that will delete us.
|
|
||||||
thread_id interfaceDeleterThread
|
|
||||||
= spawn_kernel_thread(interface_deleter_thread,
|
|
||||||
"KPPPInterface: interface_deleter_thread", B_NORMAL_PRIORITY, this);
|
|
||||||
resume_thread(interfaceDeleterThread);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -801,6 +794,8 @@ KPPPInterface::RemoveProtocol(KPPPProtocol *protocol)
|
|||||||
int32
|
int32
|
||||||
KPPPInterface::CountProtocols() const
|
KPPPInterface::CountProtocols() const
|
||||||
{
|
{
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
KPPPProtocol *protocol = FirstProtocol();
|
KPPPProtocol *protocol = FirstProtocol();
|
||||||
|
|
||||||
int32 count = 0;
|
int32 count = 0;
|
||||||
@ -815,6 +810,8 @@ KPPPInterface::CountProtocols() const
|
|||||||
KPPPProtocol*
|
KPPPProtocol*
|
||||||
KPPPInterface::ProtocolAt(int32 index) const
|
KPPPInterface::ProtocolAt(int32 index) const
|
||||||
{
|
{
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
KPPPProtocol *protocol = FirstProtocol();
|
KPPPProtocol *protocol = FirstProtocol();
|
||||||
|
|
||||||
int32 currentIndex = 0;
|
int32 currentIndex = 0;
|
||||||
@ -837,6 +834,8 @@ KPPPInterface::ProtocolFor(uint16 protocolNumber, KPPPProtocol *start) const
|
|||||||
{
|
{
|
||||||
TRACE("KPPPInterface: ProtocolFor(%X)\n", protocolNumber);
|
TRACE("KPPPInterface: ProtocolFor(%X)\n", protocolNumber);
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
KPPPProtocol *current = start ? start : FirstProtocol();
|
KPPPProtocol *current = start ? start : FirstProtocol();
|
||||||
|
|
||||||
for(; current; current = current->NextProtocol()) {
|
for(; current; current = current->NextProtocol()) {
|
||||||
@ -898,6 +897,8 @@ KPPPInterface::ChildAt(int32 index) const
|
|||||||
{
|
{
|
||||||
TRACE("KPPPInterface: ChildAt(%ld)\n", index);
|
TRACE("KPPPInterface: ChildAt(%ld)\n", index);
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
KPPPInterface *child = fChildren.ItemAt(index);
|
KPPPInterface *child = fChildren.ItemAt(index);
|
||||||
|
|
||||||
if(child == fChildren.GetDefaultItem())
|
if(child == fChildren.GetDefaultItem())
|
||||||
@ -916,8 +917,6 @@ KPPPInterface::SetAutoReconnect(bool autoReconnect)
|
|||||||
if(Mode() != PPP_CLIENT_MODE)
|
if(Mode() != PPP_CLIENT_MODE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fAutoReconnect = autoReconnect;
|
fAutoReconnect = autoReconnect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,6 +930,8 @@ KPPPInterface::SetConnectOnDemand(bool connectOnDemand)
|
|||||||
|
|
||||||
TRACE("KPPPInterface: SetConnectOnDemand(%s)\n", connectOnDemand ? "true" : "false");
|
TRACE("KPPPInterface: SetConnectOnDemand(%s)\n", connectOnDemand ? "true" : "false");
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
// Only clients support ConnectOnDemand.
|
// Only clients support ConnectOnDemand.
|
||||||
if(Mode() != PPP_CLIENT_MODE) {
|
if(Mode() != PPP_CLIENT_MODE) {
|
||||||
TRACE("KPPPInterface::SetConnectOnDemand(): Wrong mode!\n");
|
TRACE("KPPPInterface::SetConnectOnDemand(): Wrong mode!\n");
|
||||||
@ -939,8 +940,6 @@ KPPPInterface::SetConnectOnDemand(bool connectOnDemand)
|
|||||||
} else if(DoesConnectOnDemand() == connectOnDemand)
|
} else if(DoesConnectOnDemand() == connectOnDemand)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fConnectOnDemand = connectOnDemand;
|
fConnectOnDemand = connectOnDemand;
|
||||||
|
|
||||||
// Do not allow changes when we are disconnected (only main interfaces).
|
// Do not allow changes when we are disconnected (only main interfaces).
|
||||||
@ -972,8 +971,10 @@ void
|
|||||||
KPPPInterface::SetAskBeforeConnecting(bool ask)
|
KPPPInterface::SetAskBeforeConnecting(bool ask)
|
||||||
{
|
{
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
bool old = fAskBeforeConnecting;
|
bool old = fAskBeforeConnecting;
|
||||||
fAskBeforeConnecting = ask;
|
fAskBeforeConnecting = ask;
|
||||||
|
|
||||||
if(old && fAskBeforeConnecting == false && State() == PPP_STARTING_STATE
|
if(old && fAskBeforeConnecting == false && State() == PPP_STARTING_STATE
|
||||||
&& Phase() == PPP_DOWN_PHASE) {
|
&& Phase() == PPP_DOWN_PHASE) {
|
||||||
locker.UnlockNow();
|
locker.UnlockNow();
|
||||||
@ -988,6 +989,8 @@ KPPPInterface::SetPFCOptions(uint8 pfcOptions)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPInterface: SetPFCOptions(0x%X)\n", pfcOptions);
|
TRACE("KPPPInterface: SetPFCOptions(0x%X)\n", pfcOptions);
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
if(PFCOptions() & PPP_FREEZE_PFC_OPTIONS)
|
if(PFCOptions() & PPP_FREEZE_PFC_OPTIONS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1014,13 +1017,8 @@ KPPPInterface::Up()
|
|||||||
if(IsUp())
|
if(IsUp())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Lock needs timeout because destructor could have locked the interface.
|
LockerHelper locker(fLock);
|
||||||
while(fLock.LockWithTimeout(100000) != B_NO_ERROR)
|
|
||||||
if(fDeleteCounter > 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
StateMachine().OpenEvent();
|
StateMachine().OpenEvent();
|
||||||
fLock.Unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1045,6 +1043,8 @@ KPPPInterface::Down()
|
|||||||
|
|
||||||
send_data_with_timeout(fReconnectThread, 0, NULL, 0, 200);
|
send_data_with_timeout(fReconnectThread, 0, NULL, 0, 200);
|
||||||
// tell the reconnect thread to abort its attempt (if it's still waiting)
|
// tell the reconnect thread to abort its attempt (if it's still waiting)
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
StateMachine().CloseEvent();
|
StateMachine().CloseEvent();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1060,13 +1060,7 @@ KPPPInterface::WaitForConnection()
|
|||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Lock needs timeout because destructor could have locked the interface.
|
|
||||||
while(fLock.LockWithTimeout(100000) != B_NO_ERROR)
|
|
||||||
if(fDeleteCounter > 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ReportManager().EnableReports(PPP_CONNECTION_REPORT, find_thread(NULL));
|
ReportManager().EnableReports(PPP_CONNECTION_REPORT, find_thread(NULL));
|
||||||
fLock.Unlock();
|
|
||||||
|
|
||||||
ppp_report_packet report;
|
ppp_report_packet report;
|
||||||
thread_id sender;
|
thread_id sender;
|
||||||
@ -1092,15 +1086,6 @@ KPPPInterface::WaitForConnection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Returns if the interface is connected.
|
|
||||||
bool
|
|
||||||
KPPPInterface::IsUp() const
|
|
||||||
{
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
return Phase() == PPP_ESTABLISHED_PHASE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Loads modules specified in the settings structure.
|
/*! \brief Loads modules specified in the settings structure.
|
||||||
|
|
||||||
\param settings PPP interface description file format settings.
|
\param settings PPP interface description file format settings.
|
||||||
@ -1221,7 +1206,9 @@ KPPPInterface::IsAllowedToSend() const
|
|||||||
|
|
||||||
This brings the interface up if connect-on-demand is enabled and we are not
|
This brings the interface up if connect-on-demand is enabled and we are not
|
||||||
connected. \n
|
connected. \n
|
||||||
PFC encoding is handled here.
|
PFC encoding is handled here. \n
|
||||||
|
NOTE: In order to prevent interface destruction while sending you must either
|
||||||
|
hold a refcount for this interface or make sure it is locked.
|
||||||
|
|
||||||
\param packet The packet.
|
\param packet The packet.
|
||||||
\param protocolNumber The packet's protocol number.
|
\param protocolNumber The packet's protocol number.
|
||||||
@ -1247,6 +1234,8 @@ KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// go up if ConnectOnDemand is enabled and we are disconnected
|
// go up if ConnectOnDemand is enabled and we are disconnected
|
||||||
|
// TODO: our new netstack will simplify ConnectOnDemand handling, so
|
||||||
|
// we do not have to handle it here
|
||||||
if((protocolNumber != PPP_LCP_PROTOCOL && DoesConnectOnDemand()
|
if((protocolNumber != PPP_LCP_PROTOCOL && DoesConnectOnDemand()
|
||||||
&& (Phase() == PPP_DOWN_PHASE
|
&& (Phase() == PPP_DOWN_PHASE
|
||||||
|| Phase() == PPP_ESTABLISHMENT_PHASE)
|
|| Phase() == PPP_ESTABLISHMENT_PHASE)
|
||||||
@ -1303,7 +1292,7 @@ KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
*header = protocolNumber;
|
*header = protocolNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass to device/children
|
// pass to device if we're either not a multilink interface or a child interface
|
||||||
if(!IsMultilink() || Parent()) {
|
if(!IsMultilink() || Parent()) {
|
||||||
// check if packet is too big for device
|
// check if packet is too big for device
|
||||||
uint32 length = packet->m_flags & M_PKTHDR ? (uint32) packet->m_pkthdr.len :
|
uint32 length = packet->m_flags & M_PKTHDR ? (uint32) packet->m_pkthdr.len :
|
||||||
@ -1351,6 +1340,8 @@ KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
if(!packet)
|
if(!packet)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
int32 result = PPP_REJECTED;
|
int32 result = PPP_REJECTED;
|
||||||
// assume we have no handler
|
// assume we have no handler
|
||||||
|
|
||||||
@ -1447,6 +1438,8 @@ KPPPInterface::ReceiveFromDevice(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
KPPPInterface::Pulse()
|
KPPPInterface::Pulse()
|
||||||
{
|
{
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
if(Device())
|
if(Device())
|
||||||
Device()->Pulse();
|
Device()->Pulse();
|
||||||
|
|
||||||
@ -1579,6 +1572,8 @@ KPPPInterface::StackControlEachHandler(uint32 op, void *data)
|
|||||||
|
|
||||||
status_t result = B_BAD_VALUE, tmp;
|
status_t result = B_BAD_VALUE, tmp;
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
KPPPProtocol *protocol = FirstProtocol();
|
KPPPProtocol *protocol = FirstProtocol();
|
||||||
for(; protocol; protocol = protocol->NextProtocol()) {
|
for(; protocol; protocol = protocol->NextProtocol()) {
|
||||||
tmp = protocol->StackControl(op, data);
|
tmp = protocol->StackControl(op, data);
|
||||||
@ -1603,6 +1598,8 @@ KPPPInterface::CalculateInterfaceMTU()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPInterface: CalculateInterfaceMTU()\n");
|
TRACE("KPPPInterface: CalculateInterfaceMTU()\n");
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
fInterfaceMTU = fMRU;
|
fInterfaceMTU = fMRU;
|
||||||
fHeaderLength = 2;
|
fHeaderLength = 2;
|
||||||
|
|
||||||
@ -1631,6 +1628,8 @@ KPPPInterface::CalculateBaudRate()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPInterface: CalculateBaudRate()\n");
|
TRACE("KPPPInterface: CalculateBaudRate()\n");
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
if(!Ifnet())
|
if(!Ifnet())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1652,6 +1651,8 @@ KPPPInterface::Reconnect(uint32 delay)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPInterface: Reconnect(%ld)\n", delay);
|
TRACE("KPPPInterface: Reconnect(%ld)\n", delay);
|
||||||
|
|
||||||
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
if(fReconnectThread != -1)
|
if(fReconnectThread != -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1692,26 +1693,3 @@ reconnect_thread(void *data)
|
|||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------
|
|
||||||
// Function: interface_deleter_thread
|
|
||||||
// ----------------------------------
|
|
||||||
//! Private class.
|
|
||||||
class KPPPInterfaceAccess {
|
|
||||||
public:
|
|
||||||
KPPPInterfaceAccess() {}
|
|
||||||
|
|
||||||
void Delete(KPPPInterface *interface)
|
|
||||||
{ delete interface; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
interface_deleter_thread(void *data)
|
|
||||||
{
|
|
||||||
KPPPInterfaceAccess access;
|
|
||||||
access.Delete((KPPPInterface*) data);
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,8 +19,6 @@
|
|||||||
#include <KPPPLCPExtension.h>
|
#include <KPPPLCPExtension.h>
|
||||||
#include <KPPPOptionHandler.h>
|
#include <KPPPOptionHandler.h>
|
||||||
|
|
||||||
#include <LockerHelper.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <core_funcs.h>
|
#include <core_funcs.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -59,8 +57,6 @@ KPPPLCP::AddOptionHandler(KPPPOptionHandler *optionHandler)
|
|||||||
if(!optionHandler || &optionHandler->Interface() != &Interface())
|
if(!optionHandler || &optionHandler->Interface() != &Interface())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LockerHelper locker(StateMachine().fLock);
|
|
||||||
|
|
||||||
if(Interface().Phase() != PPP_DOWN_PHASE
|
if(Interface().Phase() != PPP_DOWN_PHASE
|
||||||
|| OptionHandlerFor(optionHandler->Type()))
|
|| OptionHandlerFor(optionHandler->Type()))
|
||||||
return false;
|
return false;
|
||||||
@ -78,8 +74,6 @@ KPPPLCP::AddOptionHandler(KPPPOptionHandler *optionHandler)
|
|||||||
bool
|
bool
|
||||||
KPPPLCP::RemoveOptionHandler(KPPPOptionHandler *optionHandler)
|
KPPPLCP::RemoveOptionHandler(KPPPOptionHandler *optionHandler)
|
||||||
{
|
{
|
||||||
LockerHelper locker(StateMachine().fLock);
|
|
||||||
|
|
||||||
if(Interface().Phase() != PPP_DOWN_PHASE)
|
if(Interface().Phase() != PPP_DOWN_PHASE)
|
||||||
return false;
|
return false;
|
||||||
// a running connection may not change
|
// a running connection may not change
|
||||||
@ -138,8 +132,6 @@ KPPPLCP::AddLCPExtension(KPPPLCPExtension *lcpExtension)
|
|||||||
if(!lcpExtension || &lcpExtension->Interface() != &Interface())
|
if(!lcpExtension || &lcpExtension->Interface() != &Interface())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LockerHelper locker(StateMachine().fLock);
|
|
||||||
|
|
||||||
if(Interface().Phase() != PPP_DOWN_PHASE)
|
if(Interface().Phase() != PPP_DOWN_PHASE)
|
||||||
return false;
|
return false;
|
||||||
// a running connection may not change
|
// a running connection may not change
|
||||||
@ -155,8 +147,6 @@ KPPPLCP::AddLCPExtension(KPPPLCPExtension *lcpExtension)
|
|||||||
bool
|
bool
|
||||||
KPPPLCP::RemoveLCPExtension(KPPPLCPExtension *lcpExtension)
|
KPPPLCP::RemoveLCPExtension(KPPPLCPExtension *lcpExtension)
|
||||||
{
|
{
|
||||||
LockerHelper locker(StateMachine().fLock);
|
|
||||||
|
|
||||||
if(Interface().Phase() != PPP_DOWN_PHASE)
|
if(Interface().Phase() != PPP_DOWN_PHASE)
|
||||||
return false;
|
return false;
|
||||||
// a running connection may not change
|
// a running connection may not change
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Waldemar Kornewald <wkornew@gmx.net>
|
* Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,7 +19,6 @@
|
|||||||
#include <KPPPLCPExtension.h>
|
#include <KPPPLCPExtension.h>
|
||||||
#include <KPPPOptionHandler.h>
|
#include <KPPPOptionHandler.h>
|
||||||
|
|
||||||
#include <LockerHelper.h>
|
|
||||||
#include <KPPPUtils.h>
|
#include <KPPPUtils.h>
|
||||||
|
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
@ -150,8 +149,6 @@ KPPPStateMachine::Reconfigure()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: Reconfigure() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: Reconfigure() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(State() < PPP_REQ_SENT_STATE)
|
if(State() < PPP_REQ_SENT_STATE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -162,8 +159,6 @@ KPPPStateMachine::Reconfigure()
|
|||||||
DownProtocols();
|
DownProtocols();
|
||||||
ResetLCPHandlers();
|
ResetLCPHandlers();
|
||||||
|
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
return SendConfigureRequest();
|
return SendConfigureRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,8 +230,6 @@ KPPPStateMachine::LocalAuthenticationRequested()
|
|||||||
TRACE("KPPPSM: LocalAuthenticationRequested() state=%d phase=%d\n",
|
TRACE("KPPPSM: LocalAuthenticationRequested() state=%d phase=%d\n",
|
||||||
State(), Phase());
|
State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fLastConnectionReportCode = PPP_REPORT_AUTHENTICATION_REQUESTED;
|
fLastConnectionReportCode = PPP_REPORT_AUTHENTICATION_REQUESTED;
|
||||||
Interface().Report(PPP_CONNECTION_REPORT,
|
Interface().Report(PPP_CONNECTION_REPORT,
|
||||||
PPP_REPORT_AUTHENTICATION_REQUESTED, &fInterface.fID,
|
PPP_REPORT_AUTHENTICATION_REQUESTED, &fInterface.fID,
|
||||||
@ -260,8 +253,6 @@ KPPPStateMachine::LocalAuthenticationAccepted(const char *name)
|
|||||||
TRACE("KPPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n",
|
TRACE("KPPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n",
|
||||||
State(), Phase());
|
State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fLocalAuthenticationStatus = PPP_AUTHENTICATION_SUCCESSFUL;
|
fLocalAuthenticationStatus = PPP_AUTHENTICATION_SUCCESSFUL;
|
||||||
free(fLocalAuthenticationName);
|
free(fLocalAuthenticationName);
|
||||||
if(name)
|
if(name)
|
||||||
@ -282,8 +273,6 @@ KPPPStateMachine::LocalAuthenticationDenied(const char *name)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: LocalAuthenticationDenied() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: LocalAuthenticationDenied() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fLocalAuthenticationStatus = PPP_AUTHENTICATION_FAILED;
|
fLocalAuthenticationStatus = PPP_AUTHENTICATION_FAILED;
|
||||||
free(fLocalAuthenticationName);
|
free(fLocalAuthenticationName);
|
||||||
if(name)
|
if(name)
|
||||||
@ -302,8 +291,6 @@ KPPPStateMachine::PeerAuthenticationRequested()
|
|||||||
TRACE("KPPPSM: PeerAuthenticationRequested() state=%d phase=%d\n",
|
TRACE("KPPPSM: PeerAuthenticationRequested() state=%d phase=%d\n",
|
||||||
State(), Phase());
|
State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fLastConnectionReportCode = PPP_REPORT_AUTHENTICATION_REQUESTED;
|
fLastConnectionReportCode = PPP_REPORT_AUTHENTICATION_REQUESTED;
|
||||||
Interface().Report(PPP_CONNECTION_REPORT,
|
Interface().Report(PPP_CONNECTION_REPORT,
|
||||||
PPP_REPORT_AUTHENTICATION_REQUESTED, &fInterface.fID,
|
PPP_REPORT_AUTHENTICATION_REQUESTED, &fInterface.fID,
|
||||||
@ -327,8 +314,6 @@ KPPPStateMachine::PeerAuthenticationAccepted(const char *name)
|
|||||||
TRACE("KPPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n",
|
TRACE("KPPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n",
|
||||||
State(), Phase());
|
State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fPeerAuthenticationStatus = PPP_AUTHENTICATION_SUCCESSFUL;
|
fPeerAuthenticationStatus = PPP_AUTHENTICATION_SUCCESSFUL;
|
||||||
free(fPeerAuthenticationName);
|
free(fPeerAuthenticationName);
|
||||||
if(name)
|
if(name)
|
||||||
@ -349,8 +334,6 @@ KPPPStateMachine::PeerAuthenticationDenied(const char *name)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: PeerAuthenticationDenied() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: PeerAuthenticationDenied() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
fPeerAuthenticationStatus = PPP_AUTHENTICATION_FAILED;
|
fPeerAuthenticationStatus = PPP_AUTHENTICATION_FAILED;
|
||||||
free(fPeerAuthenticationName);
|
free(fPeerAuthenticationName);
|
||||||
if(name)
|
if(name)
|
||||||
@ -381,8 +364,6 @@ KPPPStateMachine::UpEvent(KPPPInterface& interface)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: UpEvent(interface) state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: UpEvent(interface) state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(Phase() <= PPP_TERMINATION_PHASE) {
|
if(Phase() <= PPP_TERMINATION_PHASE) {
|
||||||
interface.StateMachine().CloseEvent();
|
interface.StateMachine().CloseEvent();
|
||||||
return;
|
return;
|
||||||
@ -393,7 +374,6 @@ KPPPStateMachine::UpEvent(KPPPInterface& interface)
|
|||||||
if(Phase() == PPP_ESTABLISHMENT_PHASE) {
|
if(Phase() == PPP_ESTABLISHMENT_PHASE) {
|
||||||
// this is the first interface that went up
|
// this is the first interface that went up
|
||||||
Interface().SetMRU(interface.MRU());
|
Interface().SetMRU(interface.MRU());
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerUp();
|
ThisLayerUp();
|
||||||
} else if(Interface().MRU() > interface.MRU())
|
} else if(Interface().MRU() > interface.MRU())
|
||||||
Interface().SetMRU(interface.MRU());
|
Interface().SetMRU(interface.MRU());
|
||||||
@ -409,8 +389,6 @@ KPPPStateMachine::DownEvent(KPPPInterface& interface)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: DownEvent(interface) state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: DownEvent(interface) state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
uint32 MRU = 0;
|
uint32 MRU = 0;
|
||||||
// the new MRU
|
// the new MRU
|
||||||
|
|
||||||
@ -439,11 +417,9 @@ KPPPStateMachine::DownEvent(KPPPInterface& interface)
|
|||||||
else
|
else
|
||||||
Interface().SetMRU(MRU);
|
Interface().SetMRU(MRU);
|
||||||
|
|
||||||
if(count == 0) {
|
if(count == 0)
|
||||||
locker.UnlockNow();
|
|
||||||
DownEvent();
|
DownEvent();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -484,8 +460,6 @@ KPPPStateMachine::UpEvent(KPPPProtocol *protocol)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: UpEvent(protocol) state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: UpEvent(protocol) state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(Phase() >= PPP_ESTABLISHMENT_PHASE)
|
if(Phase() >= PPP_ESTABLISHMENT_PHASE)
|
||||||
BringProtocolsUp();
|
BringProtocolsUp();
|
||||||
}
|
}
|
||||||
@ -516,8 +490,6 @@ KPPPStateMachine::TLSNotify()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: TLSNotify() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: TLSNotify() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(State() == PPP_STARTING_STATE) {
|
if(State() == PPP_STARTING_STATE) {
|
||||||
if(Phase() == PPP_DOWN_PHASE)
|
if(Phase() == PPP_DOWN_PHASE)
|
||||||
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
||||||
@ -542,8 +514,6 @@ KPPPStateMachine::TLFNotify()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: TLFNotify() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: TLFNotify() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
// tell DownEvent() that it may create a connection-lost-report
|
// tell DownEvent() that it may create a connection-lost-report
|
||||||
|
|
||||||
@ -557,8 +527,6 @@ KPPPStateMachine::UpFailedEvent()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: UpFailedEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: UpFailedEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
fLastConnectionReportCode = PPP_REPORT_DEVICE_UP_FAILED;
|
fLastConnectionReportCode = PPP_REPORT_DEVICE_UP_FAILED;
|
||||||
@ -587,8 +555,6 @@ KPPPStateMachine::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.
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(!Interface().Device() || !Interface().Device()->IsUp())
|
if(!Interface().Device() || !Interface().Device()->IsUp())
|
||||||
return;
|
return;
|
||||||
// it is not our device that went up...
|
// it is not our device that went up...
|
||||||
@ -603,7 +569,6 @@ KPPPStateMachine::UpEvent()
|
|||||||
// connection, so this is an illegal event
|
// connection, so this is an illegal event
|
||||||
IllegalEvent(PPP_UP_EVENT);
|
IllegalEvent(PPP_UP_EVENT);
|
||||||
NewState(PPP_CLOSED_STATE);
|
NewState(PPP_CLOSED_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -612,7 +577,6 @@ KPPPStateMachine::UpEvent()
|
|||||||
// TODO: handle server-up! (maybe already done correctly)
|
// TODO: handle server-up! (maybe already done correctly)
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -624,14 +588,12 @@ KPPPStateMachine::UpEvent()
|
|||||||
// to go up
|
// to go up
|
||||||
IllegalEvent(PPP_UP_EVENT);
|
IllegalEvent(PPP_UP_EVENT);
|
||||||
NewState(PPP_CLOSED_STATE);
|
NewState(PPP_CLOSED_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -651,8 +613,6 @@ KPPPStateMachine::DownEvent()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: DownEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: DownEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(Interface().Device() && Interface().Device()->IsUp())
|
if(Interface().Device() && Interface().Device()->IsUp())
|
||||||
return;
|
return;
|
||||||
// it is not our device that went down...
|
// it is not our device that went down...
|
||||||
@ -753,8 +713,6 @@ KPPPStateMachine::OpenEvent()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: OpenEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: OpenEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
// reset all handlers
|
// reset all handlers
|
||||||
if(Phase() != PPP_ESTABLISHED_PHASE) {
|
if(Phase() != PPP_ESTABLISHED_PHASE) {
|
||||||
DownProtocols();
|
DownProtocols();
|
||||||
@ -777,10 +735,8 @@ KPPPStateMachine::OpenEvent()
|
|||||||
} else
|
} else
|
||||||
NewState(PPP_STARTING_STATE);
|
NewState(PPP_STARTING_STATE);
|
||||||
|
|
||||||
if(Interface().fAskBeforeConnecting == false) {
|
if(Interface().fAskBeforeConnecting == false)
|
||||||
locker.UnlockNow();
|
|
||||||
ContinueOpenEvent();
|
ContinueOpenEvent();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_CLOSED_STATE:
|
case PPP_CLOSED_STATE:
|
||||||
@ -792,7 +748,6 @@ KPPPStateMachine::OpenEvent()
|
|||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -812,7 +767,6 @@ KPPPStateMachine::ContinueOpenEvent()
|
|||||||
TRACE("KPPPSM: ContinueOpenEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: ContinueOpenEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
if(Interface().IsMultilink() && !Interface().Parent()) {
|
if(Interface().IsMultilink() && !Interface().Parent()) {
|
||||||
LockerHelper locker(fLock);
|
|
||||||
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
||||||
for(int32 index = 0; index < Interface().CountChildren(); index++)
|
for(int32 index = 0; index < Interface().CountChildren(); index++)
|
||||||
if(Interface().ChildAt(index)->Mode() == Interface().Mode())
|
if(Interface().ChildAt(index)->Mode() == Interface().Mode())
|
||||||
@ -827,8 +781,6 @@ KPPPStateMachine::CloseEvent()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: CloseEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: CloseEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(Interface().IsMultilink() && !Interface().Parent()) {
|
if(Interface().IsMultilink() && !Interface().Parent()) {
|
||||||
NewState(PPP_INITIAL_STATE);
|
NewState(PPP_INITIAL_STATE);
|
||||||
|
|
||||||
@ -852,7 +804,6 @@ KPPPStateMachine::CloseEvent()
|
|||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
// indicates to handlers that we are terminating
|
// indicates to handlers that we are terminating
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
if(State() == PPP_OPENED_STATE)
|
if(State() == PPP_OPENED_STATE)
|
||||||
ThisLayerDown();
|
ThisLayerDown();
|
||||||
SendTerminateRequest();
|
SendTerminateRequest();
|
||||||
@ -868,7 +819,6 @@ KPPPStateMachine::CloseEvent()
|
|||||||
NewPhase(PPP_DOWN_PHASE);
|
NewPhase(PPP_DOWN_PHASE);
|
||||||
// this says the following DownEvent() was not caused by
|
// this says the following DownEvent() was not caused by
|
||||||
// a connection fault
|
// a connection fault
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -893,12 +843,9 @@ KPPPStateMachine::TOGoodEvent()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: TOGoodEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: TOGoodEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
case PPP_STOPPING_STATE:
|
case PPP_STOPPING_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateRequest();
|
SendTerminateRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -907,7 +854,6 @@ KPPPStateMachine::TOGoodEvent()
|
|||||||
|
|
||||||
case PPP_REQ_SENT_STATE:
|
case PPP_REQ_SENT_STATE:
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -923,13 +869,10 @@ KPPPStateMachine::TOBadEvent()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: TOBadEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: TOBadEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
NewState(PPP_CLOSED_STATE);
|
NewState(PPP_CLOSED_STATE);
|
||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -939,7 +882,6 @@ KPPPStateMachine::TOBadEvent()
|
|||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
NewState(PPP_STOPPED_STATE);
|
NewState(PPP_STOPPED_STATE);
|
||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -955,8 +897,6 @@ KPPPStateMachine::RCRGoodEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: RCRGoodEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: RCRGoodEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
@ -965,7 +905,6 @@ KPPPStateMachine::RCRGoodEvent(struct mbuf *packet)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_CLOSED_STATE:
|
case PPP_CLOSED_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateAck();
|
SendTerminateAck();
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
break;
|
break;
|
||||||
@ -980,13 +919,11 @@ KPPPStateMachine::RCRGoodEvent(struct mbuf *packet)
|
|||||||
NewState(PPP_ACK_SENT_STATE);
|
NewState(PPP_ACK_SENT_STATE);
|
||||||
|
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureAck(packet);
|
SendConfigureAck(packet);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
NewState(PPP_OPENED_STATE);
|
NewState(PPP_OPENED_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureAck(packet);
|
SendConfigureAck(packet);
|
||||||
ThisLayerUp();
|
ThisLayerUp();
|
||||||
break;
|
break;
|
||||||
@ -995,7 +932,6 @@ KPPPStateMachine::RCRGoodEvent(struct mbuf *packet)
|
|||||||
NewState(PPP_ACK_SENT_STATE);
|
NewState(PPP_ACK_SENT_STATE);
|
||||||
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
||||||
// indicates to handlers that we are reconfiguring
|
// indicates to handlers that we are reconfiguring
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerDown();
|
ThisLayerDown();
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
SendConfigureAck(packet);
|
SendConfigureAck(packet);
|
||||||
@ -1013,8 +949,6 @@ KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: RCRBadEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: RCRBadEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
@ -1022,7 +956,6 @@ KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_CLOSED_STATE:
|
case PPP_CLOSED_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateAck();
|
SendTerminateAck();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1035,7 +968,6 @@ KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
|||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
||||||
// indicates to handlers that we are reconfiguring
|
// indicates to handlers that we are reconfiguring
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerDown();
|
ThisLayerDown();
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
|
|
||||||
@ -1046,7 +978,6 @@ KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
|||||||
|
|
||||||
case PPP_REQ_SENT_STATE:
|
case PPP_REQ_SENT_STATE:
|
||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
if(nak && ntohs(mtod(nak, ppp_lcp_packet*)->length) > 3)
|
if(nak && ntohs(mtod(nak, ppp_lcp_packet*)->length) > 3)
|
||||||
SendConfigureNak(nak);
|
SendConfigureNak(nak);
|
||||||
else if(reject && ntohs(mtod(reject, ppp_lcp_packet*)->length) > 3)
|
else if(reject && ntohs(mtod(reject, ppp_lcp_packet*)->length) > 3)
|
||||||
@ -1071,8 +1002,6 @@ KPPPStateMachine::RCAEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: RCAEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: RCAEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
||||||
// this packet is not a reply to our request
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
@ -1089,7 +1018,6 @@ KPPPStateMachine::RCAEvent(struct mbuf *packet)
|
|||||||
optionHandler = LCP().OptionHandlerAt(index);
|
optionHandler = LCP().OptionHandlerAt(index);
|
||||||
if(optionHandler->ParseAck(ack) != B_OK) {
|
if(optionHandler->ParseAck(ack) != B_OK) {
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
locker.UnlockNow();
|
|
||||||
CloseEvent();
|
CloseEvent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1103,7 +1031,6 @@ KPPPStateMachine::RCAEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_CLOSED_STATE:
|
case PPP_CLOSED_STATE:
|
||||||
case PPP_STOPPED_STATE:
|
case PPP_STOPPED_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateAck();
|
SendTerminateAck();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1114,14 +1041,12 @@ KPPPStateMachine::RCAEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_ACK_SENT_STATE:
|
case PPP_ACK_SENT_STATE:
|
||||||
NewState(PPP_OPENED_STATE);
|
NewState(PPP_OPENED_STATE);
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerUp();
|
ThisLayerUp();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1129,7 +1054,6 @@ KPPPStateMachine::RCAEvent(struct mbuf *packet)
|
|||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
||||||
// indicates to handlers that we are reconfiguring
|
// indicates to handlers that we are reconfiguring
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerDown();
|
ThisLayerDown();
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
@ -1148,8 +1072,6 @@ KPPPStateMachine::RCNEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: RCNEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: RCNEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
if(fRequestID != mtod(packet, ppp_lcp_packet*)->id) {
|
||||||
// this packet is not a reply to our request
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
@ -1168,14 +1090,12 @@ KPPPStateMachine::RCNEvent(struct mbuf *packet)
|
|||||||
if(nak_reject.Code() == PPP_CONFIGURE_NAK) {
|
if(nak_reject.Code() == PPP_CONFIGURE_NAK) {
|
||||||
if(optionHandler->ParseNak(nak_reject) != B_OK) {
|
if(optionHandler->ParseNak(nak_reject) != B_OK) {
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
locker.UnlockNow();
|
|
||||||
CloseEvent();
|
CloseEvent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if(nak_reject.Code() == PPP_CONFIGURE_REJECT) {
|
} else if(nak_reject.Code() == PPP_CONFIGURE_REJECT) {
|
||||||
if(optionHandler->ParseReject(nak_reject) != B_OK) {
|
if(optionHandler->ParseReject(nak_reject) != B_OK) {
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
locker.UnlockNow();
|
|
||||||
CloseEvent();
|
CloseEvent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1190,7 +1110,6 @@ KPPPStateMachine::RCNEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_CLOSED_STATE:
|
case PPP_CLOSED_STATE:
|
||||||
case PPP_STOPPED_STATE:
|
case PPP_STOPPED_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateAck();
|
SendTerminateAck();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1201,7 +1120,6 @@ KPPPStateMachine::RCNEvent(struct mbuf *packet)
|
|||||||
case PPP_ACK_RCVD_STATE:
|
case PPP_ACK_RCVD_STATE:
|
||||||
if(State() == PPP_ACK_RCVD_STATE)
|
if(State() == PPP_ACK_RCVD_STATE)
|
||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1209,7 +1127,6 @@ KPPPStateMachine::RCNEvent(struct mbuf *packet)
|
|||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
||||||
// indicates to handlers that we are reconfiguring
|
// indicates to handlers that we are reconfiguring
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerDown();
|
ThisLayerDown();
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
@ -1228,8 +1145,6 @@ KPPPStateMachine::RTREvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: RTREvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: RTREvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
// we should not use the same ID as the peer
|
// we should not use the same ID as the peer
|
||||||
if(fID == mtod(packet, ppp_lcp_packet*)->id)
|
if(fID == mtod(packet, ppp_lcp_packet*)->id)
|
||||||
fID -= 128;
|
fID -= 128;
|
||||||
@ -1249,7 +1164,6 @@ KPPPStateMachine::RTREvent(struct mbuf *packet)
|
|||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
// indicates to handlers that we are terminating
|
// indicates to handlers that we are terminating
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateAck(packet);
|
SendTerminateAck(packet);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1258,7 +1172,6 @@ KPPPStateMachine::RTREvent(struct mbuf *packet)
|
|||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
// indicates to handlers that we are terminating
|
// indicates to handlers that we are terminating
|
||||||
ZeroRestartCount();
|
ZeroRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerDown();
|
ThisLayerDown();
|
||||||
SendTerminateAck(packet);
|
SendTerminateAck(packet);
|
||||||
break;
|
break;
|
||||||
@ -1266,7 +1179,6 @@ KPPPStateMachine::RTREvent(struct mbuf *packet)
|
|||||||
default:
|
default:
|
||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
// indicates to handlers that we are terminating
|
// indicates to handlers that we are terminating
|
||||||
locker.UnlockNow();
|
|
||||||
SendTerminateAck(packet);
|
SendTerminateAck(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1278,8 +1190,6 @@ KPPPStateMachine::RTAEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: RTAEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: RTAEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(fTerminateID != mtod(packet, ppp_lcp_packet*)->id) {
|
if(fTerminateID != mtod(packet, ppp_lcp_packet*)->id) {
|
||||||
// this packet is not a reply to our request
|
// this packet is not a reply to our request
|
||||||
|
|
||||||
@ -1297,13 +1207,11 @@ KPPPStateMachine::RTAEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
NewState(PPP_CLOSED_STATE);
|
NewState(PPP_CLOSED_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPP_STOPPING_STATE:
|
case PPP_STOPPING_STATE:
|
||||||
NewState(PPP_STOPPED_STATE);
|
NewState(PPP_STOPPED_STATE);
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1315,7 +1223,6 @@ KPPPStateMachine::RTAEvent(struct mbuf *packet)
|
|||||||
NewState(PPP_REQ_SENT_STATE);
|
NewState(PPP_REQ_SENT_STATE);
|
||||||
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
NewPhase(PPP_ESTABLISHMENT_PHASE);
|
||||||
// indicates to handlers that we are reconfiguring
|
// indicates to handlers that we are reconfiguring
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerDown();
|
ThisLayerDown();
|
||||||
SendConfigureRequest();
|
SendConfigureRequest();
|
||||||
break;
|
break;
|
||||||
@ -1335,8 +1242,6 @@ KPPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber,
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: RUCEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: RUCEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
@ -1345,7 +1250,6 @@ KPPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
locker.UnlockNow();
|
|
||||||
SendCodeReject(packet, protocolNumber, code);
|
SendCodeReject(packet, protocolNumber, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1359,7 +1263,6 @@ KPPPStateMachine::RXJGoodEvent(struct mbuf *packet)
|
|||||||
|
|
||||||
// This method does not m_freem(packet) because the acceptable rejects are
|
// This method does not m_freem(packet) because the acceptable rejects are
|
||||||
// also passed to the parent. RXJEvent() will m_freem(packet) when needed.
|
// also passed to the parent. RXJEvent() will m_freem(packet) when needed.
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
@ -1383,8 +1286,6 @@ KPPPStateMachine::RXJBadEvent(struct mbuf *packet)
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: RXJBadEvent() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: RXJBadEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_INITIAL_STATE:
|
case PPP_INITIAL_STATE:
|
||||||
case PPP_STARTING_STATE:
|
case PPP_STARTING_STATE:
|
||||||
@ -1395,7 +1296,6 @@ KPPPStateMachine::RXJBadEvent(struct mbuf *packet)
|
|||||||
NewState(PPP_CLOSED_STATE);
|
NewState(PPP_CLOSED_STATE);
|
||||||
|
|
||||||
case PPP_CLOSED_STATE:
|
case PPP_CLOSED_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1408,7 +1308,6 @@ KPPPStateMachine::RXJBadEvent(struct mbuf *packet)
|
|||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
|
|
||||||
case PPP_STOPPED_STATE:
|
case PPP_STOPPED_STATE:
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerFinished();
|
ThisLayerFinished();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1417,7 +1316,6 @@ KPPPStateMachine::RXJBadEvent(struct mbuf *packet)
|
|||||||
NewPhase(PPP_TERMINATION_PHASE);
|
NewPhase(PPP_TERMINATION_PHASE);
|
||||||
// indicates to handlers that we are terminating
|
// indicates to handlers that we are terminating
|
||||||
InitializeRestartCount();
|
InitializeRestartCount();
|
||||||
locker.UnlockNow();
|
|
||||||
ThisLayerDown();
|
ThisLayerDown();
|
||||||
SendTerminateRequest();
|
SendTerminateRequest();
|
||||||
break;
|
break;
|
||||||
@ -1469,15 +1367,10 @@ KPPPStateMachine::TimerEvent()
|
|||||||
TRACE("KPPPSM: TimerEvent()\n");
|
TRACE("KPPPSM: TimerEvent()\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We might cause a dead-lock. Thus, abort if we cannot get the lock.
|
if(fNextTimeout == 0 || fNextTimeout > system_time())
|
||||||
if(fLock.LockWithTimeout(100000) != B_OK)
|
|
||||||
return;
|
return;
|
||||||
if(fNextTimeout == 0 || fNextTimeout > system_time()) {
|
|
||||||
fLock.Unlock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fNextTimeout = 0;
|
fNextTimeout = 0;
|
||||||
fLock.Unlock();
|
|
||||||
|
|
||||||
switch(State()) {
|
switch(State()) {
|
||||||
case PPP_CLOSING_STATE:
|
case PPP_CLOSING_STATE:
|
||||||
@ -1669,8 +1562,6 @@ KPPPStateMachine::ThisLayerUp()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: ThisLayerUp() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: ThisLayerUp() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
// We begin with authentication phase and wait until each phase is done.
|
// We begin with authentication phase and wait until each phase is done.
|
||||||
// We stop when we reach established phase.
|
// We stop when we reach established phase.
|
||||||
|
|
||||||
@ -1680,8 +1571,6 @@ KPPPStateMachine::ThisLayerUp()
|
|||||||
|
|
||||||
NewPhase(PPP_AUTHENTICATION_PHASE);
|
NewPhase(PPP_AUTHENTICATION_PHASE);
|
||||||
|
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
BringProtocolsUp();
|
BringProtocolsUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1739,10 +1628,8 @@ KPPPStateMachine::SendConfigureRequest()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: SendConfigureRequest() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: SendConfigureRequest() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
--fRequestCounter;
|
--fRequestCounter;
|
||||||
fNextTimeout = system_time() + kPPPStateMachineTimeout;
|
fNextTimeout = system_time() + kPPPStateMachineTimeout;
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
KPPPConfigurePacket request(PPP_CONFIGURE_REQUEST);
|
KPPPConfigurePacket request(PPP_CONFIGURE_REQUEST);
|
||||||
request.SetID(NextID());
|
request.SetID(NextID());
|
||||||
@ -1811,10 +1698,8 @@ KPPPStateMachine::SendTerminateRequest()
|
|||||||
{
|
{
|
||||||
TRACE("KPPPSM: SendTerminateRequest() state=%d phase=%d\n", State(), Phase());
|
TRACE("KPPPSM: SendTerminateRequest() state=%d phase=%d\n", State(), Phase());
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
--fTerminateCounter;
|
--fTerminateCounter;
|
||||||
fNextTimeout = system_time() + kPPPStateMachineTimeout;
|
fNextTimeout = system_time() + kPPPStateMachineTimeout;
|
||||||
locker.UnlockNow();
|
|
||||||
|
|
||||||
struct mbuf *packet = m_gethdr(MT_DATA);
|
struct mbuf *packet = m_gethdr(MT_DATA);
|
||||||
if(!packet)
|
if(!packet)
|
||||||
@ -1939,8 +1824,6 @@ KPPPStateMachine::BringProtocolsUp()
|
|||||||
if(BringPhaseUp() > 0)
|
if(BringPhaseUp() > 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
if(Phase() < PPP_AUTHENTICATION_PHASE)
|
if(Phase() < PPP_AUTHENTICATION_PHASE)
|
||||||
return;
|
return;
|
||||||
// phase was changed by another event
|
// phase was changed by another event
|
||||||
@ -1961,8 +1844,6 @@ KPPPStateMachine::BringPhaseUp()
|
|||||||
// Servers do not need to bring all protocols up.
|
// Servers do not need to bring all protocols up.
|
||||||
// The client specifies which protocols he wants to go up.
|
// The client specifies which protocols he wants to go up.
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
|
||||||
|
|
||||||
// check for phase change
|
// check for phase change
|
||||||
if(Phase() < PPP_AUTHENTICATION_PHASE)
|
if(Phase() < PPP_AUTHENTICATION_PHASE)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2005, Haiku Inc.
|
* Copyright 2003-2006, Haiku Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -42,7 +42,6 @@ struct ppp_interface_entry;
|
|||||||
class KPPPInterface : public KPPPLayer {
|
class KPPPInterface : public KPPPLayer {
|
||||||
friend class PPPManager;
|
friend class PPPManager;
|
||||||
friend class KPPPStateMachine;
|
friend class KPPPStateMachine;
|
||||||
friend class KPPPInterfaceAccess;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Copies are not allowed.
|
//! Copies are not allowed.
|
||||||
@ -201,7 +200,9 @@ class KPPPInterface : public KPPPLayer {
|
|||||||
// in server mode Up() listens for an incoming connection
|
// in server mode Up() listens for an incoming connection
|
||||||
virtual bool Down();
|
virtual bool Down();
|
||||||
bool WaitForConnection();
|
bool WaitForConnection();
|
||||||
bool IsUp() const;
|
//! Returns if the interface is connected.
|
||||||
|
bool IsUp() const
|
||||||
|
{ return Phase() == PPP_ESTABLISHED_PHASE; }
|
||||||
|
|
||||||
//! Returns interface's report manager.
|
//! Returns interface's report manager.
|
||||||
KPPPReportManager& ReportManager()
|
KPPPReportManager& ReportManager()
|
||||||
|
Loading…
Reference in New Issue
Block a user