DialOnDemand will be handled differently. Instead of setting it manually in the prefs we have one default interface. Still not finished.
Moved ppp_up code to KPPPManager. Experimenting with IPCP DialOnDemand support. Many changes I do not remember. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10117 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
@@ -110,12 +108,12 @@ pulse_timer(void *data)
|
|||||||
|
|
||||||
|
|
||||||
PPPManager::PPPManager()
|
PPPManager::PPPManager()
|
||||||
: fReportManager(fReportLock),
|
: fLock("PPPManager"),
|
||||||
|
fReportLock("PPPManagerReportLock"),
|
||||||
|
fReportManager(fReportLock),
|
||||||
fNextID(1)
|
fNextID(1)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: Constructor\n");
|
||||||
dprintf("PPPManager: Constructor\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fDeleterThread = spawn_kernel_thread(deleter_thread, "PPPManager: deleter_thread",
|
fDeleterThread = spawn_kernel_thread(deleter_thread, "PPPManager: deleter_thread",
|
||||||
B_NORMAL_PRIORITY, this);
|
B_NORMAL_PRIORITY, this);
|
||||||
@@ -126,9 +124,7 @@ PPPManager::PPPManager()
|
|||||||
|
|
||||||
PPPManager::~PPPManager()
|
PPPManager::~PPPManager()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: Destructor\n");
|
||||||
dprintf("PPPManager: Destructor\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32 tmp;
|
int32 tmp;
|
||||||
send_data(fDeleterThread, 0, NULL, 0);
|
send_data(fDeleterThread, 0, NULL, 0);
|
||||||
@@ -140,25 +136,25 @@ PPPManager::~PPPManager()
|
|||||||
ppp_interface_entry *entry;
|
ppp_interface_entry *entry;
|
||||||
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
||||||
entry = fEntries.ItemAt(index);
|
entry = fEntries.ItemAt(index);
|
||||||
if(entry)
|
if(entry) {
|
||||||
|
free(entry->name);
|
||||||
delete entry->interface;
|
delete entry->interface;
|
||||||
delete entry;
|
delete entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
PPPManager::Stop(ifnet *ifp)
|
PPPManager::Stop(ifnet *ifp)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: Stop(%s)\n", ifp ? ifp->if_name : "Unknown");
|
||||||
dprintf("PPPManager: Stop(%s)\n", ifp ? ifp->if_name : "Unknown");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
ppp_interface_entry *entry = EntryFor(ifp);
|
ppp_interface_entry *entry = EntryFor(ifp);
|
||||||
if(!entry) {
|
if(!entry) {
|
||||||
dprintf("PPPManager: Stop(): Could not find interface!\n");
|
ERROR("PPPManager: Stop(): Could not find interface!\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,9 +168,7 @@ int32
|
|||||||
PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
||||||
struct rtentry *rt0)
|
struct rtentry *rt0)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: Output(%s)\n", ifp ? ifp->if_name : "Unknown");
|
||||||
dprintf("PPPManager: Output(%s)\n", ifp ? ifp->if_name : "Unknown");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(dst->sa_family == AF_UNSPEC)
|
if(dst->sa_family == AF_UNSPEC)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -182,7 +176,7 @@ PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
|||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
ppp_interface_entry *entry = EntryFor(ifp);
|
ppp_interface_entry *entry = EntryFor(ifp);
|
||||||
if(!entry) {
|
if(!entry) {
|
||||||
dprintf("PPPManager: Output(): Could not find interface!\n");
|
ERROR("PPPManager: Output(): Could not find interface!\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,14 +216,12 @@ PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
|||||||
int32
|
int32
|
||||||
PPPManager::Control(ifnet *ifp, ulong cmd, caddr_t data)
|
PPPManager::Control(ifnet *ifp, ulong cmd, caddr_t data)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: Control(%s)\n", ifp ? ifp->if_name : "Unknown");
|
||||||
dprintf("PPPManager: Control(%s)\n", ifp ? ifp->if_name : "Unknown");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
ppp_interface_entry *entry = EntryFor(ifp);
|
ppp_interface_entry *entry = EntryFor(ifp);
|
||||||
if(!entry || entry->deleting) {
|
if(!entry || entry->deleting) {
|
||||||
dprintf("PPPManager: Control(): Could not find interface!\n");
|
ERROR("PPPManager: Control(): Could not find interface!\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,9 +276,7 @@ PPPManager::CreateInterfaceWithName(const char *name,
|
|||||||
bool
|
bool
|
||||||
PPPManager::DeleteInterface(ppp_interface_id ID)
|
PPPManager::DeleteInterface(ppp_interface_id ID)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: DeleteInterface(%ld)\n", ID);
|
||||||
dprintf("PPPManager: DeleteInterface(%ld)\n", ID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This only marks the interface for deletion.
|
// This only marks the interface for deletion.
|
||||||
// Our deleter_thread does the real work.
|
// Our deleter_thread does the real work.
|
||||||
@@ -318,9 +308,7 @@ PPPManager::DeleteInterface(ppp_interface_id ID)
|
|||||||
bool
|
bool
|
||||||
PPPManager::RemoveInterface(ppp_interface_id ID)
|
PPPManager::RemoveInterface(ppp_interface_id ID)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: RemoveInterface(%ld)\n", ID);
|
||||||
dprintf("PPPManager: RemoveInterface(%ld)\n", ID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -341,9 +329,7 @@ PPPManager::RemoveInterface(ppp_interface_id ID)
|
|||||||
ifnet*
|
ifnet*
|
||||||
PPPManager::RegisterInterface(ppp_interface_id ID)
|
PPPManager::RegisterInterface(ppp_interface_id ID)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: RegisterInterface(%ld)\n", ID);
|
||||||
dprintf("PPPManager: RegisterInterface(%ld)\n", ID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -355,6 +341,8 @@ PPPManager::RegisterInterface(ppp_interface_id ID)
|
|||||||
if(entry->interface->Ifnet())
|
if(entry->interface->Ifnet())
|
||||||
return entry->interface->Ifnet();
|
return entry->interface->Ifnet();
|
||||||
|
|
||||||
|
// TODO: allocate struct around ifnet with pointer to entry so we can optimize
|
||||||
|
// ifnet->ppp_interface_entry translation (speeds-up Output()/Input())
|
||||||
ifnet *ifp = (ifnet*) malloc(sizeof(ifnet));
|
ifnet *ifp = (ifnet*) malloc(sizeof(ifnet));
|
||||||
memset(ifp, 0, sizeof(ifnet));
|
memset(ifp, 0, sizeof(ifnet));
|
||||||
ifp->devid = -1;
|
ifp->devid = -1;
|
||||||
@@ -368,10 +356,8 @@ PPPManager::RegisterInterface(ppp_interface_id ID)
|
|||||||
ifp->output = ppp_ifnet_output;
|
ifp->output = ppp_ifnet_output;
|
||||||
ifp->ioctl = ppp_ifnet_ioctl;
|
ifp->ioctl = ppp_ifnet_ioctl;
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("PPPManager::RegisterInterface(): Created new ifnet: %s%d\n",
|
||||||
dprintf("PPPManager::RegisterInterface(): Created new ifnet: %s%d\n",
|
|
||||||
ifp->name, ifp->if_unit);
|
ifp->name, ifp->if_unit);
|
||||||
#endif
|
|
||||||
|
|
||||||
if_attach(ifp);
|
if_attach(ifp);
|
||||||
return ifp;
|
return ifp;
|
||||||
@@ -381,9 +367,7 @@ PPPManager::RegisterInterface(ppp_interface_id ID)
|
|||||||
bool
|
bool
|
||||||
PPPManager::UnregisterInterface(ppp_interface_id ID)
|
PPPManager::UnregisterInterface(ppp_interface_id ID)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: UnregisterInterface(%ld)\n", ID);
|
||||||
dprintf("PPPManager: UnregisterInterface(%ld)\n", ID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -403,9 +387,7 @@ PPPManager::UnregisterInterface(ppp_interface_id ID)
|
|||||||
status_t
|
status_t
|
||||||
PPPManager::Control(uint32 op, void *data, size_t length)
|
PPPManager::Control(uint32 op, void *data, size_t length)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: Control(%ld)\n", op);
|
||||||
dprintf("PPPManager: Control(%ld)\n", op);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// this method is intended for use by userland applications
|
// this method is intended for use by userland applications
|
||||||
|
|
||||||
@@ -574,9 +556,7 @@ PPPManager::Control(uint32 op, void *data, size_t length)
|
|||||||
status_t
|
status_t
|
||||||
PPPManager::ControlInterface(ppp_interface_id ID, uint32 op, void *data, size_t length)
|
PPPManager::ControlInterface(ppp_interface_id ID, uint32 op, void *data, size_t length)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: ControlInterface(%ld)\n", ID);
|
||||||
dprintf("PPPManager: ControlInterface(%ld)\n", ID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -597,9 +577,7 @@ int32
|
|||||||
PPPManager::GetInterfaces(ppp_interface_id *interfaces, int32 count,
|
PPPManager::GetInterfaces(ppp_interface_id *interfaces, int32 count,
|
||||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES)
|
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: GetInterfaces()\n");
|
||||||
dprintf("PPPManager: GetInterfaces()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -640,9 +618,7 @@ PPPManager::GetInterfaces(ppp_interface_id *interfaces, int32 count,
|
|||||||
int32
|
int32
|
||||||
PPPManager::CountInterfaces(ppp_interface_filter filter = PPP_REGISTERED_INTERFACES)
|
PPPManager::CountInterfaces(ppp_interface_filter filter = PPP_REGISTERED_INTERFACES)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: CountInterfaces()\n");
|
||||||
dprintf("PPPManager: CountInterfaces()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -681,9 +657,7 @@ PPPManager::CountInterfaces(ppp_interface_filter filter = PPP_REGISTERED_INTERFA
|
|||||||
ppp_interface_entry*
|
ppp_interface_entry*
|
||||||
PPPManager::EntryFor(ppp_interface_id ID, int32 *saveIndex = NULL) const
|
PPPManager::EntryFor(ppp_interface_id ID, int32 *saveIndex = NULL) const
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: EntryFor(%ld)\n", ID);
|
||||||
dprintf("PPPManager: EntryFor(%ld)\n", ID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(ID == PPP_UNDEFINED_INTERFACE_ID)
|
if(ID == PPP_UNDEFINED_INTERFACE_ID)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -691,7 +665,7 @@ PPPManager::EntryFor(ppp_interface_id ID, int32 *saveIndex = NULL) const
|
|||||||
ppp_interface_entry *entry;
|
ppp_interface_entry *entry;
|
||||||
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
||||||
entry = fEntries.ItemAt(index);
|
entry = fEntries.ItemAt(index);
|
||||||
if(entry && entry->interface->ID() == ID) {
|
if(entry && entry->interface && entry->interface->ID() == ID) {
|
||||||
if(saveIndex)
|
if(saveIndex)
|
||||||
*saveIndex = index;
|
*saveIndex = index;
|
||||||
return entry;
|
return entry;
|
||||||
@@ -708,14 +682,34 @@ PPPManager::EntryFor(ifnet *ifp, int32 *saveIndex = NULL) const
|
|||||||
if(!ifp)
|
if(!ifp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("PPPManager: EntryFor(%s%d)\n", ifp->name, ifp->if_unit);
|
||||||
dprintf("PPPManager: EntryFor(%s%d)\n", ifp->name, ifp->if_unit);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ppp_interface_entry *entry;
|
ppp_interface_entry *entry;
|
||||||
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
||||||
entry = fEntries.ItemAt(index);
|
entry = fEntries.ItemAt(index);
|
||||||
if(entry && entry->interface->Ifnet() == ifp) {
|
if(entry && entry->interface && entry->interface->Ifnet() == ifp) {
|
||||||
|
if(saveIndex)
|
||||||
|
*saveIndex = index;
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ppp_interface_entry*
|
||||||
|
PPPManager::EntryFor(const char *name, int32 *saveIndex = NULL) const
|
||||||
|
{
|
||||||
|
if(!name)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
TRACE("PPPManager: EntryFor(%s)\n", name);
|
||||||
|
|
||||||
|
ppp_interface_entry *entry;
|
||||||
|
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
||||||
|
entry = fEntries.ItemAt(index);
|
||||||
|
if(entry && entry->name && !strcmp(entry->name, name)) {
|
||||||
if(saveIndex)
|
if(saveIndex)
|
||||||
*saveIndex = index;
|
*saveIndex = index;
|
||||||
return entry;
|
return entry;
|
||||||
@@ -732,14 +726,13 @@ PPPManager::EntryFor(const driver_settings *settings) const
|
|||||||
if(!settings)
|
if(!settings)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("PPPManager: EntryFor(settings)\n");
|
||||||
dprintf("PPPManager: EntryFor(settings)\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ppp_interface_entry *entry;
|
ppp_interface_entry *entry;
|
||||||
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
||||||
entry = fEntries.ItemAt(index);
|
entry = fEntries.ItemAt(index);
|
||||||
if(entry && equal_interface_settings(entry->interface->Settings(), settings))
|
if(entry && entry->interface
|
||||||
|
&& equal_interface_settings(entry->interface->Settings(), settings))
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,9 +753,7 @@ ppp_interface_id
|
|||||||
PPPManager::_CreateInterface(const char *name, const driver_settings *settings,
|
PPPManager::_CreateInterface(const char *name, const driver_settings *settings,
|
||||||
const driver_settings *profile, ppp_interface_id parentID)
|
const driver_settings *profile, ppp_interface_id parentID)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPManager: CreateInterface(%s)\n", name ? name : "Unnamed");
|
||||||
dprintf("PPPManager: CreateInterface(%s)\n", name ? name : "Unnamed");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -775,21 +766,81 @@ PPPManager::_CreateInterface(const char *name, const driver_settings *settings,
|
|||||||
if(id == PPP_UNDEFINED_INTERFACE_ID)
|
if(id == PPP_UNDEFINED_INTERFACE_ID)
|
||||||
id = NextID();
|
id = NextID();
|
||||||
|
|
||||||
ppp_interface_entry *entry = new ppp_interface_entry;
|
// check if we already have an entry for the named interface
|
||||||
|
ppp_interface_entry *entry = EntryFor(name);
|
||||||
|
if(entry) {
|
||||||
|
if(entry->interface)
|
||||||
|
return entry->interface->ID();
|
||||||
|
// already existing interfaces do not need a PPP team
|
||||||
|
|
||||||
|
++entry->accessing;
|
||||||
|
|
||||||
|
thread_info info;
|
||||||
|
if(get_thread_info(entry->requestThread, &info) != B_OK)
|
||||||
|
entry->requestThread = -1;
|
||||||
|
else {
|
||||||
|
// test if app is responsive (i.e.: it reacts in at most 0.5secs)
|
||||||
|
thread_id sender;
|
||||||
|
int32 code;
|
||||||
|
if(send_data_with_timeout(entry->requestThread, PPP_RESPONSE_TEST_CODE,
|
||||||
|
NULL, 0, PPP_REPORT_TIMEOUT) != B_OK
|
||||||
|
|| receive_data_with_timeout(&sender, &code, NULL, 0, 500)
|
||||||
|
!= B_OK || code != B_OK) {
|
||||||
|
entry->requestThread = -1;
|
||||||
|
kill_team(info.team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entry = new ppp_interface_entry;
|
||||||
|
entry->name = name ? strdup(name) : NULL;
|
||||||
entry->accessing = 1;
|
entry->accessing = 1;
|
||||||
entry->deleting = false;
|
entry->requestThread = -1;
|
||||||
fEntries.AddItem(entry);
|
fEntries.AddItem(entry);
|
||||||
// nothing bad can happen because we are in a locked section
|
// nothing bad can happen because we are in a locked section
|
||||||
|
}
|
||||||
|
|
||||||
|
entry->deleting = false;
|
||||||
|
|
||||||
new KPPPInterface(name, entry, id, settings, profile,
|
new KPPPInterface(name, entry, id, settings, profile,
|
||||||
parentEntry ? parentEntry->interface : NULL);
|
parentEntry ? parentEntry->interface : NULL);
|
||||||
// KPPPInterface will add itself to the entry (no need to do it here)
|
// KPPPInterface will add itself to the entry (no need to do it here)
|
||||||
if(entry->interface->InitCheck() != B_OK) {
|
if(entry->interface->InitCheck() != B_OK) {
|
||||||
|
// use safe code because entry might have existed before this method call
|
||||||
|
--entry->accessing;
|
||||||
|
entry->deleting = true;
|
||||||
|
if(entry->accessing > 0)
|
||||||
|
return PPP_UNDEFINED_INTERFACE_ID;
|
||||||
|
|
||||||
|
free(entry->name);
|
||||||
delete entry->interface;
|
delete entry->interface;
|
||||||
|
fEntries.RemoveItem(entry);
|
||||||
delete entry;
|
delete entry;
|
||||||
return PPP_UNDEFINED_INTERFACE_ID;
|
return PPP_UNDEFINED_INTERFACE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// run ppp_up and enable reports for the request window (DONE?)
|
||||||
|
if(entry->requestThread < 0 && name) {
|
||||||
|
const char *argv[] = { "/boot/beos/bin/ppp_up", name, NULL };
|
||||||
|
const char *env[] = { NULL };
|
||||||
|
thread_id app = load_image(2, argv, env);
|
||||||
|
if(app < 0)
|
||||||
|
ERROR("KPPPInterface::Up(): Error: could not load ppp_up!\n");
|
||||||
|
resume_thread(app);
|
||||||
|
|
||||||
|
// XXX: What? BeOS' kernel is so &$$§$%! I cannot send anything to the
|
||||||
|
// team's main thread before the kernel sent something to it. So, we wait...
|
||||||
|
snooze(150000);
|
||||||
|
|
||||||
|
if(send_data(app, 0, &id, sizeof(id)) < B_OK)
|
||||||
|
ERROR("KPPPInterface::Up(): Error: could not send to ppp_up!\n");
|
||||||
|
|
||||||
|
// register the request thread as a report receiver
|
||||||
|
receive_data(&entry->requestThread, NULL, 0);
|
||||||
|
}
|
||||||
|
if(entry->requestThread >= 0)
|
||||||
|
entry->interface->ReportManager().EnableReports(PPP_CONNECTION_REPORT,
|
||||||
|
entry->requestThread, PPP_WAIT_FOR_REPLY | PPP_NO_REPLY_TIMEOUT);
|
||||||
|
|
||||||
locker.UnlockNow();
|
locker.UnlockNow();
|
||||||
// it is safe to access the manager from userland now
|
// it is safe to access the manager from userland now
|
||||||
|
|
||||||
@@ -819,7 +870,7 @@ PPPManager::FindUnit() const
|
|||||||
ppp_interface_entry *entry;
|
ppp_interface_entry *entry;
|
||||||
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
||||||
entry = fEntries.ItemAt(index);
|
entry = fEntries.ItemAt(index);
|
||||||
if(entry && entry->interface->Ifnet())
|
if(entry && entry->interface && entry->interface->Ifnet())
|
||||||
units[index] = entry->interface->Ifnet()->if_unit;
|
units[index] = entry->interface->Ifnet()->if_unit;
|
||||||
else
|
else
|
||||||
units[index] = -1;
|
units[index] = -1;
|
||||||
@@ -855,6 +906,14 @@ PPPManager::DeleterThreadEvent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(entry->deleting && entry->accessing <= 0) {
|
if(entry->deleting && entry->accessing <= 0) {
|
||||||
|
// only remove entries that do not have ppp_up associated with them
|
||||||
|
if(entry->requestThread >= 0) {
|
||||||
|
thread_info info;
|
||||||
|
if(get_thread_info(entry->requestThread, &info) == B_OK)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(entry->name);
|
||||||
delete entry->interface;
|
delete entry->interface;
|
||||||
delete entry;
|
delete entry;
|
||||||
fEntries.RemoveItem(index);
|
fEntries.RemoveItem(index);
|
||||||
@@ -872,7 +931,7 @@ PPPManager::Pulse()
|
|||||||
ppp_interface_entry *entry;
|
ppp_interface_entry *entry;
|
||||||
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
for(int32 index = 0; index < fEntries.CountItems(); index++) {
|
||||||
entry = fEntries.ItemAt(index);
|
entry = fEntries.ItemAt(index);
|
||||||
if(entry)
|
if(entry && entry->interface)
|
||||||
entry->interface->Pulse();
|
entry->interface->Pulse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _PPP_MANAGER__H
|
#ifndef _PPP_MANAGER__H
|
||||||
#define _PPP_MANAGER__H
|
#define _PPP_MANAGER__H
|
||||||
@@ -59,6 +57,7 @@ class PPPManager {
|
|||||||
ppp_interface_entry *EntryFor(ppp_interface_id ID,
|
ppp_interface_entry *EntryFor(ppp_interface_id ID,
|
||||||
int32 *saveIndex = NULL) const;
|
int32 *saveIndex = NULL) const;
|
||||||
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 driver_settings *settings) const;
|
ppp_interface_entry *EntryFor(const driver_settings *settings) const;
|
||||||
|
|
||||||
ppp_interface_id NextID()
|
ppp_interface_id NextID()
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <core_funcs.h>
|
#include <core_funcs.h>
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
- add CHAP
|
- add CHAP
|
||||||
- add ISDN (CAPI)
|
- add ISDN (CAPI)
|
||||||
- add PPTP (this is a virtual device that uses TCP/IP to connect to some other PPP server on the net)
|
- add PPTP (this is a virtual device that uses TCP/IP to connect to some other PPP server on the net)
|
||||||
|
- add L2TP (this is a virtual device that uses TCP/IP to connect to some other PPP server on the net)
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef IPCP__H
|
#ifndef IPCP__H
|
||||||
#define IPCP__H
|
#define IPCP__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <[email protected]>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@@ -74,7 +72,8 @@ 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")
|
||||||
{
|
{
|
||||||
ProfileChanged();
|
ProfileChanged();
|
||||||
|
|
||||||
@@ -102,9 +101,7 @@ IPCP::Uninit()
|
|||||||
status_t
|
status_t
|
||||||
IPCP::StackControl(uint32 op, void *data)
|
IPCP::StackControl(uint32 op, void *data)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: StackControl(op=%ld)\n", op);
|
||||||
dprintf("IPCP: StackControl(op=%ld)\n", op);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// check values
|
// check values
|
||||||
@@ -123,7 +120,7 @@ IPCP::StackControl(uint32 op, void *data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dprintf("IPCP: Unknown ioctl: %ld\n", op);
|
ERROR("IPCP: Unknown ioctl: %ld\n", op);
|
||||||
return KPPPProtocol::StackControl(op, data);
|
return KPPPProtocol::StackControl(op, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,9 +153,7 @@ IPCP::ProfileChanged()
|
|||||||
bool
|
bool
|
||||||
IPCP::Up()
|
IPCP::Up()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: Up() state=%d\n", State());
|
||||||
dprintf("IPCP: Up() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Servers do not send a configure-request when Up() is called. They wait until
|
// Servers do not send a configure-request when Up() is called. They wait until
|
||||||
// the client requests this protocol.
|
// the client requests this protocol.
|
||||||
@@ -186,9 +181,7 @@ IPCP::Up()
|
|||||||
bool
|
bool
|
||||||
IPCP::Down()
|
IPCP::Down()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: Down() state=%d\n", State());
|
||||||
dprintf("IPCP: Down() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -233,9 +226,7 @@ IPCP::Down()
|
|||||||
status_t
|
status_t
|
||||||
IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL)
|
IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: Send(0x%X)\n", protocolNumber);
|
||||||
dprintf("IPCP: Send(0x%X)\n", protocolNumber);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if((protocolNumber == IP_PROTOCOL && State() == PPP_OPENED_STATE)
|
if((protocolNumber == IP_PROTOCOL && State() == PPP_OPENED_STATE)
|
||||||
|| protocolNumber == IPCP_PROTOCOL) {
|
|| protocolNumber == IPCP_PROTOCOL) {
|
||||||
@@ -246,7 +237,7 @@ IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL)
|
|||||||
return SendToNext(packet, protocolNumber);
|
return SendToNext(packet, protocolNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf("IPCP: Send() failed because of wrong state or protocol number!\n");
|
ERROR("IPCP: Send() failed because of wrong state or protocol number!\n");
|
||||||
|
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -256,9 +247,7 @@ IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL)
|
|||||||
status_t
|
status_t
|
||||||
IPCP::Receive(struct mbuf *packet, uint16 protocolNumber)
|
IPCP::Receive(struct mbuf *packet, uint16 protocolNumber)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: Receive(0x%X)\n", protocolNumber);
|
||||||
dprintf("IPCP: Receive(0x%X)\n", protocolNumber);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -335,7 +324,7 @@ IPCP::ReceiveIPPacket(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
gProto[IPPROTO_IP]->pr_input(packet, 0);
|
gProto[IPPROTO_IP]->pr_input(packet, 0);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} else {
|
} else {
|
||||||
dprintf("IPCP: Error: Could not find input function for IP!\n");
|
ERROR("IPCP: Error: Could not find input function for IP!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -450,7 +439,7 @@ IPCP::UpdateAddresses()
|
|||||||
if(fLocalRequests.address != INADDR_ANY)
|
if(fLocalRequests.address != INADDR_ANY)
|
||||||
inreq.ifra_addr.sin_addr.s_addr = fLocalRequests.address;
|
inreq.ifra_addr.sin_addr.s_addr = fLocalRequests.address;
|
||||||
else if(fLocalConfiguration.address == INADDR_ANY)
|
else if(fLocalConfiguration.address == INADDR_ANY)
|
||||||
inreq.ifra_addr.sin_addr.s_addr = INADDR_BROADCAST;
|
inreq.ifra_addr.sin_addr.s_addr = 0x010F0F0F; // was: INADDR_BROADCAST
|
||||||
else
|
else
|
||||||
inreq.ifra_addr.sin_addr.s_addr = fLocalConfiguration.address;
|
inreq.ifra_addr.sin_addr.s_addr = fLocalConfiguration.address;
|
||||||
inreq.ifra_addr.sin_len = sizeof(struct sockaddr_in);
|
inreq.ifra_addr.sin_len = sizeof(struct sockaddr_in);
|
||||||
@@ -461,7 +450,7 @@ IPCP::UpdateAddresses()
|
|||||||
if(fPeerRequests.address != INADDR_ANY)
|
if(fPeerRequests.address != INADDR_ANY)
|
||||||
fGateway.sin_addr.s_addr = fPeerRequests.address;
|
fGateway.sin_addr.s_addr = fPeerRequests.address;
|
||||||
else if(fPeerConfiguration.address == INADDR_ANY)
|
else if(fPeerConfiguration.address == INADDR_ANY)
|
||||||
fGateway.sin_addr.s_addr = INADDR_BROADCAST;
|
fGateway.sin_addr.s_addr = 0x020F0F0F; // was: INADDR_BROADCAST
|
||||||
else
|
else
|
||||||
fGateway.sin_addr.s_addr = fPeerConfiguration.address;
|
fGateway.sin_addr.s_addr = fPeerConfiguration.address;
|
||||||
fGateway.sin_len = sizeof(struct sockaddr_in);
|
fGateway.sin_len = sizeof(struct sockaddr_in);
|
||||||
@@ -478,25 +467,25 @@ IPCP::UpdateAddresses()
|
|||||||
// tell stack to use these values
|
// tell stack to use these values
|
||||||
if(in_control(NULL, SIOCAIFADDR, (caddr_t) &inreq,
|
if(in_control(NULL, SIOCAIFADDR, (caddr_t) &inreq,
|
||||||
Interface().Ifnet()) != B_OK)
|
Interface().Ifnet()) != B_OK)
|
||||||
dprintf("IPCP: UpdateAddress(): SIOCAIFADDR returned error!\n");
|
ERROR("IPCP: UpdateAddress(): SIOCAIFADDR returned error!\n");
|
||||||
if(in_control(NULL, SIOCSIFADDR, (caddr_t) &ifreqAddress,
|
if(in_control(NULL, SIOCSIFADDR, (caddr_t) &ifreqAddress,
|
||||||
Interface().Ifnet()) != B_OK)
|
Interface().Ifnet()) != B_OK)
|
||||||
dprintf("IPCP: UpdateAddress(): SIOCSIFADDR returned error!\n");
|
ERROR("IPCP: UpdateAddress(): SIOCSIFADDR returned error!\n");
|
||||||
if(in_control(NULL, SIOCSIFDSTADDR, (caddr_t) &ifreqDestination,
|
if(in_control(NULL, SIOCSIFDSTADDR, (caddr_t) &ifreqDestination,
|
||||||
Interface().Ifnet()) != B_OK)
|
Interface().Ifnet()) != B_OK)
|
||||||
dprintf("IPCP: UpdateAddress(): SIOCSIFDSTADDR returned error!\n");
|
ERROR("IPCP: UpdateAddress(): SIOCSIFDSTADDR returned error!\n");
|
||||||
memcpy(&inreq.ifra_addr, &inreq.ifra_mask, sizeof(struct sockaddr_in));
|
memcpy(&inreq.ifra_addr, &inreq.ifra_mask, sizeof(struct sockaddr_in));
|
||||||
// SIOCISFNETMASK wants the netmask to be in ifra_addr
|
// SIOCISFNETMASK wants the netmask to be in ifra_addr
|
||||||
if(in_control(NULL, SIOCSIFNETMASK, (caddr_t) &inreq,
|
if(in_control(NULL, SIOCSIFNETMASK, (caddr_t) &inreq,
|
||||||
Interface().Ifnet()) != B_OK)
|
Interface().Ifnet()) != B_OK)
|
||||||
dprintf("IPCP: UpdateAddress(): SIOCSIFNETMASK returned error!\n");
|
ERROR("IPCP: UpdateAddress(): SIOCSIFNETMASK returned error!\n");
|
||||||
|
|
||||||
// add default/subnet route
|
// add default/subnet route
|
||||||
if(Side() == PPP_LOCAL_SIDE) {
|
if(Side() == PPP_LOCAL_SIDE) {
|
||||||
if(rtrequest(RTM_ADD, (struct sockaddr*) &inreq.ifra_mask,
|
if(rtrequest(RTM_ADD, (struct sockaddr*) &inreq.ifra_mask,
|
||||||
(struct sockaddr*) &fGateway, (struct sockaddr*) &inreq.ifra_mask,
|
(struct sockaddr*) &fGateway, (struct sockaddr*) &inreq.ifra_mask,
|
||||||
RTF_UP | RTF_GATEWAY, &fDefaultRoute) != B_OK)
|
RTF_UP | RTF_GATEWAY, &fDefaultRoute) != B_OK)
|
||||||
dprintf("IPCP: UpdateAddress(): could not add default/subnet route!\n");
|
ERROR("IPCP: UpdateAddress(): could not add default/subnet route!\n");
|
||||||
|
|
||||||
--fDefaultRoute->rt_refcnt;
|
--fDefaultRoute->rt_refcnt;
|
||||||
}
|
}
|
||||||
@@ -519,7 +508,7 @@ IPCP::RemoveRoutes()
|
|||||||
if(rtrequest(RTM_DELETE, (struct sockaddr*) &netmask,
|
if(rtrequest(RTM_DELETE, (struct sockaddr*) &netmask,
|
||||||
(struct sockaddr*) &fGateway, (struct sockaddr*) &netmask,
|
(struct sockaddr*) &fGateway, (struct sockaddr*) &netmask,
|
||||||
RTF_UP | RTF_GATEWAY, &fDefaultRoute) != B_OK)
|
RTF_UP | RTF_GATEWAY, &fDefaultRoute) != B_OK)
|
||||||
dprintf("IPCP: RemoveRoutes(): could not remove default/subnet route!\n");
|
ERROR("IPCP: RemoveRoutes(): could not remove default/subnet route!\n");
|
||||||
|
|
||||||
fDefaultRoute = NULL;
|
fDefaultRoute = NULL;
|
||||||
}
|
}
|
||||||
@@ -536,9 +525,7 @@ IPCP::NextID()
|
|||||||
void
|
void
|
||||||
IPCP::NewState(ppp_state next)
|
IPCP::NewState(ppp_state next)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: NewState(%d) state=%d\n", next, State());
|
||||||
dprintf("IPCP: NewState(%d) state=%d\n", next, State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// report state changes
|
// report state changes
|
||||||
if(State() == PPP_INITIAL_STATE && next != State())
|
if(State() == PPP_INITIAL_STATE && next != State())
|
||||||
@@ -558,7 +545,7 @@ void
|
|||||||
IPCP::TOGoodEvent()
|
IPCP::TOGoodEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
dprintf("IPCP: TOGoodEvent() state=%d\n", State());
|
printf("IPCP: TOGoodEvent() state=%d\n", State());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
@@ -587,9 +574,7 @@ IPCP::TOGoodEvent()
|
|||||||
void
|
void
|
||||||
IPCP::TOBadEvent()
|
IPCP::TOBadEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: TOBadEvent() state=%d\n", State());
|
||||||
dprintf("IPCP: TOBadEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -617,9 +602,7 @@ IPCP::TOBadEvent()
|
|||||||
void
|
void
|
||||||
IPCP::RCREvent(struct mbuf *packet)
|
IPCP::RCREvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RCREvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RCREvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
KPPPConfigurePacket request(packet);
|
KPPPConfigurePacket request(packet);
|
||||||
KPPPConfigurePacket nak(PPP_CONFIGURE_NAK);
|
KPPPConfigurePacket nak(PPP_CONFIGURE_NAK);
|
||||||
@@ -725,9 +708,7 @@ IPCP::RCREvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
IPCP::RCRGoodEvent(struct mbuf *packet)
|
IPCP::RCRGoodEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RCRGoodEvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RCRGoodEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -771,9 +752,7 @@ IPCP::RCRGoodEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
IPCP::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
IPCP::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RCRBadEvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RCRBadEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -813,9 +792,7 @@ IPCP::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
|||||||
void
|
void
|
||||||
IPCP::RCAEvent(struct mbuf *packet)
|
IPCP::RCAEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RCAEvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RCAEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -923,9 +900,7 @@ IPCP::RCAEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
IPCP::RCNEvent(struct mbuf *packet)
|
IPCP::RCNEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RCNEvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RCNEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1041,9 +1016,7 @@ IPCP::RCNEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
IPCP::RTREvent(struct mbuf *packet)
|
IPCP::RTREvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RTREvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RTREvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1086,9 +1059,7 @@ IPCP::RTREvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
IPCP::RTAEvent(struct mbuf *packet)
|
IPCP::RTAEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RTAEvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RTAEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1132,9 +1103,7 @@ IPCP::RTAEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
IPCP::RUCEvent(struct mbuf *packet)
|
IPCP::RUCEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RUCEvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RUCEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SendCodeReject(packet);
|
SendCodeReject(packet);
|
||||||
}
|
}
|
||||||
@@ -1143,9 +1112,7 @@ IPCP::RUCEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
IPCP::RXJBadEvent(struct mbuf *packet)
|
IPCP::RXJBadEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: RXJBadEvent() state=%d\n", State());
|
||||||
dprintf("IPCP: RXJBadEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1188,7 +1155,7 @@ void
|
|||||||
IPCP::IllegalEvent(ppp_event event)
|
IPCP::IllegalEvent(ppp_event event)
|
||||||
{
|
{
|
||||||
// TODO: update error statistics
|
// TODO: update error statistics
|
||||||
dprintf("IPCP: IllegalEvent(event=%d) state=%d\n", event, State());
|
ERROR("IPCP: IllegalEvent(event=%d) state=%d\n", event, State());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1248,9 +1215,7 @@ IPCP::ZeroRestartCount()
|
|||||||
bool
|
bool
|
||||||
IPCP::SendConfigureRequest()
|
IPCP::SendConfigureRequest()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: SendConfigureRequest() state=%d\n", State());
|
||||||
dprintf("IPCP: SendConfigureRequest() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
--fRequestCounter;
|
--fRequestCounter;
|
||||||
@@ -1271,11 +1236,9 @@ IPCP::SendConfigureRequest()
|
|||||||
ipItem.address = fLocalRequests.address;
|
ipItem.address = fLocalRequests.address;
|
||||||
request.AddItem((ppp_configure_item*) &ipItem);
|
request.AddItem((ppp_configure_item*) &ipItem);
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("IPCP: SCR: confaddr=%lX; reqaddr=%lX; addr=%lX\n",
|
||||||
dprintf("IPCP: SCR: confaddr=%lX; reqaddr=%lX; addr=%lX\n",
|
|
||||||
fLocalConfiguration.address, fLocalRequests.address,
|
fLocalConfiguration.address, fLocalRequests.address,
|
||||||
((ip_item*)request.ItemAt(0))->address);
|
((ip_item*)request.ItemAt(0))->address);
|
||||||
#endif
|
|
||||||
|
|
||||||
// add primary DNS (if needed)
|
// add primary DNS (if needed)
|
||||||
if(fRequestPrimaryDNS && fLocalRequests.primaryDNS == INADDR_ANY) {
|
if(fRequestPrimaryDNS && fLocalRequests.primaryDNS == INADDR_ANY) {
|
||||||
@@ -1303,9 +1266,7 @@ IPCP::SendConfigureRequest()
|
|||||||
bool
|
bool
|
||||||
IPCP::SendConfigureAck(struct mbuf *packet)
|
IPCP::SendConfigureAck(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: SendConfigureAck() state=%d\n", State());
|
||||||
dprintf("IPCP: SendConfigureAck() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return false;
|
return false;
|
||||||
@@ -1374,9 +1335,7 @@ IPCP::SendConfigureAck(struct mbuf *packet)
|
|||||||
bool
|
bool
|
||||||
IPCP::SendConfigureNak(struct mbuf *packet)
|
IPCP::SendConfigureNak(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: SendConfigureNak() state=%d\n", State());
|
||||||
dprintf("IPCP: SendConfigureNak() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return false;
|
return false;
|
||||||
@@ -1397,9 +1356,7 @@ IPCP::SendConfigureNak(struct mbuf *packet)
|
|||||||
bool
|
bool
|
||||||
IPCP::SendTerminateRequest()
|
IPCP::SendTerminateRequest()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: SendTerminateRequest() state=%d\n", State());
|
||||||
dprintf("IPCP: SendTerminateRequest() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
--fTerminateCounter;
|
--fTerminateCounter;
|
||||||
@@ -1427,9 +1384,7 @@ IPCP::SendTerminateRequest()
|
|||||||
bool
|
bool
|
||||||
IPCP::SendTerminateAck(struct mbuf *request = NULL)
|
IPCP::SendTerminateAck(struct mbuf *request = NULL)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: SendTerminateAck() state=%d\n", State());
|
||||||
dprintf("IPCP: SendTerminateAck() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct mbuf *reply = request;
|
struct mbuf *reply = request;
|
||||||
|
|
||||||
@@ -1458,9 +1413,7 @@ IPCP::SendTerminateAck(struct mbuf *request = NULL)
|
|||||||
bool
|
bool
|
||||||
IPCP::SendCodeReject(struct mbuf *packet)
|
IPCP::SendCodeReject(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("IPCP: SendCodeReject() state=%d\n", State());
|
||||||
dprintf("IPCP: SendCodeReject() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef PROTOCOL__H
|
#ifndef PROTOCOL__H
|
||||||
#define PROTOCOL__H
|
#define PROTOCOL__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <driver_settings.h>
|
#include <driver_settings.h>
|
||||||
@@ -12,7 +10,6 @@
|
|||||||
|
|
||||||
#include <KPPPInterface.h>
|
#include <KPPPInterface.h>
|
||||||
#include <KPPPModule.h>
|
#include <KPPPModule.h>
|
||||||
#include <LockerHelper.h>
|
|
||||||
|
|
||||||
#include "Protocol.h"
|
#include "Protocol.h"
|
||||||
|
|
||||||
@@ -54,10 +51,8 @@ add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface,
|
|||||||
success = mainInterface.AddProtocol(ipcp);
|
success = mainInterface.AddProtocol(ipcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("IPCP: add_to(): %s\n",
|
||||||
dprintf("IPCP: add_to(): %s\n",
|
|
||||||
success && ipcp && ipcp->InitCheck() == B_OK ? "OK" : "ERROR");
|
success && ipcp && ipcp->InitCheck() == B_OK ? "OK" : "ERROR");
|
||||||
#endif
|
|
||||||
|
|
||||||
return success && ipcp && ipcp->InitCheck() == B_OK;
|
return success && ipcp && ipcp->InitCheck() == B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "ACFCHandler.h"
|
#include "ACFCHandler.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef ACFC_HANDLER__H
|
#ifndef ACFC_HANDLER__H
|
||||||
#define ACFC_HANDLER__H
|
#define ACFC_HANDLER__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef MODEM__H
|
#ifndef MODEM__H
|
||||||
#define MODEM__H
|
#define MODEM__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
@@ -33,7 +31,7 @@ dump_packet(struct mbuf *packet)
|
|||||||
uint8 buffer[33];
|
uint8 buffer[33];
|
||||||
uint8 bufferIndex = 0;
|
uint8 bufferIndex = 0;
|
||||||
|
|
||||||
dprintf("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len,
|
TRACE("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len,
|
||||||
packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1);
|
packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1);
|
||||||
|
|
||||||
for(uint32 index = 0; index < packet->m_len; index++) {
|
for(uint32 index = 0; index < packet->m_len; index++) {
|
||||||
@@ -41,7 +39,7 @@ dump_packet(struct mbuf *packet)
|
|||||||
buffer[bufferIndex++] = sDigits[data[index] & 0x0F];
|
buffer[bufferIndex++] = sDigits[data[index] & 0x0F];
|
||||||
if(bufferIndex == 32 || index == packet->m_len - 1) {
|
if(bufferIndex == 32 || index == packet->m_len - 1) {
|
||||||
buffer[bufferIndex] = 0;
|
buffer[bufferIndex] = 0;
|
||||||
dprintf("%s\n", buffer);
|
TRACE("%s\n", buffer);
|
||||||
bufferIndex = 0;
|
bufferIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,12 +185,13 @@ 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
|
||||||
dprintf("ModemDevice: Constructor\n");
|
TRACE("ModemDevice: Constructor\n");
|
||||||
if(!settings || !settings->parameters)
|
if(!settings || !settings->parameters)
|
||||||
dprintf("ModemDevice::ctor: No settings!\n");
|
TRACE("ModemDevice::ctor: No settings!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fACFC = new ACFCHandler(REQUEST_ACFC | ALLOW_ACFC, interface);
|
fACFC = new ACFCHandler(REQUEST_ACFC | ALLOW_ACFC, interface);
|
||||||
@@ -211,17 +210,13 @@ ModemDevice::ModemDevice(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
fInitString = get_parameter_value(MODEM_INIT_KEY, settings);
|
fInitString = get_parameter_value(MODEM_INIT_KEY, settings);
|
||||||
fDialString = get_parameter_value(MODEM_DIAL_KEY, settings);
|
fDialString = get_parameter_value(MODEM_DIAL_KEY, settings);
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("ModemDevice::ctor: interfaceName: %s\n", fPortName);
|
||||||
dprintf("ModemDevice::ctor: interfaceName: %s\n", fPortName);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModemDevice::~ModemDevice()
|
ModemDevice::~ModemDevice()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("ModemDevice: Destructor\n");
|
||||||
dprintf("ModemDevice: Destructor\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -239,9 +234,7 @@ ModemDevice::InitCheck() const
|
|||||||
bool
|
bool
|
||||||
ModemDevice::Up()
|
ModemDevice::Up()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("ModemDevice: Up()\n");
|
||||||
dprintf("ModemDevice: Up()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
@@ -279,9 +272,7 @@ ModemDevice::Up()
|
|||||||
bool
|
bool
|
||||||
ModemDevice::Down()
|
ModemDevice::Down()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("ModemDevice: Down()\n");
|
||||||
dprintf("ModemDevice: Down()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
@@ -355,7 +346,7 @@ ModemDevice::OpenModem()
|
|||||||
// init port
|
// init port
|
||||||
struct termios options;
|
struct termios options;
|
||||||
if(ioctl(fHandle, TCGETA, &options) != B_OK) {
|
if(ioctl(fHandle, TCGETA, &options) != B_OK) {
|
||||||
dprintf("ModemDevice: Could not retrieve port options!\n");
|
ERROR("ModemDevice: Could not retrieve port options!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,7 +361,7 @@ ModemDevice::OpenModem()
|
|||||||
|
|
||||||
// set new options
|
// set new options
|
||||||
if(ioctl(fHandle, TCSETA, &options) != B_OK) {
|
if(ioctl(fHandle, TCSETA, &options) != B_OK) {
|
||||||
dprintf("ModemDevice: Could not init port!\n");
|
ERROR("ModemDevice: Could not init port!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,7 +424,7 @@ status_t
|
|||||||
ModemDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
ModemDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
dprintf("ModemDevice: Send()\n");
|
TRACE("ModemDevice: Send()\n");
|
||||||
dump_packet(packet);
|
dump_packet(packet);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef MODEM_DEVICE__H
|
#ifndef MODEM_DEVICE__H
|
||||||
#define MODEM_DEVICE__H
|
#define MODEM_DEVICE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <driver_settings.h>
|
#include <driver_settings.h>
|
||||||
@@ -12,7 +10,6 @@
|
|||||||
|
|
||||||
#include <KPPPInterface.h>
|
#include <KPPPInterface.h>
|
||||||
#include <KPPPModule.h>
|
#include <KPPPModule.h>
|
||||||
#include <LockerHelper.h>
|
|
||||||
|
|
||||||
#include "ModemDevice.h"
|
#include "ModemDevice.h"
|
||||||
|
|
||||||
@@ -41,10 +38,8 @@ add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface,
|
|||||||
success = mainInterface.SetDevice(device);
|
success = mainInterface.SetDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("Modem: add_to(): %s\n",
|
||||||
dprintf("Modem: add_to(): %s\n",
|
|
||||||
success && device && device->InitCheck() == B_OK ? "OK" : "ERROR");
|
success && device && device->InitCheck() == B_OK ? "OK" : "ERROR");
|
||||||
#endif
|
|
||||||
|
|
||||||
return success && device && device->InitCheck() == B_OK;
|
return success && device && device->InitCheck() == B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "Protocol.h"
|
#include "Protocol.h"
|
||||||
#include <KPPPConfigurePacket.h>
|
#include <KPPPConfigurePacket.h>
|
||||||
@@ -83,7 +81,8 @@ 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")
|
||||||
{
|
{
|
||||||
ProfileChanged();
|
ProfileChanged();
|
||||||
}
|
}
|
||||||
@@ -114,9 +113,7 @@ PAP::ProfileChanged()
|
|||||||
bool
|
bool
|
||||||
PAP::Up()
|
PAP::Up()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: Up() state=%d\n", State());
|
||||||
dprintf("PAP: Up() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -148,9 +145,7 @@ PAP::Up()
|
|||||||
bool
|
bool
|
||||||
PAP::Down()
|
PAP::Down()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: Down() state=%d\n", State());
|
||||||
dprintf("PAP: Down() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -307,9 +302,7 @@ PAP::NextID()
|
|||||||
void
|
void
|
||||||
PAP::NewState(pap_state next)
|
PAP::NewState(pap_state next)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: NewState(%d) state=%d\n", next, State());
|
||||||
dprintf("PAP: NewState(%d) state=%d\n", next, State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// state changes
|
// state changes
|
||||||
if(State() == INITIAL && next != State()) {
|
if(State() == INITIAL && next != State()) {
|
||||||
@@ -333,9 +326,7 @@ PAP::NewState(pap_state next)
|
|||||||
void
|
void
|
||||||
PAP::TOGoodEvent()
|
PAP::TOGoodEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: TOGoodEvent() state=%d\n", State());
|
||||||
dprintf("PAP: TOGoodEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -358,9 +349,7 @@ PAP::TOGoodEvent()
|
|||||||
void
|
void
|
||||||
PAP::TOBadEvent()
|
PAP::TOBadEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: TOBadEvent() state=%d\n", State());
|
||||||
dprintf("PAP: TOBadEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -386,9 +375,7 @@ PAP::TOBadEvent()
|
|||||||
void
|
void
|
||||||
PAP::RREvent(struct mbuf *packet)
|
PAP::RREvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: RREvent() state=%d\n", State());
|
||||||
dprintf("PAP: RREvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -427,9 +414,7 @@ PAP::RREvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
PAP::RAEvent(struct mbuf *packet)
|
PAP::RAEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: RAEvent() state=%d\n", State());
|
||||||
dprintf("PAP: RAEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -460,9 +445,7 @@ PAP::RAEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
PAP::RNEvent(struct mbuf *packet)
|
PAP::RNEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: RNEvent() state=%d\n", State());
|
||||||
dprintf("PAP: RNEvent() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -500,9 +483,7 @@ PAP::InitializeRestartCount()
|
|||||||
bool
|
bool
|
||||||
PAP::SendRequest()
|
PAP::SendRequest()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: SendRequest() state=%d\n", State());
|
||||||
dprintf("PAP: SendRequest() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
--fRequestCounter;
|
--fRequestCounter;
|
||||||
@@ -535,9 +516,7 @@ PAP::SendRequest()
|
|||||||
bool
|
bool
|
||||||
PAP::SendAck(struct mbuf *packet)
|
PAP::SendAck(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: SendAck() state=%d\n", State());
|
||||||
dprintf("PAP: SendAck() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return false;
|
return false;
|
||||||
@@ -558,9 +537,7 @@ PAP::SendAck(struct mbuf *packet)
|
|||||||
bool
|
bool
|
||||||
PAP::SendNak(struct mbuf *packet)
|
PAP::SendNak(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PAP: SendNak() state=%d\n", State());
|
||||||
dprintf("PAP: SendNak() state=%d\n", State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef PROTOCOL__H
|
#ifndef PROTOCOL__H
|
||||||
#define PROTOCOL__H
|
#define PROTOCOL__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <driver_settings.h>
|
#include <driver_settings.h>
|
||||||
@@ -12,7 +10,6 @@
|
|||||||
|
|
||||||
#include <KPPPInterface.h>
|
#include <KPPPInterface.h>
|
||||||
#include <KPPPModule.h>
|
#include <KPPPModule.h>
|
||||||
#include <LockerHelper.h>
|
|
||||||
|
|
||||||
#include "Protocol.h"
|
#include "Protocol.h"
|
||||||
|
|
||||||
@@ -41,10 +38,8 @@ add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface,
|
|||||||
success = mainInterface.AddProtocol(pap);
|
success = mainInterface.AddProtocol(pap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("PAP: add_to(): %s\n",
|
||||||
dprintf("PAP: add_to(): %s\n",
|
|
||||||
success && pap && pap->InitCheck() == B_OK ? "OK" : "ERROR");
|
success && pap && pap->InitCheck() == B_OK ? "OK" : "ERROR");
|
||||||
#endif
|
|
||||||
|
|
||||||
return success && pap && pap->InitCheck() == B_OK;
|
return success && pap && pap->InitCheck() == B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "DiscoveryPacket.h"
|
#include "DiscoveryPacket.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef DISCOVERY_PACKET__H
|
#ifndef DISCOVERY_PACKET__H
|
||||||
#define DISCOVERY_PACKET__H
|
#define DISCOVERY_PACKET__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef PPPoE__H
|
#ifndef PPPoE__H
|
||||||
#define PPPoE__H
|
#define PPPoE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "PPPoEDevice.h"
|
#include "PPPoEDevice.h"
|
||||||
#include "DiscoveryPacket.h"
|
#include "DiscoveryPacket.h"
|
||||||
@@ -28,7 +26,7 @@ dump_packet(struct mbuf *packet)
|
|||||||
uint8 buffer[33];
|
uint8 buffer[33];
|
||||||
uint8 bufferIndex = 0;
|
uint8 bufferIndex = 0;
|
||||||
|
|
||||||
dprintf("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len,
|
TRACE("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len,
|
||||||
packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1);
|
packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1);
|
||||||
|
|
||||||
for(uint32 index = 0; index < packet->m_len; index++) {
|
for(uint32 index = 0; index < packet->m_len; index++) {
|
||||||
@@ -36,7 +34,7 @@ dump_packet(struct mbuf *packet)
|
|||||||
buffer[bufferIndex++] = sDigits[data[index] & 0x0F];
|
buffer[bufferIndex++] = sDigits[data[index] & 0x0F];
|
||||||
if(bufferIndex == 32 || index == packet->m_len - 1) {
|
if(bufferIndex == 32 || index == packet->m_len - 1) {
|
||||||
buffer[bufferIndex] = 0;
|
buffer[bufferIndex] = 0;
|
||||||
dprintf("%s\n", buffer);
|
TRACE("%s\n", buffer);
|
||||||
bufferIndex = 0;
|
bufferIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,12 +51,13 @@ 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
|
||||||
dprintf("PPPoEDevice: Constructor\n");
|
TRACE("PPPoEDevice: Constructor\n");
|
||||||
if(!settings || !settings->parameters)
|
if(!settings || !settings->parameters)
|
||||||
dprintf("PPPoEDevice::ctor: No settings!\n");
|
TRACE("PPPoEDevice::ctor: No settings!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
interface.SetPFCOptions(PPP_ALLOW_PFC);
|
interface.SetPFCOptions(PPP_ALLOW_PFC);
|
||||||
@@ -80,7 +79,7 @@ PPPoEDevice::PPPoEDevice(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(!fEthernetIfnet)
|
if(!fEthernetIfnet)
|
||||||
dprintf("PPPoEDevice::ctor: could not find ethernet interface\n");
|
TRACE("PPPoEDevice::ctor: could not find ethernet interface\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
add_device(this);
|
add_device(this);
|
||||||
@@ -89,9 +88,7 @@ PPPoEDevice::PPPoEDevice(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
|
|
||||||
PPPoEDevice::~PPPoEDevice()
|
PPPoEDevice::~PPPoEDevice()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPoEDevice: Destructor\n");
|
||||||
dprintf("PPPoEDevice: Destructor\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
remove_device(this);
|
remove_device(this);
|
||||||
}
|
}
|
||||||
@@ -108,9 +105,7 @@ PPPoEDevice::InitCheck() const
|
|||||||
bool
|
bool
|
||||||
PPPoEDevice::Up()
|
PPPoEDevice::Up()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPoEDevice: Up()\n");
|
||||||
dprintf("PPPoEDevice: Up()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
@@ -170,7 +165,7 @@ PPPoEDevice::Up()
|
|||||||
if(EthernetIfnet()->output(EthernetIfnet(), packet, &destination, NULL) != B_OK) {
|
if(EthernetIfnet()->output(EthernetIfnet(), packet, &destination, NULL) != B_OK) {
|
||||||
fState = INITIAL;
|
fState = INITIAL;
|
||||||
fAttempts = 0;
|
fAttempts = 0;
|
||||||
dprintf("PPPoEDevice::Up(): EthernetIfnet()->output() failed!\n");
|
ERROR("PPPoEDevice::Up(): EthernetIfnet()->output() failed!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,9 +178,7 @@ PPPoEDevice::Up()
|
|||||||
bool
|
bool
|
||||||
PPPoEDevice::Down()
|
PPPoEDevice::Down()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPoEDevice: Down()\n");
|
||||||
dprintf("PPPoEDevice: Down()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
@@ -211,7 +204,7 @@ PPPoEDevice::Down()
|
|||||||
|
|
||||||
struct mbuf *packet = discovery.ToMbuf(MTU());
|
struct mbuf *packet = discovery.ToMbuf(MTU());
|
||||||
if(!packet) {
|
if(!packet) {
|
||||||
dprintf("PPPoEDevice::Down(): ToMbuf() failed; MTU=%ld\n", MTU());
|
ERROR("PPPoEDevice::Down(): ToMbuf() failed; MTU=%ld\n", MTU());
|
||||||
DownEvent();
|
DownEvent();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -264,14 +257,12 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
|||||||
{
|
{
|
||||||
// Send() is only for PPP packets. PPPoE packets are sent directly to ethernet.
|
// Send() is only for PPP packets. PPPoE packets are sent directly to ethernet.
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("PPPoEDevice: Send()\n");
|
||||||
dprintf("PPPoEDevice: Send()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
else if(InitCheck() != B_OK || protocolNumber != 0) {
|
else if(InitCheck() != B_OK || protocolNumber != 0) {
|
||||||
dprintf("PPPoEDevice::Send(): InitCheck() != B_OK!\n");
|
ERROR("PPPoEDevice::Send(): InitCheck() != B_OK!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -279,7 +270,7 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
|||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
if(!IsUp()) {
|
if(!IsUp()) {
|
||||||
dprintf("PPPoEDevice::Send(): no connection!\n");
|
ERROR("PPPoEDevice::Send(): no connection!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return PPP_NO_CONNECTION;
|
return PPP_NO_CONNECTION;
|
||||||
}
|
}
|
||||||
@@ -307,11 +298,11 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
|||||||
|
|
||||||
locker.UnlockNow();
|
locker.UnlockNow();
|
||||||
|
|
||||||
if(!packet)
|
if(!packet || !mtod(packet, pppoe_header*))
|
||||||
dprintf("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) {
|
||||||
dprintf("PPPoEDevice::Send(): EthernetIfnet()->output() failed!\n");
|
ERROR("PPPoEDevice::Send(): EthernetIfnet()->output() failed!\n");
|
||||||
DownEvent();
|
DownEvent();
|
||||||
// DownEvent() without DownStarted() indicates connection lost
|
// DownEvent() without DownStarted() indicates connection lost
|
||||||
return PPP_NO_CONNECTION;
|
return PPP_NO_CONNECTION;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef PPPoE_DEVICE__H
|
#ifndef PPPoE_DEVICE__H
|
||||||
#define PPPoE_DEVICE__H
|
#define PPPoE_DEVICE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <driver_settings.h>
|
#include <driver_settings.h>
|
||||||
@@ -34,7 +32,7 @@ static struct ethernet_module_info *sEthernet;
|
|||||||
static int32 sHostUniq = 0;
|
static int32 sHostUniq = 0;
|
||||||
status_t std_ops(int32 op, ...);
|
status_t std_ops(int32 op, ...);
|
||||||
|
|
||||||
static BLocker sLock;
|
static BLocker sLock("PPPoEList");
|
||||||
static TemplateList<PPPoEDevice*> *sDevices;
|
static TemplateList<PPPoEDevice*> *sDevices;
|
||||||
static TemplateList<pppoe_query*> *sQueries;
|
static TemplateList<pppoe_query*> *sQueries;
|
||||||
|
|
||||||
@@ -94,6 +92,7 @@ FindPPPoEInterface(const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
NewHostUniq()
|
NewHostUniq()
|
||||||
{
|
{
|
||||||
@@ -104,9 +103,7 @@ NewHostUniq()
|
|||||||
void
|
void
|
||||||
add_device(PPPoEDevice *device)
|
add_device(PPPoEDevice *device)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPoE: add_device()\n");
|
||||||
dprintf("PPPoE: add_device()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(sLock);
|
LockerHelper locker(sLock);
|
||||||
sDevices->AddItem(device);
|
sDevices->AddItem(device);
|
||||||
@@ -116,9 +113,7 @@ add_device(PPPoEDevice *device)
|
|||||||
void
|
void
|
||||||
remove_device(PPPoEDevice *device)
|
remove_device(PPPoEDevice *device)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("PPPoE: remove_device()\n");
|
||||||
dprintf("PPPoE: remove_device()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(sLock);
|
LockerHelper locker(sLock);
|
||||||
sDevices->RemoveItem(device);
|
sDevices->RemoveItem(device);
|
||||||
@@ -148,7 +143,7 @@ pppoe_input(struct mbuf *packet)
|
|||||||
if(header->pppoeHeader.code == PADO) {
|
if(header->pppoeHeader.code == PADO) {
|
||||||
DiscoveryPacket discovery(packet, ETHER_HDR_LEN);
|
DiscoveryPacket discovery(packet, ETHER_HDR_LEN);
|
||||||
if(discovery.InitCheck() != B_OK) {
|
if(discovery.InitCheck() != B_OK) {
|
||||||
dprintf("PPPoE: received corrupted discovery packet!\n");
|
ERROR("PPPoE: received corrupted discovery packet!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -171,21 +166,17 @@ pppoe_input(struct mbuf *packet)
|
|||||||
if(device && device->EthernetIfnet() == sourceIfnet) {
|
if(device && device->EthernetIfnet() == sourceIfnet) {
|
||||||
if(header->ethernetHeader.ether_type == ETHERTYPE_PPPOE
|
if(header->ethernetHeader.ether_type == ETHERTYPE_PPPOE
|
||||||
&& header->pppoeHeader.sessionID == device->SessionID()) {
|
&& header->pppoeHeader.sessionID == device->SessionID()) {
|
||||||
#if DEBUG
|
TRACE("PPPoE: session packet\n");
|
||||||
dprintf("PPPoE: session packet\n");
|
|
||||||
#endif
|
|
||||||
device->Receive(packet);
|
device->Receive(packet);
|
||||||
return;
|
return;
|
||||||
} else if(header->ethernetHeader.ether_type == ETHERTYPE_PPPOEDISC
|
} else if(header->ethernetHeader.ether_type == ETHERTYPE_PPPOEDISC
|
||||||
&& header->pppoeHeader.code != PADI
|
&& header->pppoeHeader.code != PADI
|
||||||
&& header->pppoeHeader.code != PADR
|
&& header->pppoeHeader.code != PADR
|
||||||
&& !device->IsDown()) {
|
&& !device->IsDown()) {
|
||||||
#if DEBUG
|
TRACE("PPPoE: discovery packet\n");
|
||||||
dprintf("PPPoE: discovery packet\n");
|
|
||||||
#endif
|
|
||||||
DiscoveryPacket discovery(packet, ETHER_HDR_LEN);
|
DiscoveryPacket discovery(packet, ETHER_HDR_LEN);
|
||||||
if(discovery.InitCheck() != B_OK) {
|
if(discovery.InitCheck() != B_OK) {
|
||||||
dprintf("PPPoE: received corrupted discovery packet!\n");
|
ERROR("PPPoE: received corrupted discovery packet!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -200,7 +191,7 @@ pppoe_input(struct mbuf *packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf("PPPoE: No device found for packet from: %s\n", sourceIfnet->if_name);
|
ERROR("PPPoE: No device found for packet from: %s\n", sourceIfnet->if_name);
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,10 +214,8 @@ add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface,
|
|||||||
success = mainInterface.SetDevice(device);
|
success = mainInterface.SetDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("PPPoE: add_to(): %s\n",
|
||||||
dprintf("PPPoE: add_to(): %s\n",
|
|
||||||
success && device && device->InitCheck() == B_OK ? "OK" : "ERROR");
|
success && device && device->InitCheck() == B_OK ? "OK" : "ERROR");
|
||||||
#endif
|
|
||||||
|
|
||||||
return success && device && device->InitCheck() == B_OK;
|
return success && device && device->InitCheck() == B_OK;
|
||||||
}
|
}
|
||||||
@@ -319,22 +308,19 @@ std_ops(int32 op, ...)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_max_linkhdr(PPPoE_HEADER_SIZE + ETHER_HDR_LEN);
|
set_max_linkhdr(2 + PPPoE_HEADER_SIZE + ETHER_HDR_LEN);
|
||||||
|
// 2 bytes for PPP header
|
||||||
sDevices = new TemplateList<PPPoEDevice*>;
|
sDevices = new TemplateList<PPPoEDevice*>;
|
||||||
sQueries = new TemplateList<pppoe_query*>;
|
sQueries = new TemplateList<pppoe_query*>;
|
||||||
sEthernet->set_pppoe_receiver(pppoe_input);
|
sEthernet->set_pppoe_receiver(pppoe_input);
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("PPPoE: Registered PPPoE receiver.\n");
|
||||||
dprintf("PPPoE: Registered PPPoE receiver.\n");
|
|
||||||
#endif
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
case B_MODULE_UNINIT:
|
case B_MODULE_UNINIT:
|
||||||
delete sDevices;
|
delete sDevices;
|
||||||
sEthernet->unset_pppoe_receiver();
|
sEthernet->unset_pppoe_receiver();
|
||||||
#if DEBUG
|
TRACE("PPPoE: Unregistered PPPoE receiver.\n");
|
||||||
dprintf("PPPoE: Unregistered PPPoE receiver.\n");
|
|
||||||
#endif
|
|
||||||
put_module(NET_CORE_MODULE_NAME);
|
put_module(NET_CORE_MODULE_NAME);
|
||||||
put_module(NET_ETHERNET_MODULE_NAME);
|
put_module(NET_ETHERNET_MODULE_NAME);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPConfigurePacket
|
/*! \class KPPPConfigurePacket
|
||||||
\brief Helper class for LCP configure packets.
|
\brief Helper class for LCP configure packets.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPDevice
|
/*! \class KPPPDevice
|
||||||
\brief Represents a device at the lowest level of the communcation stack.
|
\brief Represents a device at the lowest level of the communcation stack.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPInterface
|
/*! \class KPPPInterface
|
||||||
\brief The kernel representation of a PPP interface.
|
\brief The kernel representation of a PPP interface.
|
||||||
@@ -21,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// cstdio must be included before KPPPModule.h/KPPPManager.h because
|
// cstdio must be included before KPPPModule.h/KPPPManager.h because
|
||||||
// ddprintf is defined twice with different return values, once with
|
// dprintf is defined twice with different return values, once with
|
||||||
// void (KernelExport.h) and once with int (stdio.h).
|
// void (KernelExport.h) and once with int (stdio.h).
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -52,7 +50,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// - implement timers with support for settings next time instead of receiving timer
|
// - implement timers with support for setting next event instead of receiving timer
|
||||||
// events periodically
|
// events periodically
|
||||||
// - add missing settings support (DialRetryDelay, etc.)
|
// - add missing settings support (DialRetryDelay, etc.)
|
||||||
|
|
||||||
@@ -154,7 +152,7 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
|||||||
_KPPPMRUHandler *mruHandler =
|
_KPPPMRUHandler *mruHandler =
|
||||||
new _KPPPMRUHandler(*this);
|
new _KPPPMRUHandler(*this);
|
||||||
if(!LCP().AddOptionHandler(mruHandler) || mruHandler->InitCheck() != B_OK) {
|
if(!LCP().AddOptionHandler(mruHandler) || mruHandler->InitCheck() != B_OK) {
|
||||||
dprintf("KPPPInterface: Could not add MRU handler!\n");
|
ERROR("KPPPInterface: Could not add MRU handler!\n");
|
||||||
delete mruHandler;
|
delete mruHandler;
|
||||||
}
|
}
|
||||||
// authentication
|
// authentication
|
||||||
@@ -162,14 +160,14 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
|||||||
new _KPPPAuthenticationHandler(*this);
|
new _KPPPAuthenticationHandler(*this);
|
||||||
if(!LCP().AddOptionHandler(authenticationHandler)
|
if(!LCP().AddOptionHandler(authenticationHandler)
|
||||||
|| authenticationHandler->InitCheck() != B_OK) {
|
|| authenticationHandler->InitCheck() != B_OK) {
|
||||||
dprintf("KPPPInterface: Could not add authentication handler!\n");
|
ERROR("KPPPInterface: Could not add authentication handler!\n");
|
||||||
delete authenticationHandler;
|
delete authenticationHandler;
|
||||||
}
|
}
|
||||||
// PFC
|
// PFC
|
||||||
_KPPPPFCHandler *pfcHandler =
|
_KPPPPFCHandler *pfcHandler =
|
||||||
new _KPPPPFCHandler(fLocalPFCState, fPeerPFCState, *this);
|
new _KPPPPFCHandler(fLocalPFCState, fPeerPFCState, *this);
|
||||||
if(!LCP().AddOptionHandler(pfcHandler) || pfcHandler->InitCheck() != B_OK) {
|
if(!LCP().AddOptionHandler(pfcHandler) || pfcHandler->InitCheck() != B_OK) {
|
||||||
dprintf("KPPPInterface: Could not add PFC handler!\n");
|
ERROR("KPPPInterface: Could not add PFC handler!\n");
|
||||||
delete pfcHandler;
|
delete pfcHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +178,7 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
|||||||
// 1s delay between lost connection and redial
|
// 1s delay between lost connection and redial
|
||||||
|
|
||||||
if(get_module(PPP_INTERFACE_MODULE_NAME, (module_info**) &fManager) != B_OK)
|
if(get_module(PPP_INTERFACE_MODULE_NAME, (module_info**) &fManager) != B_OK)
|
||||||
dprintf("KPPPInterface: Manager module not found!\n");
|
ERROR("KPPPInterface: Manager module not found!\n");
|
||||||
|
|
||||||
// are we a multilink subinterface?
|
// are we a multilink subinterface?
|
||||||
if(parent && parent->IsMultilink()) {
|
if(parent && parent->IsMultilink()) {
|
||||||
@@ -225,7 +223,7 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
|||||||
|
|
||||||
// load all protocols and the device
|
// load all protocols and the device
|
||||||
if(!LoadModules(fSettings, 0, fSettings->parameter_count)) {
|
if(!LoadModules(fSettings, 0, fSettings->parameter_count)) {
|
||||||
dprintf("KPPPInterface: Error loading modules!\n");
|
ERROR("KPPPInterface: Error loading modules!\n");
|
||||||
fInitStatus = B_ERROR;
|
fInitStatus = B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,9 +232,7 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry,
|
|||||||
//! Destructor: Disconnects and marks interface for deletion.
|
//! Destructor: Disconnects and marks interface for deletion.
|
||||||
KPPPInterface::~KPPPInterface()
|
KPPPInterface::~KPPPInterface()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: Destructor\n");
|
||||||
dprintf("KPPPInterface: Destructor\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
++fDeleteCounter;
|
++fDeleteCounter;
|
||||||
|
|
||||||
@@ -347,9 +343,7 @@ KPPPInterface::InitCheck() const
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::SetMRU(uint32 MRU)
|
KPPPInterface::SetMRU(uint32 MRU)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: SetMRU(%ld)\n", MRU);
|
||||||
dprintf("KPPPInterface: SetMRU(%ld)\n", MRU);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(Device() && MRU > Device()->MTU() - 2)
|
if(Device() && MRU > Device()->MTU() - 2)
|
||||||
return false;
|
return false;
|
||||||
@@ -579,9 +573,7 @@ KPPPInterface::Control(uint32 op, void *data, size_t length)
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::SetDevice(KPPPDevice *device)
|
KPPPInterface::SetDevice(KPPPDevice *device)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: SetDevice(%p)\n", device);
|
||||||
dprintf("KPPPInterface: SetDevice(%p)\n", device);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(device && &device->Interface() != this)
|
if(device && &device->Interface() != this)
|
||||||
return false;
|
return false;
|
||||||
@@ -628,13 +620,11 @@ KPPPInterface::SetDevice(KPPPDevice *device)
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::AddProtocol(KPPPProtocol *protocol)
|
KPPPInterface::AddProtocol(KPPPProtocol *protocol)
|
||||||
{
|
{
|
||||||
// Find instert position after the last protocol
|
// Find insert position after the last protocol
|
||||||
// with the same level.
|
// with the same level.
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: AddProtocol(%X)\n",
|
||||||
dprintf("KPPPInterface: AddProtocol(%X)\n",
|
|
||||||
protocol ? protocol->ProtocolNumber() : 0);
|
protocol ? protocol->ProtocolNumber() : 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!protocol || &protocol->Interface() != this
|
if(!protocol || &protocol->Interface() != this
|
||||||
|| protocol->Level() == PPP_INTERFACE_LEVEL)
|
|| protocol->Level() == PPP_INTERFACE_LEVEL)
|
||||||
@@ -701,10 +691,8 @@ KPPPInterface::AddProtocol(KPPPProtocol *protocol)
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::RemoveProtocol(KPPPProtocol *protocol)
|
KPPPInterface::RemoveProtocol(KPPPProtocol *protocol)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: RemoveProtocol(%X)\n",
|
||||||
dprintf("KPPPInterface: RemoveProtocol(%X)\n",
|
|
||||||
protocol ? protocol->ProtocolNumber() : 0);
|
protocol ? protocol->ProtocolNumber() : 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -781,9 +769,7 @@ KPPPInterface::ProtocolAt(int32 index) const
|
|||||||
KPPPProtocol*
|
KPPPProtocol*
|
||||||
KPPPInterface::ProtocolFor(uint16 protocolNumber, KPPPProtocol *start = NULL) const
|
KPPPInterface::ProtocolFor(uint16 protocolNumber, KPPPProtocol *start = NULL) const
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: ProtocolFor(%X)\n", protocolNumber);
|
||||||
dprintf("KPPPInterface: ProtocolFor(%X)\n", protocolNumber);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
KPPPProtocol *current = start ? start : FirstProtocol();
|
KPPPProtocol *current = start ? start : FirstProtocol();
|
||||||
|
|
||||||
@@ -803,10 +789,7 @@ KPPPInterface::ProtocolFor(uint16 protocolNumber, KPPPProtocol *start = NULL) co
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::AddChild(KPPPInterface *child)
|
KPPPInterface::AddChild(KPPPInterface *child)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: AddChild(%lX)\n", child ? child->ID() : 0);
|
||||||
dprintf("KPPPInterface: AddChild(%lX)\n",
|
|
||||||
child ? child->ID() : 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!child)
|
if(!child)
|
||||||
return false;
|
return false;
|
||||||
@@ -826,10 +809,7 @@ KPPPInterface::AddChild(KPPPInterface *child)
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::RemoveChild(KPPPInterface *child)
|
KPPPInterface::RemoveChild(KPPPInterface *child)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: RemoveChild(%lX)\n", child ? child->ID() : 0);
|
||||||
dprintf("KPPPInterface: RemoveChild(%lX)\n",
|
|
||||||
child ? child->ID() : 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -850,9 +830,7 @@ KPPPInterface::RemoveChild(KPPPInterface *child)
|
|||||||
KPPPInterface*
|
KPPPInterface*
|
||||||
KPPPInterface::ChildAt(int32 index) const
|
KPPPInterface::ChildAt(int32 index) const
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: ChildAt(%ld)\n", index);
|
||||||
dprintf("KPPPInterface: ChildAt(%ld)\n", index);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
KPPPInterface *child = fChildren.ItemAt(index);
|
KPPPInterface *child = fChildren.ItemAt(index);
|
||||||
|
|
||||||
@@ -867,9 +845,7 @@ KPPPInterface::ChildAt(int32 index) const
|
|||||||
void
|
void
|
||||||
KPPPInterface::SetAutoRedial(bool autoRedial = true)
|
KPPPInterface::SetAutoRedial(bool autoRedial = true)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false");
|
||||||
dprintf("KPPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(Mode() != PPP_CLIENT_MODE)
|
if(Mode() != PPP_CLIENT_MODE)
|
||||||
return;
|
return;
|
||||||
@@ -887,15 +863,11 @@ KPPPInterface::SetDialOnDemand(bool dialOnDemand = true)
|
|||||||
// All protocols must check if DialOnDemand was enabled/disabled after this
|
// All protocols must check if DialOnDemand was enabled/disabled after this
|
||||||
// interface went down. This is the only situation where a change is relevant.
|
// interface went down. This is the only situation where a change is relevant.
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false");
|
||||||
dprintf("KPPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Only clients support DialOnDemand.
|
// Only clients support DialOnDemand.
|
||||||
if(Mode() != PPP_CLIENT_MODE) {
|
if(Mode() != PPP_CLIENT_MODE) {
|
||||||
#if DEBUG
|
TRACE("KPPPInterface::SetDialOnDemand(): Wrong mode!\n");
|
||||||
dprintf("KPPPInterface::SetDialOnDemand(): Wrong mode!\n");
|
|
||||||
#endif
|
|
||||||
fDialOnDemand = false;
|
fDialOnDemand = false;
|
||||||
return;
|
return;
|
||||||
} else if(DoesDialOnDemand() == dialOnDemand)
|
} else if(DoesDialOnDemand() == dialOnDemand)
|
||||||
@@ -933,9 +905,7 @@ KPPPInterface::SetDialOnDemand(bool dialOnDemand = true)
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::SetPFCOptions(uint8 pfcOptions)
|
KPPPInterface::SetPFCOptions(uint8 pfcOptions)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: SetPFCOptions(0x%X)\n", pfcOptions);
|
||||||
dprintf("KPPPInterface: SetPFCOptions(0x%X)\n", pfcOptions);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(PFCOptions() & PPP_FREEZE_PFC_OPTIONS)
|
if(PFCOptions() & PPP_FREEZE_PFC_OPTIONS)
|
||||||
return false;
|
return false;
|
||||||
@@ -955,9 +925,7 @@ KPPPInterface::SetPFCOptions(uint8 pfcOptions)
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::Up()
|
KPPPInterface::Up()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: Up()\n");
|
||||||
dprintf("KPPPInterface: Up()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(InitCheck() != B_OK || Phase() == PPP_TERMINATION_PHASE)
|
if(InitCheck() != B_OK || Phase() == PPP_TERMINATION_PHASE)
|
||||||
return false;
|
return false;
|
||||||
@@ -973,6 +941,7 @@ KPPPInterface::Up()
|
|||||||
while(fLock.LockWithTimeout(100000) != B_NO_ERROR)
|
while(fLock.LockWithTimeout(100000) != B_NO_ERROR)
|
||||||
if(fDeleteCounter > 0)
|
if(fDeleteCounter > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(fUpThread == -1)
|
if(fUpThread == -1)
|
||||||
fUpThread = me;
|
fUpThread = me;
|
||||||
|
|
||||||
@@ -1003,10 +972,8 @@ KPPPInterface::Up()
|
|||||||
if(receive_data(&sender, &report, sizeof(report)) != PPP_REPORT_CODE)
|
if(receive_data(&sender, &report, sizeof(report)) != PPP_REPORT_CODE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//#if DEBUG
|
// TRACE("KPPPInterface::Up(): Report: Type = %ld Code = %ld\n", report.type,
|
||||||
// dprintf("KPPPInterface::Up(): Report: Type = %ld Code = %ld\n", report.type,
|
|
||||||
// report.code);
|
// report.code);
|
||||||
//#endif
|
|
||||||
|
|
||||||
if(IsUp()) {
|
if(IsUp()) {
|
||||||
if(me == fUpThread) {
|
if(me == fUpThread) {
|
||||||
@@ -1014,8 +981,7 @@ KPPPInterface::Up()
|
|||||||
fUpThread = -1;
|
fUpThread = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||||
ReportManager().DisableReports(PPP_CONNECTION_REPORT, me);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1025,8 +991,7 @@ KPPPInterface::Up()
|
|||||||
fUpThread = -1;
|
fUpThread = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||||
ReportManager().DisableReports(PPP_CONNECTION_REPORT, me);
|
|
||||||
return false;
|
return false;
|
||||||
} else if(report.type != PPP_CONNECTION_REPORT) {
|
} else if(report.type != PPP_CONNECTION_REPORT) {
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, B_OK);
|
||||||
@@ -1044,8 +1009,7 @@ KPPPInterface::Up()
|
|||||||
// notify redial thread that we do not need it anymore
|
// notify redial thread that we do not need it anymore
|
||||||
}
|
}
|
||||||
|
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||||
ReportManager().DisableReports(PPP_CONNECTION_REPORT, me);
|
|
||||||
return true;
|
return true;
|
||||||
} else if(report.code == PPP_REPORT_DOWN_SUCCESSFUL
|
} else if(report.code == PPP_REPORT_DOWN_SUCCESSFUL
|
||||||
|| report.code == PPP_REPORT_UP_ABORTED
|
|| report.code == PPP_REPORT_UP_ABORTED
|
||||||
@@ -1055,12 +1019,11 @@ KPPPInterface::Up()
|
|||||||
fDialRetry = 0;
|
fDialRetry = 0;
|
||||||
fUpThread = -1;
|
fUpThread = -1;
|
||||||
|
|
||||||
if(!DoesDialOnDemand() && report.code != PPP_REPORT_DOWN_SUCCESSFUL)
|
if(report.code != PPP_REPORT_DOWN_SUCCESSFUL)
|
||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||||
ReportManager().DisableReports(PPP_CONNECTION_REPORT, me);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1068,8 +1031,7 @@ KPPPInterface::Up()
|
|||||||
// I am an observer
|
// I am an observer
|
||||||
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
|
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
|
||||||
if(fDialRetry >= fDialRetriesLimit || fUpThread == -1) {
|
if(fDialRetry >= fDialRetriesLimit || fUpThread == -1) {
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||||
ReportManager().DisableReports(PPP_CONNECTION_REPORT, me);
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, B_OK);
|
||||||
@@ -1080,8 +1042,7 @@ KPPPInterface::Up()
|
|||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, B_OK);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||||
ReportManager().DisableReports(PPP_CONNECTION_REPORT, me);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1089,27 +1050,20 @@ KPPPInterface::Up()
|
|||||||
// I am the thread for the real task
|
// I am the thread for the real task
|
||||||
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
|
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
|
||||||
if(fDialRetry >= fDialRetriesLimit) {
|
if(fDialRetry >= fDialRetriesLimit) {
|
||||||
#if DEBUG
|
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n");
|
||||||
dprintf("KPPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n");
|
|
||||||
#endif
|
|
||||||
fDialRetry = 0;
|
fDialRetry = 0;
|
||||||
fUpThread = -1;
|
fUpThread = -1;
|
||||||
|
|
||||||
if(!DoesDialOnDemand())
|
|
||||||
Delete();
|
Delete();
|
||||||
|
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||||
|
|
||||||
PPP_REPLY(sender, B_OK);
|
|
||||||
ReportManager().DisableReports(PPP_CONNECTION_REPORT, me);
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
#if DEBUG
|
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: <maxretries\n");
|
||||||
dprintf("KPPPInterface::Up(): DEVICE_UP_FAILED: <maxretries\n");
|
|
||||||
#endif
|
|
||||||
++fDialRetry;
|
++fDialRetry;
|
||||||
PPP_REPLY(sender, B_OK);
|
PPP_REPLY(sender, B_OK);
|
||||||
#if DEBUG
|
TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: replied\n");
|
||||||
dprintf("KPPPInterface::Up(): DEVICE_UP_FAILED: replied\n");
|
|
||||||
#endif
|
|
||||||
Redial(DialRetryDelay());
|
Redial(DialRetryDelay());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1124,11 +1078,8 @@ KPPPInterface::Up()
|
|||||||
} else {
|
} else {
|
||||||
fDialRetry = 0;
|
fDialRetry = 0;
|
||||||
fUpThread = -1;
|
fUpThread = -1;
|
||||||
PPP_REPLY(sender, B_OK);
|
|
||||||
ReportManager().DisableReports(PPP_CONNECTION_REPORT, me);
|
|
||||||
|
|
||||||
if(!DoesDialOnDemand())
|
|
||||||
Delete();
|
Delete();
|
||||||
|
PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1153,9 +1104,7 @@ KPPPInterface::Up()
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::Down()
|
KPPPInterface::Down()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: Down()\n");
|
||||||
dprintf("KPPPInterface: Down()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(InitCheck() != B_OK)
|
if(InitCheck() != B_OK)
|
||||||
return false;
|
return false;
|
||||||
@@ -1204,9 +1153,7 @@ KPPPInterface::Down()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!DoesDialOnDemand())
|
|
||||||
Delete();
|
Delete();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1232,9 +1179,7 @@ KPPPInterface::IsUp() const
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::LoadModules(driver_settings *settings, int32 start, int32 count)
|
KPPPInterface::LoadModules(driver_settings *settings, int32 start, int32 count)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: LoadModules()\n");
|
||||||
dprintf("KPPPInterface: LoadModules()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(Phase() != PPP_DOWN_PHASE)
|
if(Phase() != PPP_DOWN_PHASE)
|
||||||
return false;
|
return false;
|
||||||
@@ -1304,9 +1249,7 @@ bool
|
|||||||
KPPPInterface::LoadModule(const char *name, driver_parameter *parameter,
|
KPPPInterface::LoadModule(const char *name, driver_parameter *parameter,
|
||||||
ppp_module_key_type type)
|
ppp_module_key_type type)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: LoadModule(%s)\n", name ? name : "XXX: NO NAME");
|
||||||
dprintf("KPPPInterface: LoadModule(%s)\n", name ? name : "XXX: NO NAME");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(Phase() != PPP_DOWN_PHASE)
|
if(Phase() != PPP_DOWN_PHASE)
|
||||||
return false;
|
return false;
|
||||||
@@ -1357,9 +1300,7 @@ KPPPInterface::IsAllowedToSend() const
|
|||||||
status_t
|
status_t
|
||||||
KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: Send(0x%X)\n", protocolNumber);
|
||||||
dprintf("KPPPInterface: Send(0x%X)\n", protocolNumber);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -1389,21 +1330,21 @@ KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(!protocol)
|
if(!protocol)
|
||||||
dprintf("KPPPInterface::Send(): no protocol found!\n");
|
TRACE("KPPPInterface::Send(): no protocol found!\n");
|
||||||
else if(!Device()->IsUp())
|
else if(!Device()->IsUp())
|
||||||
dprintf("KPPPInterface::Send(): device is not up!\n");
|
TRACE("KPPPInterface::Send(): device is not up!\n");
|
||||||
else if(!protocol->IsEnabled())
|
else if(!protocol->IsEnabled())
|
||||||
dprintf("KPPPInterface::Send(): protocol not enabled!\n");
|
TRACE("KPPPInterface::Send(): protocol not enabled!\n");
|
||||||
else if(!IsProtocolAllowed(*protocol))
|
else if(!IsProtocolAllowed(*protocol))
|
||||||
dprintf("KPPPInterface::Send(): protocol not allowed to send!\n");
|
TRACE("KPPPInterface::Send(): protocol not allowed to send!\n");
|
||||||
else
|
else
|
||||||
dprintf("KPPPInterface::Send(): protocol allowed\n");
|
TRACE("KPPPInterface::Send(): protocol allowed\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// make sure that protocol is allowed to send and everything is up
|
// make sure that protocol is allowed to send and everything is up
|
||||||
if(!Device()->IsUp() || !protocol || !protocol->IsEnabled()
|
if(!Device()->IsUp() || !protocol || !protocol->IsEnabled()
|
||||||
|| !IsProtocolAllowed(*protocol)) {
|
|| !IsProtocolAllowed(*protocol)) {
|
||||||
dprintf("KPPPInterface::Send(): cannot send!\n");
|
ERROR("KPPPInterface::Send(): cannot send!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -1468,9 +1409,7 @@ KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
status_t
|
status_t
|
||||||
KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: Receive(0x%X)\n", protocolNumber);
|
||||||
dprintf("KPPPInterface: Receive(0x%X)\n", protocolNumber);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -1494,9 +1433,7 @@ KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
for(; protocol;
|
for(; protocol;
|
||||||
protocol = protocol->NextProtocol() ?
|
protocol = protocol->NextProtocol() ?
|
||||||
ProtocolFor(protocolNumber, protocol->NextProtocol()) : NULL) {
|
ProtocolFor(protocolNumber, protocol->NextProtocol()) : NULL) {
|
||||||
#if DEBUG
|
TRACE("KPPPInterface::Receive(): trying protocol\n");
|
||||||
dprintf("KPPPInterface::Receive(): trying protocol\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!protocol->IsEnabled() || !IsProtocolAllowed(*protocol))
|
if(!protocol->IsEnabled() || !IsProtocolAllowed(*protocol))
|
||||||
continue;
|
continue;
|
||||||
@@ -1509,9 +1446,7 @@ KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("KPPPInterface::Receive(): trying parent\n");
|
||||||
dprintf("KPPPInterface::Receive(): trying parent\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// maybe the parent interface can handle the packet
|
// maybe the parent interface can handle the packet
|
||||||
if(Parent())
|
if(Parent())
|
||||||
@@ -1543,9 +1478,7 @@ KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
status_t
|
status_t
|
||||||
KPPPInterface::ReceiveFromDevice(struct mbuf *packet)
|
KPPPInterface::ReceiveFromDevice(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: ReceiveFromDevice()\n");
|
||||||
dprintf("KPPPInterface: ReceiveFromDevice()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -1596,9 +1529,7 @@ KPPPInterface::Pulse()
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::RegisterInterface()
|
KPPPInterface::RegisterInterface()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: RegisterInterface()\n");
|
||||||
dprintf("KPPPInterface: RegisterInterface()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(fIfnet)
|
if(fIfnet)
|
||||||
return true;
|
return true;
|
||||||
@@ -1632,9 +1563,7 @@ KPPPInterface::RegisterInterface()
|
|||||||
bool
|
bool
|
||||||
KPPPInterface::UnregisterInterface()
|
KPPPInterface::UnregisterInterface()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: UnregisterInterface()\n");
|
||||||
dprintf("KPPPInterface: UnregisterInterface()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!fIfnet)
|
if(!fIfnet)
|
||||||
return true;
|
return true;
|
||||||
@@ -1671,9 +1600,7 @@ KPPPInterface::UpdateProfile()
|
|||||||
status_t
|
status_t
|
||||||
KPPPInterface::StackControl(uint32 op, void *data)
|
KPPPInterface::StackControl(uint32 op, void *data)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: StackControl(0x%lX)\n", op);
|
||||||
dprintf("KPPPInterface: StackControl(0x%lX)\n", op);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch(op) {
|
switch(op) {
|
||||||
default:
|
default:
|
||||||
@@ -1716,9 +1643,7 @@ class CallStackControl {
|
|||||||
status_t
|
status_t
|
||||||
KPPPInterface::StackControlEachHandler(uint32 op, void *data)
|
KPPPInterface::StackControlEachHandler(uint32 op, void *data)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: StackControlEachHandler(0x%lX)\n", op);
|
||||||
dprintf("KPPPInterface: StackControlEachHandler(0x%lX)\n", op);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
status_t result = B_BAD_VALUE, tmp;
|
status_t result = B_BAD_VALUE, tmp;
|
||||||
|
|
||||||
@@ -1744,9 +1669,7 @@ KPPPInterface::StackControlEachHandler(uint32 op, void *data)
|
|||||||
void
|
void
|
||||||
KPPPInterface::CalculateInterfaceMTU()
|
KPPPInterface::CalculateInterfaceMTU()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: CalculateInterfaceMTU()\n");
|
||||||
dprintf("KPPPInterface: CalculateInterfaceMTU()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fInterfaceMTU = fMRU;
|
fInterfaceMTU = fMRU;
|
||||||
fHeaderLength = 2;
|
fHeaderLength = 2;
|
||||||
@@ -1774,9 +1697,7 @@ KPPPInterface::CalculateInterfaceMTU()
|
|||||||
void
|
void
|
||||||
KPPPInterface::CalculateBaudRate()
|
KPPPInterface::CalculateBaudRate()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: CalculateBaudRate()\n");
|
||||||
dprintf("KPPPInterface: CalculateBaudRate()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!Ifnet())
|
if(!Ifnet())
|
||||||
return;
|
return;
|
||||||
@@ -1797,9 +1718,7 @@ KPPPInterface::CalculateBaudRate()
|
|||||||
void
|
void
|
||||||
KPPPInterface::Redial(uint32 delay)
|
KPPPInterface::Redial(uint32 delay)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPInterface: Redial(%ld)\n", delay);
|
||||||
dprintf("KPPPInterface: Redial(%ld)\n", delay);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(fRedialThread != -1)
|
if(fRedialThread != -1)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPLCP
|
/*! \class KPPPLCP
|
||||||
\brief The LCP protocol.
|
\brief The LCP protocol.
|
||||||
@@ -279,7 +277,7 @@ KPPPLCP::Receive(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
if(protocolNumber != PPP_LCP_PROTOCOL) {
|
if(protocolNumber != PPP_LCP_PROTOCOL) {
|
||||||
dprintf("KPPPLCP::Receive(): wrong protocol number!\n");
|
ERROR("KPPPLCP::Receive(): wrong protocol number!\n");
|
||||||
return PPP_UNHANDLED;
|
return PPP_UNHANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPLCPExtension
|
/*! \class KPPPLCPExtension
|
||||||
\brief LCP protocol extension
|
\brief LCP protocol extension
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPLayer
|
/*! \class KPPPLayer
|
||||||
\brief An abstract layer that can encapsulate/send and receive packets.
|
\brief An abstract layer that can encapsulate/send and receive packets.
|
||||||
@@ -84,7 +82,7 @@ KPPPLayer::SendToNext(struct mbuf *packet, uint16 protocolNumber) const
|
|||||||
else
|
else
|
||||||
return Next()->SendToNext(packet, protocolNumber);
|
return Next()->SendToNext(packet, protocolNumber);
|
||||||
} else {
|
} else {
|
||||||
dprintf("KPPPLayer: SendToNext() failed because there is no next handler!\n");
|
ERROR("KPPPLayer: SendToNext() failed because there is no next handler!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPOptionHandler
|
/*! \class KPPPOptionHandler
|
||||||
\brief Handler for LCP configure packets.
|
\brief Handler for LCP configure packets.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPProfile
|
/*! \class KPPPProfile
|
||||||
\brief Manages profiles for KPPPInterface.
|
\brief Manages profiles for KPPPInterface.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPProtocol.
|
/*! \class KPPPProtocol.
|
||||||
\brief Represents a PPP protocol object.
|
\brief Represents a PPP protocol object.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPReportManager
|
/*! \class KPPPReportManager
|
||||||
\brief Manager for PPP reports and report requests.
|
\brief Manager for PPP reports and report requests.
|
||||||
@@ -117,10 +115,8 @@ KPPPReportManager::DoesReport(ppp_report_type type, thread_id thread)
|
|||||||
bool
|
bool
|
||||||
KPPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 length)
|
KPPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 length)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPReportManager: Report(type=%d code=%ld length=%ld) to %ld receivers\n",
|
||||||
dprintf("KPPPReportManager: Report(type=%d code=%ld length=%ld) to %ld receivers\n",
|
|
||||||
type, code, length, fReportRequests.CountItems());
|
type, code, length, fReportRequests.CountItems());
|
||||||
#endif
|
|
||||||
|
|
||||||
if(length > PPP_REPORT_DATA_LIMIT)
|
if(length > PPP_REPORT_DATA_LIMIT)
|
||||||
return false;
|
return false;
|
||||||
@@ -157,7 +153,7 @@ KPPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 le
|
|||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(result == B_TIMED_OUT)
|
if(result == B_TIMED_OUT)
|
||||||
dprintf("KPPPReportManager::Report(): timed out sending\n");
|
TRACE("KPPPReportManager::Report(): timed out sending\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thread_info info;
|
thread_info info;
|
||||||
@@ -194,31 +190,29 @@ KPPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 le
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(sender != request->thread) {
|
if(sender != request->thread) {
|
||||||
#if DEBUG
|
TRACE("KPPPReportManager::Report(): sender != requested\n");
|
||||||
dprintf("KPPPReportManager::Report(): sender != requested\n");
|
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result == B_OK && code != B_OK)
|
if(result == B_OK && code != B_OK && code != PPP_OK_DISABLE_REPORTS)
|
||||||
acceptable = false;
|
acceptable = false;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(result == B_TIMED_OUT)
|
if(result == B_TIMED_OUT)
|
||||||
dprintf("KPPPReportManager::Report(): reply timed out\n");
|
TRACE("KPPPReportManager::Report(): reply timed out\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove thread if it is not existant or if remove-flag is set
|
// remove thread if it is not existant or if remove-flag is set
|
||||||
if(request->flags & PPP_REMOVE_AFTER_REPORT
|
if(request->flags & PPP_REMOVE_AFTER_REPORT
|
||||||
|| get_thread_info(request->thread, &info) != B_OK) {
|
|| get_thread_info(request->thread, &info) != B_OK
|
||||||
|
|| code == PPP_OK_DISABLE_REPORTS) {
|
||||||
fReportRequests.RemoveItem(request);
|
fReportRequests.RemoveItem(request);
|
||||||
--index;
|
--index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("KPPPReportManager::Report(): returning: %s\n", acceptable?"true":"false");
|
||||||
dprintf("KPPPReportManager::Report(): returning: %s\n", acceptable?"true":"false");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return acceptable;
|
return acceptable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class KPPPStateMachine
|
/*! \class KPPPStateMachine
|
||||||
\brief PPP state machine belonging to the LCP protocol
|
\brief PPP state machine belonging to the LCP protocol
|
||||||
@@ -49,7 +47,8 @@ KPPPStateMachine::KPPPStateMachine(KPPPInterface& interface)
|
|||||||
fRequestID(0),
|
fRequestID(0),
|
||||||
fTerminateID(0),
|
fTerminateID(0),
|
||||||
fEchoID(0),
|
fEchoID(0),
|
||||||
fNextTimeout(0)
|
fNextTimeout(0),
|
||||||
|
fLock("KPPPStateMachine")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,9 +77,7 @@ KPPPStateMachine::NextID()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::NewState(ppp_state next)
|
KPPPStateMachine::NewState(ppp_state next)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: NewState(%d) state=%d\n", next, State());
|
||||||
dprintf("KPPPSM: NewState(%d) state=%d\n", next, State());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// maybe we do not need the timer anymore
|
// maybe we do not need the timer anymore
|
||||||
if(next < PPP_CLOSING_STATE || next == PPP_OPENED_STATE)
|
if(next < PPP_CLOSING_STATE || next == PPP_OPENED_STATE)
|
||||||
@@ -103,7 +100,7 @@ KPPPStateMachine::NewPhase(ppp_phase next)
|
|||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(next <= PPP_ESTABLISHMENT_PHASE || next == PPP_ESTABLISHED_PHASE)
|
if(next <= PPP_ESTABLISHMENT_PHASE || next == PPP_ESTABLISHED_PHASE)
|
||||||
dprintf("KPPPSM: NewPhase(%d) phase=%d\n", next, Phase());
|
TRACE("KPPPSM: NewPhase(%d) phase=%d\n", next, Phase());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// there is nothing after established phase and nothing before down phase
|
// there is nothing after established phase and nothing before down phase
|
||||||
@@ -117,8 +114,6 @@ KPPPStateMachine::NewPhase(ppp_phase next)
|
|||||||
if(Phase() == PPP_ESTABLISHED_PHASE && next != Phase()) {
|
if(Phase() == PPP_ESTABLISHED_PHASE && next != Phase()) {
|
||||||
if(Interface().Ifnet()) {
|
if(Interface().Ifnet()) {
|
||||||
Interface().Ifnet()->if_flags &= ~IFF_RUNNING;
|
Interface().Ifnet()->if_flags &= ~IFF_RUNNING;
|
||||||
|
|
||||||
if(!Interface().DoesDialOnDemand())
|
|
||||||
Interface().Ifnet()->if_flags &= ~IFF_UP;
|
Interface().Ifnet()->if_flags &= ~IFF_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,10 +139,7 @@ KPPPStateMachine::NewPhase(ppp_phase next)
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::Reconfigure()
|
KPPPStateMachine::Reconfigure()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: Reconfigure() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: Reconfigure() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -171,10 +163,7 @@ KPPPStateMachine::Reconfigure()
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendEchoRequest()
|
KPPPStateMachine::SendEchoRequest()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendEchoRequest() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: SendEchoRequest() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(State() != PPP_OPENED_STATE)
|
if(State() != PPP_OPENED_STATE)
|
||||||
return false;
|
return false;
|
||||||
@@ -202,10 +191,7 @@ KPPPStateMachine::SendEchoRequest()
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendDiscardRequest()
|
KPPPStateMachine::SendDiscardRequest()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendDiscardRequest() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: SendDiscardRequest() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(State() != PPP_OPENED_STATE)
|
if(State() != PPP_OPENED_STATE)
|
||||||
return false;
|
return false;
|
||||||
@@ -237,10 +223,8 @@ KPPPStateMachine::SendDiscardRequest()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::LocalAuthenticationRequested()
|
KPPPStateMachine::LocalAuthenticationRequested()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: LocalAuthenticationRequested() state=%d phase=%d\n",
|
||||||
dprintf("KPPPSM: LocalAuthenticationRequested() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
State(), Phase());
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -263,10 +247,8 @@ KPPPStateMachine::LocalAuthenticationRequested()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::LocalAuthenticationAccepted(const char *name)
|
KPPPStateMachine::LocalAuthenticationAccepted(const char *name)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n",
|
||||||
dprintf("KPPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
State(), Phase());
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -292,10 +274,7 @@ KPPPStateMachine::LocalAuthenticationAccepted(const char *name)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::LocalAuthenticationDenied(const char *name)
|
KPPPStateMachine::LocalAuthenticationDenied(const char *name)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: LocalAuthenticationDenied() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: LocalAuthenticationDenied() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -314,10 +293,8 @@ KPPPStateMachine::LocalAuthenticationDenied(const char *name)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::PeerAuthenticationRequested()
|
KPPPStateMachine::PeerAuthenticationRequested()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: PeerAuthenticationRequested() state=%d phase=%d\n",
|
||||||
dprintf("KPPPSM: PeerAuthenticationRequested() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
State(), Phase());
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -340,10 +317,8 @@ KPPPStateMachine::PeerAuthenticationRequested()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::PeerAuthenticationAccepted(const char *name)
|
KPPPStateMachine::PeerAuthenticationAccepted(const char *name)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n",
|
||||||
dprintf("KPPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
State(), Phase());
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -369,10 +344,7 @@ KPPPStateMachine::PeerAuthenticationAccepted(const char *name)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::PeerAuthenticationDenied(const char *name)
|
KPPPStateMachine::PeerAuthenticationDenied(const char *name)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: PeerAuthenticationDenied() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: PeerAuthenticationDenied() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -393,10 +365,7 @@ KPPPStateMachine::PeerAuthenticationDenied(const char *name)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::UpFailedEvent(KPPPInterface& interface)
|
KPPPStateMachine::UpFailedEvent(KPPPInterface& interface)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: UpFailedEvent(interface) state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: UpFailedEvent(interface) state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// log that an interface did not go up
|
// log that an interface did not go up
|
||||||
@@ -407,10 +376,7 @@ KPPPStateMachine::UpFailedEvent(KPPPInterface& interface)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::UpEvent(KPPPInterface& interface)
|
KPPPStateMachine::UpEvent(KPPPInterface& interface)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: UpEvent(interface) state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: UpEvent(interface) state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -438,10 +404,7 @@ KPPPStateMachine::UpEvent(KPPPInterface& interface)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::DownEvent(KPPPInterface& interface)
|
KPPPStateMachine::DownEvent(KPPPInterface& interface)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: DownEvent(interface) state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: DownEvent(interface) state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -489,10 +452,7 @@ KPPPStateMachine::DownEvent(KPPPInterface& interface)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::UpFailedEvent(KPPPProtocol *protocol)
|
KPPPStateMachine::UpFailedEvent(KPPPProtocol *protocol)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: UpFailedEvent(protocol) state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: UpFailedEvent(protocol) state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if((protocol->Flags() & PPP_NOT_IMPORTANT) == 0) {
|
if((protocol->Flags() & PPP_NOT_IMPORTANT) == 0) {
|
||||||
if(Interface().Mode() == PPP_CLIENT_MODE) {
|
if(Interface().Mode() == PPP_CLIENT_MODE) {
|
||||||
@@ -519,10 +479,7 @@ KPPPStateMachine::UpFailedEvent(KPPPProtocol *protocol)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::UpEvent(KPPPProtocol *protocol)
|
KPPPStateMachine::UpEvent(KPPPProtocol *protocol)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: UpEvent(protocol) state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: UpEvent(protocol) state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -539,10 +496,7 @@ KPPPStateMachine::UpEvent(KPPPProtocol *protocol)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::DownEvent(KPPPProtocol *protocol)
|
KPPPStateMachine::DownEvent(KPPPProtocol *protocol)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: DownEvent(protocol) state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: DownEvent(protocol) state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -557,10 +511,7 @@ KPPPStateMachine::DownEvent(KPPPProtocol *protocol)
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::TLSNotify()
|
KPPPStateMachine::TLSNotify()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: TLSNotify() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: TLSNotify() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -586,10 +537,7 @@ KPPPStateMachine::TLSNotify()
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::TLFNotify()
|
KPPPStateMachine::TLFNotify()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: TLFNotify() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: TLFNotify() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -604,10 +552,7 @@ KPPPStateMachine::TLFNotify()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::UpFailedEvent()
|
KPPPStateMachine::UpFailedEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: UpFailedEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: UpFailedEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -633,10 +578,7 @@ KPPPStateMachine::UpFailedEvent()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::UpEvent()
|
KPPPStateMachine::UpEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: UpEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: UpEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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.
|
||||||
@@ -703,10 +645,7 @@ KPPPStateMachine::UpEvent()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::DownEvent()
|
KPPPStateMachine::DownEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: DownEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: DownEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -788,13 +727,12 @@ KPPPStateMachine::DownEvent()
|
|||||||
if(Interface().DoesAutoRedial()) {
|
if(Interface().DoesAutoRedial()) {
|
||||||
if(needsRedial)
|
if(needsRedial)
|
||||||
Interface().Redial(Interface().RedialDelay());
|
Interface().Redial(Interface().RedialDelay());
|
||||||
} else if(!Interface().DoesDialOnDemand())
|
} else
|
||||||
Interface().Delete();
|
Interface().Delete();
|
||||||
} else {
|
} else {
|
||||||
Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_DOWN_SUCCESSFUL,
|
Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_DOWN_SUCCESSFUL,
|
||||||
&fInterface.fID, sizeof(ppp_interface_id));
|
&fInterface.fID, sizeof(ppp_interface_id));
|
||||||
|
|
||||||
if(!Interface().DoesDialOnDemand())
|
|
||||||
Interface().Delete();
|
Interface().Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -807,10 +745,7 @@ KPPPStateMachine::DownEvent()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::OpenEvent()
|
KPPPStateMachine::OpenEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: OpenEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: OpenEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -873,10 +808,7 @@ KPPPStateMachine::OpenEvent()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::CloseEvent()
|
KPPPStateMachine::CloseEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: CloseEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: CloseEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -942,10 +874,7 @@ KPPPStateMachine::CloseEvent()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::TOGoodEvent()
|
KPPPStateMachine::TOGoodEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: TOGoodEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: TOGoodEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -975,10 +904,7 @@ KPPPStateMachine::TOGoodEvent()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::TOBadEvent()
|
KPPPStateMachine::TOBadEvent()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: TOBadEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: TOBadEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1010,10 +936,7 @@ KPPPStateMachine::TOBadEvent()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RCRGoodEvent(struct mbuf *packet)
|
KPPPStateMachine::RCRGoodEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RCRGoodEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RCRGoodEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1071,10 +994,7 @@ KPPPStateMachine::RCRGoodEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RCRBadEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RCRBadEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1132,10 +1052,7 @@ KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RCAEvent(struct mbuf *packet)
|
KPPPStateMachine::RCAEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RCAEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RCAEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1212,10 +1129,7 @@ KPPPStateMachine::RCAEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RCNEvent(struct mbuf *packet)
|
KPPPStateMachine::RCNEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RCNEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RCNEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1295,10 +1209,7 @@ KPPPStateMachine::RCNEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RTREvent(struct mbuf *packet)
|
KPPPStateMachine::RTREvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RTREvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RTREvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1348,10 +1259,7 @@ KPPPStateMachine::RTREvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RTAEvent(struct mbuf *packet)
|
KPPPStateMachine::RTAEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RTAEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RTAEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1408,10 +1316,7 @@ void
|
|||||||
KPPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber,
|
KPPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber,
|
||||||
uint8 code = PPP_PROTOCOL_REJECT)
|
uint8 code = PPP_PROTOCOL_REJECT)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RUCEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RUCEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1433,10 +1338,7 @@ KPPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber,
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RXJGoodEvent(struct mbuf *packet)
|
KPPPStateMachine::RXJGoodEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RXJGoodEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RXJGoodEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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.
|
||||||
@@ -1462,10 +1364,7 @@ KPPPStateMachine::RXJGoodEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RXJBadEvent(struct mbuf *packet)
|
KPPPStateMachine::RXJBadEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RXJBadEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RXJBadEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1515,10 +1414,7 @@ KPPPStateMachine::RXJBadEvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RXREvent(struct mbuf *packet)
|
KPPPStateMachine::RXREvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RXREvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RXREvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ppp_lcp_packet *echo = mtod(packet, ppp_lcp_packet*);
|
ppp_lcp_packet *echo = mtod(packet, ppp_lcp_packet*);
|
||||||
|
|
||||||
@@ -1553,7 +1449,7 @@ KPPPStateMachine::TimerEvent()
|
|||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(fNextTimeout != 0)
|
if(fNextTimeout != 0)
|
||||||
dprintf("KPPPSM: TimerEvent()\n");
|
TRACE("KPPPSM: TimerEvent()\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We might cause a dead-lock. Thus, abort if we cannot get the lock.
|
// We might cause a dead-lock. Thus, abort if we cannot get the lock.
|
||||||
@@ -1596,10 +1492,7 @@ KPPPStateMachine::TimerEvent()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RCREvent(struct mbuf *packet)
|
KPPPStateMachine::RCREvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RCREvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RCREvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
KPPPConfigurePacket request(packet);
|
KPPPConfigurePacket request(packet);
|
||||||
KPPPConfigurePacket nak(PPP_CONFIGURE_NAK);
|
KPPPConfigurePacket nak(PPP_CONFIGURE_NAK);
|
||||||
@@ -1620,16 +1513,14 @@ KPPPStateMachine::RCREvent(struct mbuf *packet)
|
|||||||
optionHandler = LCP().OptionHandlerFor(request.ItemAt(index)->type);
|
optionHandler = LCP().OptionHandlerFor(request.ItemAt(index)->type);
|
||||||
|
|
||||||
if(!optionHandler || !optionHandler->IsEnabled()) {
|
if(!optionHandler || !optionHandler->IsEnabled()) {
|
||||||
dprintf("KPPPSM::RCREvent(): unknown type:%d\n", request.ItemAt(index)->type);
|
ERROR("KPPPSM::RCREvent():unknown type:%d\n", request.ItemAt(index)->type);
|
||||||
// unhandled items should be added to the reject
|
// unhandled items should be added to the reject
|
||||||
reject.AddItem(request.ItemAt(index));
|
reject.AddItem(request.ItemAt(index));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("KPPPSM::RCREvent(): OH=%s\n",
|
||||||
dprintf("KPPPSM::RCREvent(): OH=%s\n",
|
|
||||||
optionHandler->Name() ? optionHandler->Name() : "Unknown");
|
optionHandler->Name() ? optionHandler->Name() : "Unknown");
|
||||||
#endif
|
|
||||||
result = optionHandler->ParseRequest(request, index, nak, reject);
|
result = optionHandler->ParseRequest(request, index, nak, reject);
|
||||||
|
|
||||||
if(result == PPP_UNHANDLED) {
|
if(result == PPP_UNHANDLED) {
|
||||||
@@ -1639,7 +1530,7 @@ KPPPStateMachine::RCREvent(struct mbuf *packet)
|
|||||||
} else if(result != B_OK) {
|
} else if(result != B_OK) {
|
||||||
// the request contains a value that has been sent more than
|
// the request contains a value that has been sent more than
|
||||||
// once or the value is corrupted
|
// once or the value is corrupted
|
||||||
dprintf("KPPPSM::RCREvent(): OptionHandler returned parse error!\n");
|
ERROR("KPPPSM::RCREvent(): OptionHandler returned parse error!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
CloseEvent();
|
CloseEvent();
|
||||||
return;
|
return;
|
||||||
@@ -1658,7 +1549,7 @@ KPPPStateMachine::RCREvent(struct mbuf *packet)
|
|||||||
if(result != B_OK) {
|
if(result != B_OK) {
|
||||||
// the request contains a value that has been sent more than
|
// the request contains a value that has been sent more than
|
||||||
// once or the value is corrupted
|
// once or the value is corrupted
|
||||||
dprintf("KPPPSM::RCREvent(): OptionHandler returned append error!\n");
|
ERROR("KPPPSM::RCREvent():OptionHandler returned append error!\n");
|
||||||
m_freem(packet);
|
m_freem(packet);
|
||||||
CloseEvent();
|
CloseEvent();
|
||||||
return;
|
return;
|
||||||
@@ -1684,10 +1575,7 @@ KPPPStateMachine::RCREvent(struct mbuf *packet)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::RXJEvent(struct mbuf *packet)
|
KPPPStateMachine::RXJEvent(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: RXJEvent() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: RXJEvent() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ppp_lcp_packet *reject = mtod(packet, ppp_lcp_packet*);
|
ppp_lcp_packet *reject = mtod(packet, ppp_lcp_packet*);
|
||||||
|
|
||||||
@@ -1754,7 +1642,7 @@ KPPPStateMachine::IllegalEvent(ppp_event event)
|
|||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
// update error statistics
|
// update error statistics
|
||||||
dprintf("KPPPSM: IllegalEvent(event=%d) state=%d phase=%d\n",
|
ERROR("KPPPSM: IllegalEvent(event=%d) state=%d phase=%d\n",
|
||||||
event, State(), Phase());
|
event, State(), Phase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1762,10 +1650,7 @@ KPPPStateMachine::IllegalEvent(ppp_event event)
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::ThisLayerUp()
|
KPPPStateMachine::ThisLayerUp()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: ThisLayerUp() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: ThisLayerUp() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
|
|
||||||
@@ -1787,10 +1672,7 @@ KPPPStateMachine::ThisLayerUp()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::ThisLayerDown()
|
KPPPStateMachine::ThisLayerDown()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: ThisLayerDown() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: ThisLayerDown() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// KPPPProtocol::Down() should block if needed.
|
// KPPPProtocol::Down() should block if needed.
|
||||||
DownProtocols();
|
DownProtocols();
|
||||||
@@ -1800,10 +1682,7 @@ KPPPStateMachine::ThisLayerDown()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::ThisLayerStarted()
|
KPPPStateMachine::ThisLayerStarted()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: ThisLayerStarted() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: ThisLayerStarted() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(Interface().Device() && !Interface().Device()->Up())
|
if(Interface().Device() && !Interface().Device()->Up())
|
||||||
Interface().Device()->UpFailedEvent();
|
Interface().Device()->UpFailedEvent();
|
||||||
@@ -1813,10 +1692,7 @@ KPPPStateMachine::ThisLayerStarted()
|
|||||||
void
|
void
|
||||||
KPPPStateMachine::ThisLayerFinished()
|
KPPPStateMachine::ThisLayerFinished()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: ThisLayerFinished() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: ThisLayerFinished() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(Interface().Device())
|
if(Interface().Device())
|
||||||
Interface().Device()->Down();
|
Interface().Device()->Down();
|
||||||
@@ -1844,10 +1720,7 @@ KPPPStateMachine::ZeroRestartCount()
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendConfigureRequest()
|
KPPPStateMachine::SendConfigureRequest()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendConfigureRequest() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: SendConfigureRequest() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
--fRequestCounter;
|
--fRequestCounter;
|
||||||
@@ -1874,10 +1747,7 @@ KPPPStateMachine::SendConfigureRequest()
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendConfigureAck(struct mbuf *packet)
|
KPPPStateMachine::SendConfigureAck(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendConfigureAck() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: SendConfigureAck() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return false;
|
return false;
|
||||||
@@ -1901,10 +1771,7 @@ KPPPStateMachine::SendConfigureAck(struct mbuf *packet)
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendConfigureNak(struct mbuf *packet)
|
KPPPStateMachine::SendConfigureNak(struct mbuf *packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendConfigureNak() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: SendConfigureNak() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return false;
|
return false;
|
||||||
@@ -1925,10 +1792,7 @@ KPPPStateMachine::SendConfigureNak(struct mbuf *packet)
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendTerminateRequest()
|
KPPPStateMachine::SendTerminateRequest()
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendTerminateRequest() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: SendTerminateRequest() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LockerHelper locker(fLock);
|
LockerHelper locker(fLock);
|
||||||
--fTerminateCounter;
|
--fTerminateCounter;
|
||||||
@@ -1956,10 +1820,7 @@ KPPPStateMachine::SendTerminateRequest()
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendTerminateAck(struct mbuf *request = NULL)
|
KPPPStateMachine::SendTerminateAck(struct mbuf *request = NULL)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendTerminateAck() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: SendTerminateAck() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct mbuf *reply = request;
|
struct mbuf *reply = request;
|
||||||
|
|
||||||
@@ -1988,10 +1849,8 @@ KPPPStateMachine::SendTerminateAck(struct mbuf *request = NULL)
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uint8 code)
|
KPPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uint8 code)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendCodeReject(protocolNumber=%X;code=%d) state=%d phase=%d\n",
|
||||||
dprintf("KPPPSM: SendCodeReject(protocolNumber=%X;code=%d) state=%d phase=%d\n",
|
|
||||||
protocolNumber, code, State(), Phase());
|
protocolNumber, code, State(), Phase());
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!packet)
|
if(!packet)
|
||||||
return false;
|
return false;
|
||||||
@@ -2035,10 +1894,7 @@ KPPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uin
|
|||||||
bool
|
bool
|
||||||
KPPPStateMachine::SendEchoReply(struct mbuf *request)
|
KPPPStateMachine::SendEchoReply(struct mbuf *request)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
TRACE("KPPPSM: SendEchoReply() state=%d phase=%d\n", State(), Phase());
|
||||||
dprintf("KPPPSM: SendEchoReply() state=%d phase=%d\n",
|
|
||||||
State(), Phase());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!request)
|
if(!request)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "_KPPPAuthenticationHandler.h"
|
#include "_KPPPAuthenticationHandler.h"
|
||||||
|
|
||||||
@@ -99,9 +97,7 @@ _KPPPAuthenticationHandler::AddToRequest(KPPPConfigurePacket& request)
|
|||||||
// this could omit some authenticators when we get a suggestion, but that is
|
// this could omit some authenticators when we get a suggestion, but that is
|
||||||
// no problem because the suggested authenticator will be accepted (hopefully)
|
// no problem because the suggested authenticator will be accepted (hopefully)
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("KPPPAuthHandler: AddToRequest(%X)\n", authenticator->ProtocolNumber());
|
||||||
dprintf("KPPPAuthHandler: AddToRequest(%X)\n", authenticator->ProtocolNumber());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
authenticator->SetEnabled(true);
|
authenticator->SetEnabled(true);
|
||||||
return authenticator->OptionHandler()->AddToRequest(request);
|
return authenticator->OptionHandler()->AddToRequest(request);
|
||||||
@@ -193,9 +189,7 @@ _KPPPAuthenticationHandler::ParseRequest(const KPPPConfigurePacket& request,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
// no authentication requested by peer (index > request.CountItems())
|
// no authentication requested by peer (index > request.CountItems())
|
||||||
|
|
||||||
#if DEBUG
|
TRACE("KPPPAuthHandler: ParseRequest(%X)\n", ntohs(item->protocolNumber));
|
||||||
dprintf("KPPPAuthHandler: ParseRequest(%X)\n", ntohs(item->protocolNumber));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// try to find the requested protocol
|
// try to find the requested protocol
|
||||||
fLocalAuthenticator = Interface().ProtocolFor(ntohs(item->protocolNumber));
|
fLocalAuthenticator = Interface().ProtocolFor(ntohs(item->protocolNumber));
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef __K_PPP_AUTHENTICATION_HANDLER__H
|
#ifndef __K_PPP_AUTHENTICATION_HANDLER__H
|
||||||
#define __K_PPP_AUTHENTICATION_HANDLER__H
|
#define __K_PPP_AUTHENTICATION_HANDLER__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "_KPPPMRUHandler.h"
|
#include "_KPPPMRUHandler.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef __K_PPP_MRU_HANDLER__H
|
#ifndef __K_PPP_MRU_HANDLER__H
|
||||||
#define __K_PPP_MRU_HANDLER__H
|
#define __K_PPP_MRU_HANDLER__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "_KPPPPFCHandler.h"
|
#include "_KPPPPFCHandler.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef __K_PPP_PFC_HANDLER__H
|
#ifndef __K_PPP_PFC_HANDLER__H
|
||||||
#define __K_PPP_PFC_HANDLER__H
|
#define __K_PPP_PFC_HANDLER__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP__H
|
#ifndef _K_PPP__H
|
||||||
#define _K_PPP__H
|
#define _K_PPP__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_CONFIGURE_PACKET__H
|
#ifndef _K_PPP_CONFIGURE_PACKET__H
|
||||||
#define _K_PPP_CONFIGURE_PACKET__H
|
#define _K_PPP_CONFIGURE_PACKET__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_DEFS__H
|
#ifndef _K_PPP_DEFS__H
|
||||||
#define _K_PPP_DEFS__H
|
#define _K_PPP_DEFS__H
|
||||||
@@ -12,6 +10,15 @@
|
|||||||
#include <PPPDefs.h>
|
#include <PPPDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
// debugging macros
|
||||||
|
#define ERROR(format, args...) dprintf(format, ## args)
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define TRACE(format, args...) dprintf(format, ## args)
|
||||||
|
#else
|
||||||
|
#define TRACE(format, args...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern struct core_module_info *core;
|
extern struct core_module_info *core;
|
||||||
// needed by core quick-access function defines
|
// needed by core quick-access function defines
|
||||||
|
|
||||||
@@ -19,6 +26,8 @@ extern struct core_module_info *core;
|
|||||||
// various constants
|
// various constants
|
||||||
#define PPP_PULSE_RATE 500000
|
#define PPP_PULSE_RATE 500000
|
||||||
//!< Rate at which Pulse() is called (in microseconds).
|
//!< Rate at which Pulse() is called (in microseconds).
|
||||||
|
#define PPP_RESPONSE_TEST_CODE '_3PT'
|
||||||
|
// private code used to test if ppp_up did not crash
|
||||||
|
|
||||||
|
|
||||||
//! Module key types used when loading a module.
|
//! Module key types used when loading a module.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_DEVICE__H
|
#ifndef _K_PPP_DEVICE__H
|
||||||
#define _K_PPP_DEVICE__H
|
#define _K_PPP_DEVICE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_INTERFACE__H
|
#ifndef _K_PPP_INTERFACE__H
|
||||||
#define _K_PPP_INTERFACE__H
|
#define _K_PPP_INTERFACE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_LCP__H
|
#ifndef _K_PPP_LCP__H
|
||||||
#define _K_PPP_LCP__H
|
#define _K_PPP_LCP__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef __K_PPP_LCP_EXTENSION__H
|
#ifndef __K_PPP_LCP_EXTENSION__H
|
||||||
#define __K_PPP_LCP_EXTENSION__H
|
#define __K_PPP_LCP_EXTENSION__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_LAYER__H
|
#ifndef _K_PPP_LAYER__H
|
||||||
#define _K_PPP_LAYER__H
|
#define _K_PPP_LAYER__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_MANAGER__H
|
#ifndef _K_PPP_MANAGER__H
|
||||||
#define _K_PPP_MANAGER__H
|
#define _K_PPP_MANAGER__H
|
||||||
@@ -20,11 +18,15 @@
|
|||||||
|
|
||||||
|
|
||||||
class KPPPInterface;
|
class KPPPInterface;
|
||||||
//! Private structure used by PPP interface manager.
|
//! Private structure shared by PPP manager and KPPPInterface.
|
||||||
typedef struct ppp_interface_entry {
|
typedef struct ppp_interface_entry {
|
||||||
|
char *name;
|
||||||
KPPPInterface *interface;
|
KPPPInterface *interface;
|
||||||
vint32 accessing;
|
vint32 accessing;
|
||||||
bool deleting;
|
bool deleting;
|
||||||
|
|
||||||
|
// ppp_up communication
|
||||||
|
thread_id requestThread;
|
||||||
} ppp_interface_entry;
|
} ppp_interface_entry;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_MODULE__H
|
#ifndef _K_PPP_MODULE__H
|
||||||
#define _K_PPP_MODULE__H
|
#define _K_PPP_MODULE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_OPTION_HANDLER__H
|
#ifndef _K_PPP_OPTION_HANDLER__H
|
||||||
#define _K_PPP_OPTION_HANDLER__H
|
#define _K_PPP_OPTION_HANDLER__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_PROFILE__H
|
#ifndef _K_PPP_PROFILE__H
|
||||||
#define _K_PPP_PROFILE__H
|
#define _K_PPP_PROFILE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_PROTOCOL__H
|
#ifndef _K_PPP_PROTOCOL__H
|
||||||
#define _K_PPP_PROTOCOL__H
|
#define _K_PPP_PROTOCOL__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_REPORT_MANAGER__H
|
#ifndef _K_PPP_REPORT_MANAGER__H
|
||||||
#define _K_PPP_REPORT_MANAGER__H
|
#define _K_PPP_REPORT_MANAGER__H
|
||||||
@@ -16,10 +14,6 @@
|
|||||||
#include <TemplateList.h>
|
#include <TemplateList.h>
|
||||||
|
|
||||||
|
|
||||||
//! Sends a reply to the report message sender.
|
|
||||||
#define PPP_REPLY(sender, value) \
|
|
||||||
send_data_with_timeout((sender), (value), NULL, 0, PPP_REPORT_TIMEOUT)
|
|
||||||
|
|
||||||
class KPPPReportManager {
|
class KPPPReportManager {
|
||||||
public:
|
public:
|
||||||
KPPPReportManager(BLocker& lock);
|
KPPPReportManager(BLocker& lock);
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_STATE_MACHINE__H
|
#ifndef _K_PPP_STATE_MACHINE__H
|
||||||
#define _K_PPP_STATE_MACHINE__H
|
#define _K_PPP_STATE_MACHINE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _K_PPP_UTILS__H
|
#ifndef _K_PPP_UTILS__H
|
||||||
#define _K_PPP_UTILS__H
|
#define _K_PPP_UTILS__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class LockerHelper
|
/*! \class LockerHelper
|
||||||
\brief Helper class for automatically releasing a lock.
|
\brief Helper class for automatically releasing a lock.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _PPP_CONTROL__H
|
#ifndef _PPP_CONTROL__H
|
||||||
#define _PPP_CONTROL__H
|
#define _PPP_CONTROL__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _PPP_DEFS__H
|
#ifndef _PPP_DEFS__H
|
||||||
#define _PPP_DEFS__H
|
#define _PPP_DEFS__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _PPP_REPORT_DEFS__H
|
#ifndef _PPP_REPORT_DEFS__H
|
||||||
#define _PPP_REPORT_DEFS__H
|
#define _PPP_REPORT_DEFS__H
|
||||||
@@ -18,6 +16,13 @@
|
|||||||
#define PPP_REPORT_CODE '_3PR'
|
#define PPP_REPORT_CODE '_3PR'
|
||||||
// the code of receive_data() must have this value
|
// the code of receive_data() must have this value
|
||||||
|
|
||||||
|
//! Sends a reply to the report message sender.
|
||||||
|
#define PPP_REPLY(sender, value) \
|
||||||
|
send_data_with_timeout((sender), (value), NULL, 0, PPP_REPORT_TIMEOUT)
|
||||||
|
|
||||||
|
#define PPP_OK_DISABLE_REPORTS 'OKDR'
|
||||||
|
// additional reply code (B_OK should be used)
|
||||||
|
|
||||||
//! Report flags.
|
//! Report flags.
|
||||||
enum ppp_report_flags {
|
enum ppp_report_flags {
|
||||||
PPP_WAIT_FOR_REPLY = 0x01,
|
PPP_WAIT_FOR_REPLY = 0x01,
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _SETTINGS_TOOLS__H
|
#ifndef _SETTINGS_TOOLS__H
|
||||||
#define _SETTINGS_TOOLS__H
|
#define _SETTINGS_TOOLS__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <KPPPDefs.h>
|
#include <KPPPDefs.h>
|
||||||
#include <driver_settings.h>
|
#include <driver_settings.h>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ StaticLibrary ppp :
|
|||||||
strlcat.c
|
strlcat.c
|
||||||
driver_settings.c
|
driver_settings.c
|
||||||
settings_tools.cpp
|
settings_tools.cpp
|
||||||
|
KPPPUtils.cpp
|
||||||
|
|
||||||
_libppputils.cpp
|
_libppputils.cpp
|
||||||
PPPInterface.cpp
|
PPPInterface.cpp
|
||||||
@@ -20,3 +21,4 @@ StaticLibrary ppp :
|
|||||||
SEARCH on [ FGristFiles strlcat.c ] = [ FDirName $(OBOS_TOP) src kernel libroot posix string ] ;
|
SEARCH on [ FGristFiles strlcat.c ] = [ FDirName $(OBOS_TOP) src kernel libroot posix string ] ;
|
||||||
SEARCH on [ FGristFiles driver_settings.c ] = [ FDirName $(OBOS_TOP) src kernel libroot os ] ;
|
SEARCH on [ FGristFiles driver_settings.c ] = [ FDirName $(OBOS_TOP) src kernel libroot os ] ;
|
||||||
SEARCH on [ FGristFiles settings_tools.cpp ] = [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkernelppp ] ;
|
SEARCH on [ FGristFiles settings_tools.cpp ] = [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkernelppp ] ;
|
||||||
|
SEARCH on [ FGristFiles KPPPUtils.cpp ] = [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkernelppp ] ;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class PPPInterface
|
/*! \class PPPInterface
|
||||||
\brief This class represents a PPP interface living in kernel space.
|
\brief This class represents a PPP interface living in kernel space.
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class PPPInterfaceListener
|
/*! \class PPPInterfaceListener
|
||||||
\brief This class simplifies the process of monitoring PPP interfaces.
|
\brief This class simplifies the process of monitoring PPP interfaces.
|
||||||
@@ -29,6 +27,7 @@
|
|||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <Handler.h>
|
#include <Handler.h>
|
||||||
#include <LockerHelper.h>
|
#include <LockerHelper.h>
|
||||||
|
#include <KPPPUtils.h>
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kReportFlags = PPP_WAIT_FOR_REPLY | PPP_NO_REPLY_TIMEOUT
|
static const uint32 kReportFlags = PPP_WAIT_FOR_REPLY | PPP_NO_REPLY_TIMEOUT
|
||||||
@@ -92,9 +91,9 @@ PPPInterfaceListenerThread::Run()
|
|||||||
BHandler *noHandler = NULL;
|
BHandler *noHandler = NULL;
|
||||||
// needed to tell compiler which version of SendMessage we want
|
// needed to tell compiler which version of SendMessage we want
|
||||||
if(messenger.SendMessage(&message, noHandler, 100000) != B_OK)
|
if(messenger.SendMessage(&message, noHandler, 100000) != B_OK)
|
||||||
send_data(sender, B_OK, NULL, 0);
|
PPP_REPLY(sender, B_OK);
|
||||||
} else
|
} else
|
||||||
send_data(sender, B_OK, NULL, 0);
|
PPP_REPLY(sender, B_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*! \class PPPManager
|
/*! \class PPPManager
|
||||||
\brief Allows controlling the PPP stack.
|
\brief Allows controlling the PPP stack.
|
||||||
@@ -134,12 +132,13 @@ PPPManager::CreateInterface(const driver_settings *settings,
|
|||||||
|
|
||||||
/*! \brief Creates an interface with the given name and profile.
|
/*! \brief Creates an interface with the given name and profile.
|
||||||
|
|
||||||
Every PPP interface has a profile. By it looks if the pppidf/profile folder
|
If the interface already exists its ID will be returned.
|
||||||
contains a profile with the interface's name. Otherwise the interface's settings
|
Every PPP interface has a profile. By default it checks if the pppidf/profile
|
||||||
become its profile. This has the advantage that you can put the profile and the
|
folder contains a profile with the interface's name. Otherwise the interface's
|
||||||
settings into the same file which simplifies your PPP configuration if you edit
|
settings become its profile. This has the advantage that you can put the profile
|
||||||
your PPP interface definitions by hand. In this case PAP, for example, would
|
and the settings into the same file which simplifies your PPP configuration if
|
||||||
still find the username and password although you specify them in the same
|
you edit your PPP interface definitions by hand. In this case PAP, for example,
|
||||||
|
would still find the username and password although you specify them in the same
|
||||||
parameter that loads the PAP module.
|
parameter that loads the PAP module.
|
||||||
|
|
||||||
\param name The PPP interface description file's name.
|
\param name The PPP interface description file's name.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*/
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include "_libppputils.h"
|
#include "_libppputils.h"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
*/
|
||||||
|
|
||||||
#ifndef __libppputils__h
|
#ifndef __libppputils__h
|
||||||
#define __libppputils__h
|
#define __libppputils__h
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _PPP_INTERFACE__H
|
#ifndef _PPP_INTERFACE__H
|
||||||
#define _PPP_INTERFACE__H
|
#define _PPP_INTERFACE__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _PPP_INTERFACE_LISTENER__H
|
#ifndef _PPP_INTERFACE_LISTENER__H
|
||||||
#define _PPP_INTERFACE_LISTENER__H
|
#define _PPP_INTERFACE_LISTENER__H
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
//-----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2003-2004, Haiku Inc.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*/
|
||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _PPP_MANAGER__H
|
#ifndef _PPP_MANAGER__H
|
||||||
#define _PPP_MANAGER__H
|
#define _PPP_MANAGER__H
|
||||||
|
|||||||
Reference in New Issue
Block a user