Replaced all printf and spawn_thread functions with their kernel counterparts.
IPCP: changed route initialization a little bit. Still cannot remove default route correctly. Renamed interface_id to ppp_interface_id. Some minor changes. Worked on libppp.a (userland PPP library). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6159 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "PPPManager.h"
|
||||
#include <PPPControl.h>
|
||||
@@ -15,14 +15,6 @@
|
||||
#include <sys/sockio.h>
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
static const char sPPPIfNameBase[] = "ppp";
|
||||
|
||||
|
||||
@@ -43,7 +35,7 @@ static
|
||||
status_t
|
||||
bring_interface_up(ppp_interface_entry *entry)
|
||||
{
|
||||
thread_id upThread = spawn_thread(interface_up_thread,
|
||||
thread_id upThread = spawn_kernel_thread(interface_up_thread,
|
||||
"PPPManager: up_thread", B_NORMAL_PRIORITY, entry);
|
||||
resume_thread(upThread);
|
||||
|
||||
@@ -71,7 +63,7 @@ status_t
|
||||
bring_interface_down(ppp_interface_entry *entry)
|
||||
{
|
||||
#if DOWN_AS_THREAD
|
||||
thread_id downThread = spawn_thread(interface_down_thread,
|
||||
thread_id downThread = spawn_kernel_thread(interface_down_thread,
|
||||
"PPPManager: down_thread", B_NORMAL_PRIORITY, entry);
|
||||
resume_thread(downThread); */
|
||||
#else
|
||||
@@ -116,10 +108,10 @@ PPPManager::PPPManager()
|
||||
fNextID(1)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: Constructor\n");
|
||||
dprintf("PPPManager: Constructor\n");
|
||||
#endif
|
||||
|
||||
fDeleterThread = spawn_thread(deleter_thread, "PPPManager: deleter_thread",
|
||||
fDeleterThread = spawn_kernel_thread(deleter_thread, "PPPManager: deleter_thread",
|
||||
B_NORMAL_PRIORITY, this);
|
||||
resume_thread(fDeleterThread);
|
||||
fPulseTimer = net_add_timer(pulse_timer, this, PPP_PULSE_RATE);
|
||||
@@ -129,7 +121,7 @@ PPPManager::PPPManager()
|
||||
PPPManager::~PPPManager()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: Destructor\n");
|
||||
dprintf("PPPManager: Destructor\n");
|
||||
#endif
|
||||
|
||||
int32 tmp;
|
||||
@@ -153,14 +145,14 @@ int32
|
||||
PPPManager::Stop(ifnet *ifp)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: Stop(%s)\n", ifp ? ifp->if_name : "Unknown");
|
||||
dprintf("PPPManager: Stop(%s)\n", ifp ? ifp->if_name : "Unknown");
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
|
||||
ppp_interface_entry *entry = EntryFor(ifp);
|
||||
if(!entry) {
|
||||
printf("PPPManager: Stop(): Could not find interface!\n");
|
||||
dprintf("PPPManager: Stop(): Could not find interface!\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -175,7 +167,7 @@ PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
||||
struct rtentry *rt0)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("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)
|
||||
@@ -184,7 +176,7 @@ PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst,
|
||||
LockerHelper locker(fLock);
|
||||
ppp_interface_entry *entry = EntryFor(ifp);
|
||||
if(!entry) {
|
||||
printf("PPPManager: Output(): Could not find interface!\n");
|
||||
dprintf("PPPManager: Output(): Could not find interface!\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -225,13 +217,13 @@ int32
|
||||
PPPManager::Control(ifnet *ifp, ulong cmd, caddr_t data)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: Control(%s)\n", ifp ? ifp->if_name : "Unknown");
|
||||
dprintf("PPPManager: Control(%s)\n", ifp ? ifp->if_name : "Unknown");
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
ppp_interface_entry *entry = EntryFor(ifp);
|
||||
if(!entry || entry->deleting) {
|
||||
printf("PPPManager: Control(): Could not find interface!\n");
|
||||
dprintf("PPPManager: Control(): Could not find interface!\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -260,12 +252,12 @@ PPPManager::Control(ifnet *ifp, ulong cmd, caddr_t data)
|
||||
}
|
||||
|
||||
|
||||
interface_id
|
||||
ppp_interface_id
|
||||
PPPManager::CreateInterface(const driver_settings *settings,
|
||||
interface_id parentID = PPP_UNDEFINED_INTERFACE_ID)
|
||||
ppp_interface_id parentID = PPP_UNDEFINED_INTERFACE_ID)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: CreateInterface()\n");
|
||||
dprintf("PPPManager: CreateInterface()\n");
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -274,7 +266,11 @@ PPPManager::CreateInterface(const driver_settings *settings,
|
||||
if(parentID != PPP_UNDEFINED_INTERFACE_ID && !parentEntry)
|
||||
return PPP_UNDEFINED_INTERFACE_ID;
|
||||
|
||||
interface_id id = NextID();
|
||||
// the day when NextID() returns 0 will come, be prepared! ;)
|
||||
ppp_interface_id id = NextID();
|
||||
if(id == PPP_UNDEFINED_INTERFACE_ID)
|
||||
id = NextID();
|
||||
|
||||
ppp_interface_entry *entry = new ppp_interface_entry;
|
||||
entry->accessing = 1;
|
||||
entry->deleting = false;
|
||||
@@ -290,9 +286,10 @@ PPPManager::CreateInterface(const driver_settings *settings,
|
||||
}
|
||||
|
||||
locker.UnlockNow();
|
||||
// it is safe to access the manager from userland
|
||||
|
||||
if(!Report(PPP_MANAGER_REPORT, PPP_REPORT_INTERFACE_CREATED,
|
||||
&id, sizeof(interface_id))) {
|
||||
&id, sizeof(ppp_interface_id))) {
|
||||
DeleteInterface(id);
|
||||
--entry->accessing;
|
||||
return PPP_UNDEFINED_INTERFACE_ID;
|
||||
@@ -309,10 +306,10 @@ PPPManager::CreateInterface(const driver_settings *settings,
|
||||
|
||||
|
||||
bool
|
||||
PPPManager::DeleteInterface(interface_id ID)
|
||||
PPPManager::DeleteInterface(ppp_interface_id ID)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: DeleteInterface(%ld)\n", ID);
|
||||
dprintf("PPPManager: DeleteInterface(%ld)\n", ID);
|
||||
#endif
|
||||
|
||||
// This only marks the interface for deletion.
|
||||
@@ -336,10 +333,10 @@ PPPManager::DeleteInterface(interface_id ID)
|
||||
|
||||
|
||||
bool
|
||||
PPPManager::RemoveInterface(interface_id ID)
|
||||
PPPManager::RemoveInterface(ppp_interface_id ID)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: RemoveInterface(%ld)\n", ID);
|
||||
dprintf("PPPManager: RemoveInterface(%ld)\n", ID);
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -359,10 +356,10 @@ PPPManager::RemoveInterface(interface_id ID)
|
||||
|
||||
|
||||
ifnet*
|
||||
PPPManager::RegisterInterface(interface_id ID)
|
||||
PPPManager::RegisterInterface(ppp_interface_id ID)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: RegisterInterface(%ld)\n", ID);
|
||||
dprintf("PPPManager: RegisterInterface(%ld)\n", ID);
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -389,7 +386,7 @@ PPPManager::RegisterInterface(interface_id ID)
|
||||
ifp->ioctl = ppp_ifnet_ioctl;
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPManager::RegisterInterface(): Created new ifnet: %s%d\n",
|
||||
dprintf("PPPManager::RegisterInterface(): Created new ifnet: %s%d\n",
|
||||
ifp->name, ifp->if_unit);
|
||||
#endif
|
||||
|
||||
@@ -399,10 +396,10 @@ PPPManager::RegisterInterface(interface_id ID)
|
||||
|
||||
|
||||
bool
|
||||
PPPManager::UnregisterInterface(interface_id ID)
|
||||
PPPManager::UnregisterInterface(ppp_interface_id ID)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: UnregisterInterface(%ld)\n", ID);
|
||||
dprintf("PPPManager: UnregisterInterface(%ld)\n", ID);
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -424,7 +421,7 @@ status_t
|
||||
PPPManager::Control(uint32 op, void *data, size_t length)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: Control(%ld)\n", op);
|
||||
dprintf("PPPManager: Control(%ld)\n", op);
|
||||
#endif
|
||||
|
||||
// this method is intended for use by userland applications
|
||||
@@ -444,20 +441,20 @@ PPPManager::Control(uint32 op, void *data, size_t length)
|
||||
} break;
|
||||
|
||||
case PPPC_DELETE_INTERFACE:
|
||||
if(length != sizeof(interface_id) || !data)
|
||||
if(length != sizeof(ppp_interface_id) || !data)
|
||||
return B_ERROR;
|
||||
|
||||
if(!DeleteInterface(*(interface_id*)data))
|
||||
if(!DeleteInterface(*(ppp_interface_id*)data))
|
||||
return B_ERROR;
|
||||
break;
|
||||
|
||||
case PPPC_BRING_INTERFACE_UP: {
|
||||
if(length != sizeof(interface_id) || !data)
|
||||
if(length != sizeof(ppp_interface_id) || !data)
|
||||
return B_ERROR;
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
|
||||
ppp_interface_entry *entry = EntryFor(*(interface_id*)data);
|
||||
ppp_interface_entry *entry = EntryFor(*(ppp_interface_id*)data);
|
||||
if(!entry || entry->deleting)
|
||||
return B_BAD_INDEX;
|
||||
|
||||
@@ -467,12 +464,12 @@ PPPManager::Control(uint32 op, void *data, size_t length)
|
||||
} break;
|
||||
|
||||
case PPPC_BRING_INTERFACE_DOWN: {
|
||||
if(length != sizeof(interface_id) || !data)
|
||||
if(length != sizeof(ppp_interface_id) || !data)
|
||||
return B_ERROR;
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
|
||||
ppp_interface_entry *entry = EntryFor(*(interface_id*)data);
|
||||
ppp_interface_entry *entry = EntryFor(*(ppp_interface_id*)data);
|
||||
if(!entry || entry->deleting)
|
||||
return B_BAD_INDEX;
|
||||
|
||||
@@ -542,10 +539,10 @@ PPPManager::Control(uint32 op, void *data, size_t length)
|
||||
|
||||
|
||||
status_t
|
||||
PPPManager::ControlInterface(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
|
||||
printf("PPPManager: ControlInterface(%ld)\n", ID);
|
||||
dprintf("PPPManager: ControlInterface(%ld)\n", ID);
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -559,11 +556,11 @@ PPPManager::ControlInterface(interface_id ID, uint32 op, void *data, size_t leng
|
||||
|
||||
|
||||
int32
|
||||
PPPManager::GetInterfaces(interface_id *interfaces, int32 count,
|
||||
PPPManager::GetInterfaces(ppp_interface_id *interfaces, int32 count,
|
||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: GetInterfaces()\n");
|
||||
dprintf("PPPManager: GetInterfaces()\n");
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -606,7 +603,7 @@ int32
|
||||
PPPManager::CountInterfaces(ppp_interface_filter filter = PPP_REGISTERED_INTERFACES)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: CountInterfaces()\n");
|
||||
dprintf("PPPManager: CountInterfaces()\n");
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -644,10 +641,10 @@ PPPManager::CountInterfaces(ppp_interface_filter filter = PPP_REGISTERED_INTERFA
|
||||
|
||||
|
||||
ppp_interface_entry*
|
||||
PPPManager::EntryFor(interface_id ID, int32 *saveIndex = NULL) const
|
||||
PPPManager::EntryFor(ppp_interface_id ID, int32 *saveIndex = NULL) const
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPManager: EntryFor(%ld)\n", ID);
|
||||
dprintf("PPPManager: EntryFor(%ld)\n", ID);
|
||||
#endif
|
||||
|
||||
if(ID == PPP_UNDEFINED_INTERFACE_ID)
|
||||
@@ -674,7 +671,7 @@ PPPManager::EntryFor(ifnet *ifp, int32 *saveIndex = NULL) const
|
||||
return NULL;
|
||||
|
||||
#if DEBUG
|
||||
printf("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;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _PPP_MANAGER__H
|
||||
#define _PPP_MANAGER__H
|
||||
@@ -30,19 +30,19 @@ class PPPManager {
|
||||
struct rtentry *rt0);
|
||||
int32 Control(ifnet *ifp, ulong cmd, caddr_t data);
|
||||
|
||||
interface_id CreateInterface(const driver_settings *settings,
|
||||
interface_id parentID = PPP_UNDEFINED_INTERFACE_ID);
|
||||
bool DeleteInterface(interface_id ID);
|
||||
bool RemoveInterface(interface_id ID);
|
||||
ppp_interface_id CreateInterface(const driver_settings *settings,
|
||||
ppp_interface_id parentID = PPP_UNDEFINED_INTERFACE_ID);
|
||||
bool DeleteInterface(ppp_interface_id ID);
|
||||
bool RemoveInterface(ppp_interface_id ID);
|
||||
|
||||
ifnet *RegisterInterface(interface_id ID);
|
||||
bool UnregisterInterface(interface_id ID);
|
||||
ifnet *RegisterInterface(ppp_interface_id ID);
|
||||
bool UnregisterInterface(ppp_interface_id ID);
|
||||
|
||||
status_t Control(uint32 op, void *data, size_t length);
|
||||
status_t ControlInterface(interface_id ID, uint32 op, void *data,
|
||||
status_t ControlInterface(ppp_interface_id ID, uint32 op, void *data,
|
||||
size_t length);
|
||||
|
||||
int32 GetInterfaces(interface_id *interfaces, int32 count,
|
||||
int32 GetInterfaces(ppp_interface_id *interfaces, int32 count,
|
||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES);
|
||||
int32 CountInterfaces(ppp_interface_filter filter = PPP_REGISTERED_INTERFACES);
|
||||
|
||||
@@ -52,11 +52,11 @@ class PPPManager {
|
||||
{ return ReportManager().Report(type, code, data, length); }
|
||||
// returns false if reply was bad (or an error occured)
|
||||
|
||||
ppp_interface_entry *EntryFor(interface_id ID, int32 *saveIndex = NULL) const;
|
||||
ppp_interface_entry *EntryFor(ppp_interface_id ID, int32 *saveIndex = NULL) const;
|
||||
ppp_interface_entry *EntryFor(ifnet *ifp, int32 *saveIndex = NULL) const;
|
||||
|
||||
interface_id NextID()
|
||||
{ return (interface_id) atomic_add((int32*) &fNextID, 1); }
|
||||
ppp_interface_id NextID()
|
||||
{ return (ppp_interface_id) atomic_add((int32*) &fNextID, 1); }
|
||||
|
||||
void DeleterThreadEvent();
|
||||
void Pulse();
|
||||
@@ -68,7 +68,7 @@ class PPPManager {
|
||||
BLocker fLock, fReportLock;
|
||||
PPPReportManager fReportManager;
|
||||
TemplateList<ppp_interface_entry*> fEntries;
|
||||
interface_id fNextID;
|
||||
ppp_interface_id fNextID;
|
||||
thread_id fDeleterThread, fPulseTimer;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <core_funcs.h>
|
||||
#include <KernelExport.h>
|
||||
@@ -87,8 +87,8 @@ ppp_control(uint32 op, void *data, size_t length)
|
||||
|
||||
|
||||
static
|
||||
interface_id
|
||||
CreateInterface(const driver_settings *settings, interface_id parent)
|
||||
ppp_interface_id
|
||||
CreateInterface(const driver_settings *settings, ppp_interface_id parent)
|
||||
{
|
||||
if(sManager)
|
||||
return sManager->CreateInterface(settings, parent);
|
||||
@@ -99,7 +99,7 @@ CreateInterface(const driver_settings *settings, interface_id parent)
|
||||
|
||||
static
|
||||
bool
|
||||
DeleteInterface(interface_id ID)
|
||||
DeleteInterface(ppp_interface_id ID)
|
||||
{
|
||||
if(sManager)
|
||||
return sManager->DeleteInterface(ID);
|
||||
@@ -110,7 +110,7 @@ DeleteInterface(interface_id ID)
|
||||
|
||||
static
|
||||
bool
|
||||
RemoveInterface(interface_id ID)
|
||||
RemoveInterface(ppp_interface_id ID)
|
||||
{
|
||||
if(sManager)
|
||||
return sManager->RemoveInterface(ID);
|
||||
@@ -121,7 +121,7 @@ RemoveInterface(interface_id ID)
|
||||
|
||||
static
|
||||
ifnet*
|
||||
RegisterInterface(interface_id ID)
|
||||
RegisterInterface(ppp_interface_id ID)
|
||||
{
|
||||
if(sManager)
|
||||
return sManager->RegisterInterface(ID);
|
||||
@@ -132,7 +132,7 @@ RegisterInterface(interface_id ID)
|
||||
|
||||
static
|
||||
bool
|
||||
UnregisterInterface(interface_id ID)
|
||||
UnregisterInterface(ppp_interface_id ID)
|
||||
{
|
||||
if(sManager)
|
||||
return sManager->UnregisterInterface(ID);
|
||||
@@ -143,7 +143,7 @@ UnregisterInterface(interface_id ID)
|
||||
|
||||
static
|
||||
status_t
|
||||
ControlInterface(interface_id ID, uint32 op, void *data, size_t length)
|
||||
ControlInterface(ppp_interface_id ID, uint32 op, void *data, size_t length)
|
||||
{
|
||||
if(sManager)
|
||||
return sManager->ControlInterface(ID, op, data, length);
|
||||
@@ -154,7 +154,7 @@ ControlInterface(interface_id ID, uint32 op, void *data, size_t length)
|
||||
|
||||
static
|
||||
int32
|
||||
GetInterfaces(interface_id *interfaces, int32 count,
|
||||
GetInterfaces(ppp_interface_id *interfaces, int32 count,
|
||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES)
|
||||
{
|
||||
if(sManager)
|
||||
|
||||
@@ -8,7 +8,9 @@ UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkerne
|
||||
UseHeaders [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkernelppp ] ;
|
||||
|
||||
R5KernelAddon ipcp : kernel obos_network ppp :
|
||||
# imported from libnet
|
||||
inet_addr.c
|
||||
|
||||
ipcp.cpp
|
||||
Protocol.cpp
|
||||
;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Protocol.h"
|
||||
#include <KPPPConfigurePacket.h>
|
||||
@@ -17,14 +17,6 @@
|
||||
#include <sys/sockio.h>
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#define PPP_STATE_MACHINE_TIMEOUT 3000000
|
||||
// 3 seconds
|
||||
|
||||
@@ -32,6 +24,7 @@
|
||||
IPCP::IPCP(PPPInterface& interface, driver_parameter *settings)
|
||||
: PPPProtocol("IPCP", PPP_NCP_PHASE, IPCP_PROTOCOL, PPP_PROTOCOL_LEVEL,
|
||||
AF_INET, 0, interface, settings, PPP_INCLUDES_NCP),
|
||||
fDefaultRoute(NULL),
|
||||
fRequestPrimaryDNS(false),
|
||||
fRequestSecondaryDNS(false),
|
||||
fState(PPP_INITIAL_STATE),
|
||||
@@ -64,6 +57,7 @@ IPCP::IPCP(PPPInterface& interface, driver_parameter *settings)
|
||||
|
||||
IPCP::~IPCP()
|
||||
{
|
||||
RemoveRoutes();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +65,7 @@ status_t
|
||||
IPCP::StackControl(uint32 op, void *data)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: StackControl(op=%ld)\n", op);
|
||||
dprintf("IPCP: StackControl(op=%ld)\n", op);
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
@@ -91,7 +85,7 @@ IPCP::StackControl(uint32 op, void *data)
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("IPCP: Unknown ioctl: %ld\n", op);
|
||||
dprintf("IPCP: Unknown ioctl: %ld\n", op);
|
||||
return PPPProtocol::StackControl(op, data);
|
||||
}
|
||||
|
||||
@@ -103,7 +97,7 @@ bool
|
||||
IPCP::Up()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("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
|
||||
@@ -133,7 +127,7 @@ bool
|
||||
IPCP::Down()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: Down() state=%d\n", State());
|
||||
dprintf("IPCP: Down() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -180,14 +174,14 @@ status_t
|
||||
IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: Send(0x%X)\n", protocolNumber);
|
||||
dprintf("IPCP: Send(0x%X)\n", protocolNumber);
|
||||
#endif
|
||||
|
||||
if((protocolNumber == IP_PROTOCOL && State() == PPP_OPENED_STATE)
|
||||
|| protocolNumber == IPCP_PROTOCOL)
|
||||
return SendToNext(packet, protocolNumber);
|
||||
|
||||
printf("IPCP: Send() failed because of wrong state or protocol number!\n");
|
||||
dprintf("IPCP: Send() failed because of wrong state or protocol number!\n");
|
||||
|
||||
m_freem(packet);
|
||||
return B_ERROR;
|
||||
@@ -198,7 +192,7 @@ status_t
|
||||
IPCP::Receive(struct mbuf *packet, uint16 protocolNumber)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: Receive(0x%X)\n", protocolNumber);
|
||||
dprintf("IPCP: Receive(0x%X)\n", protocolNumber);
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
@@ -272,7 +266,7 @@ IPCP::ReceiveIPPacket(struct mbuf *packet, uint16 protocolNumber)
|
||||
gProto[IPPROTO_IP]->pr_input(packet, 0);
|
||||
return B_OK;
|
||||
} else {
|
||||
printf("IPCP: Error: Could not find input function for IP!\n");
|
||||
dprintf("IPCP: Error: Could not find input function for IP!\n");
|
||||
m_freem(packet);
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -366,15 +360,17 @@ IPCP::ParseSideRequests(driver_parameter *requests, ppp_side side)
|
||||
void
|
||||
IPCP::UpdateAddresses()
|
||||
{
|
||||
RemoveRoutes();
|
||||
|
||||
if(State() != PPP_OPENED_STATE && !Interface().DoesDialOnDemand())
|
||||
return;
|
||||
|
||||
struct sockaddr_in gateway;
|
||||
struct in_aliasreq inreq;
|
||||
struct ifreq ifreqAddress, ifreqDestination;
|
||||
memset(&inreq, 0, sizeof(struct in_aliasreq));
|
||||
memset(&ifreqAddress, 0, sizeof(struct ifreq));
|
||||
memset(&ifreqDestination, 0, sizeof(struct ifreq));
|
||||
memset(&fGateway, 0, sizeof(struct sockaddr_in));
|
||||
|
||||
// create local address
|
||||
inreq.ifra_addr.sin_family = AF_INET;
|
||||
@@ -388,15 +384,15 @@ IPCP::UpdateAddresses()
|
||||
memcpy(&ifreqAddress.ifr_addr, &inreq.ifra_addr, sizeof(struct sockaddr_in));
|
||||
|
||||
// create destination address
|
||||
gateway.sin_family = AF_INET;
|
||||
fGateway.sin_family = AF_INET;
|
||||
if(fPeerRequests.address != INADDR_ANY)
|
||||
gateway.sin_addr.s_addr = fPeerRequests.address;
|
||||
fGateway.sin_addr.s_addr = fPeerRequests.address;
|
||||
else if(fPeerConfiguration.address == INADDR_ANY)
|
||||
gateway.sin_addr.s_addr = INADDR_BROADCAST;
|
||||
fGateway.sin_addr.s_addr = INADDR_BROADCAST;
|
||||
else
|
||||
gateway.sin_addr.s_addr = fPeerConfiguration.address;
|
||||
gateway.sin_len = sizeof(struct sockaddr_in);
|
||||
memcpy(&inreq.ifra_dstaddr, &gateway,
|
||||
fGateway.sin_addr.s_addr = fPeerConfiguration.address;
|
||||
fGateway.sin_len = sizeof(struct sockaddr_in);
|
||||
memcpy(&inreq.ifra_dstaddr, &fGateway,
|
||||
sizeof(struct sockaddr_in));
|
||||
memcpy(&ifreqDestination.ifr_dstaddr, &inreq.ifra_dstaddr,
|
||||
sizeof(struct sockaddr_in));
|
||||
@@ -409,34 +405,49 @@ IPCP::UpdateAddresses()
|
||||
// tell stack to use these values
|
||||
if(in_control(NULL, SIOCAIFADDR, (caddr_t) &inreq,
|
||||
Interface().Ifnet()) != B_OK)
|
||||
printf("IPCP: UpdateAddress(): SIOCAIFADDR returned error!\n");
|
||||
dprintf("IPCP: UpdateAddress(): SIOCAIFADDR returned error!\n");
|
||||
if(in_control(NULL, SIOCSIFADDR, (caddr_t) &ifreqAddress,
|
||||
Interface().Ifnet()) != B_OK)
|
||||
printf("IPCP: UpdateAddress(): SIOCSIFADDR returned error!\n");
|
||||
dprintf("IPCP: UpdateAddress(): SIOCSIFADDR returned error!\n");
|
||||
if(in_control(NULL, SIOCSIFDSTADDR, (caddr_t) &ifreqDestination,
|
||||
Interface().Ifnet()) != B_OK)
|
||||
printf("IPCP: UpdateAddress(): SIOCSIFDSTADDR returned error!\n");
|
||||
dprintf("IPCP: UpdateAddress(): SIOCSIFDSTADDR returned error!\n");
|
||||
memcpy(&inreq.ifra_addr, &inreq.ifra_mask, sizeof(struct sockaddr_in));
|
||||
// SIOCISFNETMASK wants the netmask to be in ifra_addr
|
||||
if(in_control(NULL, SIOCSIFNETMASK, (caddr_t) &inreq,
|
||||
Interface().Ifnet()) != B_OK)
|
||||
printf("IPCP: UpdateAddress(): SIOCSIFNETMASK returned error!\n");
|
||||
dprintf("IPCP: UpdateAddress(): SIOCSIFNETMASK returned error!\n");
|
||||
|
||||
// add default/subnet route
|
||||
struct rtentry *rt;
|
||||
struct sockaddr_in destination;
|
||||
destination.sin_family = AF_INET;
|
||||
destination.sin_addr.s_addr = fLocalRequests.netmask;
|
||||
if(fLocalRequests.netmask == INADDR_ANY)
|
||||
destination.sin_len = 0;
|
||||
else
|
||||
destination.sin_len = sizeof(struct sockaddr_in);
|
||||
if(rtrequest(RTM_ADD, (struct sockaddr*) &inreq.ifra_mask,
|
||||
(struct sockaddr*) &fGateway, (struct sockaddr*) &inreq.ifra_mask,
|
||||
RTF_UP | RTF_GATEWAY, &fDefaultRoute) != B_OK)
|
||||
dprintf("IPCP: UpdateAddress(): could not add default/subnet route!\n");
|
||||
|
||||
if(rtrequest(RTM_ADD, (struct sockaddr*) &destination, (struct sockaddr*) &gateway,
|
||||
(struct sockaddr*) &inreq.ifra_mask, RTF_UP | RTF_GATEWAY, &rt) != B_OK)
|
||||
printf("IPCP: UpdateAddress(): could not add default route!\n");
|
||||
--fDefaultRoute->rt_refcnt;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
IPCP::RemoveRoutes()
|
||||
{
|
||||
// note: netstack creates and deletes destination route automatically
|
||||
|
||||
--rt->rt_refcnt;
|
||||
if(fDefaultRoute) {
|
||||
struct sockaddr_in netmask;
|
||||
memset(&netmask, 0, sizeof(struct sockaddr_in));
|
||||
|
||||
netmask.sin_family = AF_INET;
|
||||
netmask.sin_addr.s_addr = fLocalRequests.netmask;
|
||||
netmask.sin_len = sizeof(struct sockaddr_in);
|
||||
|
||||
if(rtrequest(RTM_DELETE, (struct sockaddr*) &netmask,
|
||||
(struct sockaddr*) &fGateway, (struct sockaddr*) &netmask,
|
||||
RTF_GATEWAY, &fDefaultRoute) != B_OK)
|
||||
dprintf("IPCP: RemoveRoutes(): could not remove default/subnet route!\n");
|
||||
|
||||
fDefaultRoute = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -451,7 +462,7 @@ void
|
||||
IPCP::NewState(ppp_state next)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: NewState(%d) state=%d\n", next, State());
|
||||
dprintf("IPCP: NewState(%d) state=%d\n", next, State());
|
||||
#endif
|
||||
|
||||
// report state changes
|
||||
@@ -472,7 +483,7 @@ void
|
||||
IPCP::TOGoodEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: TOGoodEvent() state=%d\n", State());
|
||||
dprintf("IPCP: TOGoodEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -502,7 +513,7 @@ void
|
||||
IPCP::TOBadEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: TOBadEvent() state=%d\n", State());
|
||||
dprintf("IPCP: TOBadEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -532,7 +543,7 @@ void
|
||||
IPCP::RCREvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RCREvent() state=%d\n", State());
|
||||
dprintf("IPCP: RCREvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
PPPConfigurePacket request(packet);
|
||||
@@ -640,7 +651,7 @@ void
|
||||
IPCP::RCRGoodEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RCRGoodEvent() state=%d\n", State());
|
||||
dprintf("IPCP: RCRGoodEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -686,7 +697,7 @@ void
|
||||
IPCP::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RCRBadEvent() state=%d\n", State());
|
||||
dprintf("IPCP: RCRBadEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -728,7 +739,7 @@ void
|
||||
IPCP::RCAEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RCAEvent() state=%d\n", State());
|
||||
dprintf("IPCP: RCAEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -838,7 +849,7 @@ void
|
||||
IPCP::RCNEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RCNEvent() state=%d\n", State());
|
||||
dprintf("IPCP: RCNEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -956,7 +967,7 @@ void
|
||||
IPCP::RTREvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RTREvent() state=%d\n", State());
|
||||
dprintf("IPCP: RTREvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -1001,7 +1012,7 @@ void
|
||||
IPCP::RTAEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RTAEvent() state=%d\n", State());
|
||||
dprintf("IPCP: RTAEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -1047,7 +1058,7 @@ void
|
||||
IPCP::RUCEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RUCEvent() state=%d\n", State());
|
||||
dprintf("IPCP: RUCEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
SendCodeReject(packet);
|
||||
@@ -1058,7 +1069,7 @@ void
|
||||
IPCP::RXJBadEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: RXJBadEvent() state=%d\n", State());
|
||||
dprintf("IPCP: RXJBadEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -1102,7 +1113,7 @@ void
|
||||
IPCP::IllegalEvent(ppp_event event)
|
||||
{
|
||||
// TODO: update error statistics
|
||||
printf("IPCP: IllegalEvent(event=%d) state=%d\n", event, State());
|
||||
dprintf("IPCP: IllegalEvent(event=%d) state=%d\n", event, State());
|
||||
}
|
||||
|
||||
|
||||
@@ -1163,7 +1174,7 @@ bool
|
||||
IPCP::SendConfigureRequest()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: SendConfigureRequest() state=%d\n", State());
|
||||
dprintf("IPCP: SendConfigureRequest() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -1186,7 +1197,7 @@ IPCP::SendConfigureRequest()
|
||||
request.AddItem((ppp_configure_item*) &ipItem);
|
||||
|
||||
#if DEBUG
|
||||
printf("IPCP: SCR: confaddr=%lX; reqaddr=%lX; addr=%lX\n",
|
||||
dprintf("IPCP: SCR: confaddr=%lX; reqaddr=%lX; addr=%lX\n",
|
||||
fLocalConfiguration.address, fLocalRequests.address,
|
||||
((ip_item*)request.ItemAt(0))->address);
|
||||
#endif
|
||||
@@ -1218,7 +1229,7 @@ bool
|
||||
IPCP::SendConfigureAck(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: SendConfigureAck() state=%d\n", State());
|
||||
dprintf("IPCP: SendConfigureAck() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
@@ -1289,7 +1300,7 @@ bool
|
||||
IPCP::SendConfigureNak(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: SendConfigureNak() state=%d\n", State());
|
||||
dprintf("IPCP: SendConfigureNak() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
@@ -1312,7 +1323,7 @@ bool
|
||||
IPCP::SendTerminateRequest()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: SendTerminateRequest() state=%d\n", State());
|
||||
dprintf("IPCP: SendTerminateRequest() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -1342,7 +1353,7 @@ bool
|
||||
IPCP::SendTerminateAck(struct mbuf *request = NULL)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: SendTerminateAck() state=%d\n", State());
|
||||
dprintf("IPCP: SendTerminateAck() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
struct mbuf *reply = request;
|
||||
@@ -1373,7 +1384,7 @@ bool
|
||||
IPCP::SendCodeReject(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("IPCP: SendCodeReject() state=%d\n", State());
|
||||
dprintf("IPCP: SendCodeReject() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef PROTOCOL__H
|
||||
#define PROTOCOL__H
|
||||
@@ -80,6 +80,7 @@ class IPCP : public PPPProtocol {
|
||||
private:
|
||||
bool ParseSideRequests(driver_parameter *requests, ppp_side side);
|
||||
void UpdateAddresses();
|
||||
void RemoveRoutes();
|
||||
|
||||
// for state machine
|
||||
void NewState(ppp_state next);
|
||||
@@ -117,6 +118,10 @@ class IPCP : public PPPProtocol {
|
||||
ipcp_configuration fLocalConfiguration, fPeerConfiguration;
|
||||
ipcp_requests fLocalRequests, fPeerRequests;
|
||||
|
||||
// default route
|
||||
struct sockaddr_in fGateway;
|
||||
rtentry *fDefaultRoute;
|
||||
|
||||
// used for local requests
|
||||
bool fRequestPrimaryDNS, fRequestSecondaryDNS;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <driver_settings.h>
|
||||
@@ -17,14 +17,6 @@
|
||||
#include "Protocol.h"
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#define IPCP_MODULE_NAME NETWORK_MODULES_ROOT "ppp/ipcp"
|
||||
|
||||
struct protosw *gProto[IPPROTO_MAX];
|
||||
@@ -63,7 +55,7 @@ add_to(PPPInterface& mainInterface, PPPInterface *subInterface,
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
printf("IPCP: add_to(): %s\n",
|
||||
dprintf("IPCP: add_to(): %s\n",
|
||||
success && ipcp && ipcp->InitCheck() == B_OK ? "OK" : "ERROR");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "ACFCHandler.h"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef ACFC_HANDLER__H
|
||||
#define ACFC_HANDLER__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef MODEM__H
|
||||
#define MODEM__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
@@ -18,11 +18,6 @@
|
||||
#include <settings_tools.h>
|
||||
#include <LockerHelper.h>
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#endif
|
||||
|
||||
|
||||
#if DEBUG
|
||||
static char sDigits[] = "0123456789ABCDEF";
|
||||
@@ -36,7 +31,7 @@ dump_packet(struct mbuf *packet)
|
||||
uint8 buffer[33];
|
||||
uint8 bufferIndex = 0;
|
||||
|
||||
printf("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len,
|
||||
dprintf("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len,
|
||||
packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1);
|
||||
|
||||
for(uint32 index = 0; index < packet->m_len; index++) {
|
||||
@@ -44,7 +39,7 @@ dump_packet(struct mbuf *packet)
|
||||
buffer[bufferIndex++] = sDigits[data[index] & 0x0F];
|
||||
if(bufferIndex == 32 || index == packet->m_len - 1) {
|
||||
buffer[bufferIndex] = 0;
|
||||
printf("%s\n", buffer);
|
||||
dprintf("%s\n", buffer);
|
||||
bufferIndex = 0;
|
||||
}
|
||||
}
|
||||
@@ -193,9 +188,9 @@ ModemDevice::ModemDevice(PPPInterface& interface, driver_parameter *settings)
|
||||
fState(INITIAL)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("ModemDevice: Constructor\n");
|
||||
dprintf("ModemDevice: Constructor\n");
|
||||
if(!settings || !settings->parameters)
|
||||
printf("ModemDevice::ctor: No settings!\n");
|
||||
dprintf("ModemDevice::ctor: No settings!\n");
|
||||
#endif
|
||||
|
||||
fACFC = new ACFCHandler(REQUEST_ACFC | ALLOW_ACFC, interface);
|
||||
@@ -215,7 +210,7 @@ ModemDevice::ModemDevice(PPPInterface& interface, driver_parameter *settings)
|
||||
fDialString = get_parameter_value(MODEM_DIAL_KEY, settings);
|
||||
|
||||
#if DEBUG
|
||||
printf("ModemDevice::ctor: interfaceName: %s\n", interfaceName);
|
||||
dprintf("ModemDevice::ctor: interfaceName: %s\n", interfaceName);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -223,7 +218,7 @@ ModemDevice::ModemDevice(PPPInterface& interface, driver_parameter *settings)
|
||||
ModemDevice::~ModemDevice()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("ModemDevice: Destructor\n");
|
||||
dprintf("ModemDevice: Destructor\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -242,7 +237,7 @@ bool
|
||||
ModemDevice::Up()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("ModemDevice: Up()\n");
|
||||
dprintf("ModemDevice: Up()\n");
|
||||
#endif
|
||||
|
||||
if(InitCheck() != B_OK)
|
||||
@@ -269,7 +264,7 @@ ModemDevice::Up()
|
||||
fState = DIALING;
|
||||
|
||||
if(fWorkerThread == -1) {
|
||||
fWorkerThread = spawn_thread(worker_thread, "Modem: worker_thread",
|
||||
fWorkerThread = spawn_kernel_thread(worker_thread, "Modem: worker_thread",
|
||||
B_NORMAL_PRIORITY, this);
|
||||
resume_thread(fWorkerThread);
|
||||
}
|
||||
@@ -282,7 +277,7 @@ bool
|
||||
ModemDevice::Down()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("ModemDevice: Down()\n");
|
||||
dprintf("ModemDevice: Down()\n");
|
||||
#endif
|
||||
|
||||
if(InitCheck() != B_OK)
|
||||
@@ -415,7 +410,7 @@ status_t
|
||||
ModemDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("ModemDevice: Send()\n");
|
||||
dprintf("ModemDevice: Send()\n");
|
||||
dump_packet(packet);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef MODEM_DEVICE__H
|
||||
#define MODEM_DEVICE__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <driver_settings.h>
|
||||
@@ -17,14 +17,6 @@
|
||||
#include "ModemDevice.h"
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#define MODEM_MODULE_NAME NETWORK_MODULES_ROOT "ppp/modem"
|
||||
|
||||
struct core_module_info *core = NULL;
|
||||
@@ -50,7 +42,7 @@ add_to(PPPInterface& mainInterface, PPPInterface *subInterface,
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
printf("Modem: add_to(): %s\n",
|
||||
dprintf("Modem: add_to(): %s\n",
|
||||
success && device && device->InitCheck() == B_OK ? "OK" : "ERROR");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Protocol.h"
|
||||
#include <KPPPConfigurePacket.h>
|
||||
@@ -17,14 +17,6 @@
|
||||
#include <sys/sockio.h>
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#elif DEBUG
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#define PAP_TIMEOUT 3000000
|
||||
// 3 seconds
|
||||
|
||||
@@ -153,7 +145,7 @@ bool
|
||||
PAP::Up()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: Up() state=%d\n", State());
|
||||
dprintf("PAP: Up() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -187,7 +179,7 @@ bool
|
||||
PAP::Down()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: Down() state=%d\n", State());
|
||||
dprintf("PAP: Down() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -343,7 +335,7 @@ void
|
||||
PAP::NewState(pap_state next)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: NewState(%d) state=%d\n", next, State());
|
||||
dprintf("PAP: NewState(%d) state=%d\n", next, State());
|
||||
#endif
|
||||
|
||||
// state changes
|
||||
@@ -369,7 +361,7 @@ void
|
||||
PAP::TOGoodEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: TOGoodEvent() state=%d\n", State());
|
||||
dprintf("PAP: TOGoodEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -394,7 +386,7 @@ void
|
||||
PAP::TOBadEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: TOBadEvent() state=%d\n", State());
|
||||
dprintf("PAP: TOBadEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -422,7 +414,7 @@ void
|
||||
PAP::RREvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: RREvent() state=%d\n", State());
|
||||
dprintf("PAP: RREvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -463,7 +455,7 @@ void
|
||||
PAP::RAEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: RAEvent() state=%d\n", State());
|
||||
dprintf("PAP: RAEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -496,7 +488,7 @@ void
|
||||
PAP::RNEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: RNEvent() state=%d\n", State());
|
||||
dprintf("PAP: RNEvent() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -536,7 +528,7 @@ bool
|
||||
PAP::SendRequest()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: SendRequest() state=%d\n", State());
|
||||
dprintf("PAP: SendRequest() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -571,7 +563,7 @@ bool
|
||||
PAP::SendAck(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: SendAck() state=%d\n", State());
|
||||
dprintf("PAP: SendAck() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
@@ -594,7 +586,7 @@ bool
|
||||
PAP::SendNak(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PAP: SendNak() state=%d\n", State());
|
||||
dprintf("PAP: SendNak() state=%d\n", State());
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef PROTOCOL__H
|
||||
#define PROTOCOL__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <driver_settings.h>
|
||||
@@ -17,14 +17,6 @@
|
||||
#include "Protocol.h"
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#define PAP_MODULE_NAME NETWORK_MODULES_ROOT "ppp/pap"
|
||||
|
||||
struct core_module_info *core = NULL;
|
||||
@@ -50,7 +42,7 @@ add_to(PPPInterface& mainInterface, PPPInterface *subInterface,
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
printf("PAP: add_to(): %s\n",
|
||||
dprintf("PAP: add_to(): %s\n",
|
||||
success && pap && pap->InitCheck() == B_OK ? "OK" : "ERROR");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "DiscoveryPacket.h"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef DISCOVERY_PACKET__H
|
||||
#define DISCOVERY_PACKET__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef PPPoE__H
|
||||
#define PPPoE__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "PPPoEDevice.h"
|
||||
#include "DiscoveryPacket.h"
|
||||
@@ -15,13 +15,6 @@
|
||||
#include <settings_tools.h>
|
||||
#include <LockerHelper.h>
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#if DEBUG
|
||||
static char sDigits[] = "0123456789ABCDEF";
|
||||
@@ -35,7 +28,7 @@ dump_packet(struct mbuf *packet)
|
||||
uint8 buffer[33];
|
||||
uint8 bufferIndex = 0;
|
||||
|
||||
printf("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len,
|
||||
dprintf("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len,
|
||||
packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1);
|
||||
|
||||
for(uint32 index = 0; index < packet->m_len; index++) {
|
||||
@@ -43,7 +36,7 @@ dump_packet(struct mbuf *packet)
|
||||
buffer[bufferIndex++] = sDigits[data[index] & 0x0F];
|
||||
if(bufferIndex == 32 || index == packet->m_len - 1) {
|
||||
buffer[bufferIndex] = 0;
|
||||
printf("%s\n", buffer);
|
||||
dprintf("%s\n", buffer);
|
||||
bufferIndex = 0;
|
||||
}
|
||||
}
|
||||
@@ -63,9 +56,9 @@ PPPoEDevice::PPPoEDevice(PPPInterface& interface, driver_parameter *settings)
|
||||
fState(INITIAL)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPoEDevice: Constructor\n");
|
||||
dprintf("PPPoEDevice: Constructor\n");
|
||||
if(!settings || !settings->parameters)
|
||||
printf("PPPoEDevice::ctor: No settings!\n");
|
||||
dprintf("PPPoEDevice::ctor: No settings!\n");
|
||||
#endif
|
||||
|
||||
interface.SetPFCOptions(PPP_ALLOW_PFC);
|
||||
@@ -80,7 +73,7 @@ PPPoEDevice::PPPoEDevice(PPPInterface& interface, driver_parameter *settings)
|
||||
if(!interfaceName)
|
||||
return;
|
||||
#if DEBUG
|
||||
printf("PPPoEDevice::ctor: interfaceName: %s\n", interfaceName);
|
||||
dprintf("PPPoEDevice::ctor: interfaceName: %s\n", interfaceName);
|
||||
#endif
|
||||
|
||||
ifnet *current = get_interfaces();
|
||||
@@ -88,7 +81,7 @@ PPPoEDevice::PPPoEDevice(PPPInterface& interface, driver_parameter *settings)
|
||||
if(current->if_type == IFT_ETHER && current->if_name
|
||||
&& !strcmp(current->if_name, interfaceName)) {
|
||||
#if DEBUG
|
||||
printf("PPPoEDevice::ctor: found ethernet interface\n");
|
||||
dprintf("PPPoEDevice::ctor: found ethernet interface\n");
|
||||
#endif
|
||||
fEthernetIfnet = current;
|
||||
break;
|
||||
@@ -97,7 +90,7 @@ PPPoEDevice::PPPoEDevice(PPPInterface& interface, driver_parameter *settings)
|
||||
|
||||
#if DEBUG
|
||||
if(!fEthernetIfnet)
|
||||
printf("PPPoEDevice::ctor: could not find ethernet interface\n");
|
||||
dprintf("PPPoEDevice::ctor: could not find ethernet interface\n");
|
||||
#endif
|
||||
|
||||
add_device(this);
|
||||
@@ -107,7 +100,7 @@ PPPoEDevice::PPPoEDevice(PPPInterface& interface, driver_parameter *settings)
|
||||
PPPoEDevice::~PPPoEDevice()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPoEDevice: Destructor\n");
|
||||
dprintf("PPPoEDevice: Destructor\n");
|
||||
#endif
|
||||
|
||||
remove_device(this);
|
||||
@@ -129,7 +122,7 @@ bool
|
||||
PPPoEDevice::Up()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPoEDevice: Up()\n");
|
||||
dprintf("PPPoEDevice: Up()\n");
|
||||
#endif
|
||||
|
||||
if(InitCheck() != B_OK)
|
||||
@@ -190,7 +183,7 @@ PPPoEDevice::Up()
|
||||
if(EthernetIfnet()->output(EthernetIfnet(), packet, &destination, NULL) != B_OK) {
|
||||
fState = INITIAL;
|
||||
fAttempts = 0;
|
||||
printf("PPPoEDevice::Up(): EthernetIfnet()->output() failed!\n");
|
||||
dprintf("PPPoEDevice::Up(): EthernetIfnet()->output() failed!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -204,7 +197,7 @@ bool
|
||||
PPPoEDevice::Down()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPoEDevice: Down()\n");
|
||||
dprintf("PPPoEDevice: Down()\n");
|
||||
#endif
|
||||
|
||||
if(InitCheck() != B_OK)
|
||||
@@ -231,7 +224,7 @@ PPPoEDevice::Down()
|
||||
|
||||
struct mbuf *packet = discovery.ToMbuf(MTU());
|
||||
if(!packet) {
|
||||
printf("PPPoEDevice::Down(): ToMbuf() failed; MTU=%ld\n", MTU());
|
||||
dprintf("PPPoEDevice::Down(): ToMbuf() failed; MTU=%ld\n", MTU());
|
||||
DownEvent();
|
||||
return false;
|
||||
}
|
||||
@@ -285,13 +278,13 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
||||
// Send() is only for PPP packets. PPPoE packets are sent directly to ethernet.
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPoEDevice: Send()\n");
|
||||
dprintf("PPPoEDevice: Send()\n");
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
return B_ERROR;
|
||||
else if(InitCheck() != B_OK || protocolNumber != 0) {
|
||||
printf("PPPoEDevice::Send(): InitCheck() != B_OK!\n");
|
||||
dprintf("PPPoEDevice::Send(): InitCheck() != B_OK!\n");
|
||||
m_freem(packet);
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -299,7 +292,7 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
||||
LockerHelper locker(fLock);
|
||||
|
||||
if(!IsUp()) {
|
||||
printf("PPPoEDevice::Send(): no connection!\n");
|
||||
dprintf("PPPoEDevice::Send(): no connection!\n");
|
||||
m_freem(packet);
|
||||
return PPP_NO_CONNECTION;
|
||||
}
|
||||
@@ -328,7 +321,7 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0)
|
||||
locker.UnlockNow();
|
||||
|
||||
if(EthernetIfnet()->output(EthernetIfnet(), packet, &destination, NULL) != B_OK) {
|
||||
printf("PPPoEDevice::Send(): EthernetIfnet()->output() failed!\n");
|
||||
dprintf("PPPoEDevice::Send(): EthernetIfnet()->output() failed!\n");
|
||||
DownEvent();
|
||||
// DownEvent() without DownStarted() indicates connection lost
|
||||
return PPP_NO_CONNECTION;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef PPPoE_DEVICE__H
|
||||
#define PPPoE_DEVICE__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <driver_settings.h>
|
||||
@@ -20,14 +20,6 @@
|
||||
#include "DiscoveryPacket.h"
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#define PPPoE_MODULE_NAME NETWORK_MODULES_ROOT "ppp/pppoe"
|
||||
|
||||
struct core_module_info *core = NULL;
|
||||
@@ -50,7 +42,7 @@ void
|
||||
add_device(PPPoEDevice *device)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPoE: add_device()\n");
|
||||
dprintf("PPPoE: add_device()\n");
|
||||
#endif
|
||||
|
||||
LockerHelper locker(sLock);
|
||||
@@ -62,7 +54,7 @@ void
|
||||
remove_device(PPPoEDevice *device)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPoE: remove_device()\n");
|
||||
dprintf("PPPoE: remove_device()\n");
|
||||
#endif
|
||||
|
||||
LockerHelper locker(sLock);
|
||||
@@ -90,7 +82,7 @@ pppoe_input(struct mbuf *packet)
|
||||
if(header->ethernetHeader.ether_type == ETHERTYPE_PPPOE
|
||||
&& header->pppoeHeader.sessionID == device->SessionID()) {
|
||||
#if DEBUG
|
||||
printf("PPPoE: session packet\n");
|
||||
dprintf("PPPoE: session packet\n");
|
||||
#endif
|
||||
device->Receive(packet);
|
||||
return;
|
||||
@@ -99,11 +91,11 @@ pppoe_input(struct mbuf *packet)
|
||||
&& header->pppoeHeader.code != PADR
|
||||
&& !device->IsDown()) {
|
||||
#if DEBUG
|
||||
printf("PPPoE: discovery packet\n");
|
||||
dprintf("PPPoE: discovery packet\n");
|
||||
#endif
|
||||
DiscoveryPacket discovery(packet, ETHER_HDR_LEN);
|
||||
if(discovery.InitCheck() != B_OK) {
|
||||
printf("PPPoE: received corrupted discovery packet!\n");
|
||||
dprintf("PPPoE: received corrupted discovery packet!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -117,7 +109,7 @@ pppoe_input(struct mbuf *packet)
|
||||
}
|
||||
}
|
||||
|
||||
printf("PPPoE: No device found for packet from: %s\n", sourceIfnet->if_name);
|
||||
dprintf("PPPoE: No device found for packet from: %s\n", sourceIfnet->if_name);
|
||||
m_freem(packet);
|
||||
}
|
||||
|
||||
@@ -141,7 +133,7 @@ add_to(PPPInterface& mainInterface, PPPInterface *subInterface,
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPoE: add_to(): %s\n",
|
||||
dprintf("PPPoE: add_to(): %s\n",
|
||||
success && device && device->InitCheck() == B_OK ? "OK" : "ERROR");
|
||||
#endif
|
||||
|
||||
@@ -180,7 +172,7 @@ std_ops(int32 op, ...)
|
||||
sEthernet->set_pppoe_receiver(pppoe_input);
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPoE: Registered PPPoE receiver.\n");
|
||||
dprintf("PPPoE: Registered PPPoE receiver.\n");
|
||||
#endif
|
||||
return B_OK;
|
||||
|
||||
@@ -188,7 +180,7 @@ std_ops(int32 op, ...)
|
||||
delete sDevices;
|
||||
sEthernet->unset_pppoe_receiver();
|
||||
#if DEBUG
|
||||
printf("PPPoE: Unregistered PPPoE receiver.\n");
|
||||
dprintf("PPPoE: Unregistered PPPoE receiver.\n");
|
||||
#endif
|
||||
put_module(NET_CORE_MODULE_NAME);
|
||||
put_module(NET_ETHERNET_MODULE_NAME);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KPPPConfigurePacket.h>
|
||||
#include <KPPPInterface.h>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KPPPDevice.h>
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// cstdio must be included before PPPModule.h/PPPManager.h because
|
||||
// dprintf is defined twice with different return values, once with
|
||||
// ddprintf is defined twice with different return values, once with
|
||||
// void (KernelExport.h) and once with int (stdio.h).
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@@ -36,12 +36,6 @@
|
||||
#include "_KPPPPFCHandler.h"
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#endif
|
||||
|
||||
|
||||
// TODO:
|
||||
// - implement timers with support for settings next time instead of receiving timer
|
||||
// events periodically
|
||||
@@ -107,7 +101,7 @@ PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID,
|
||||
_PPPMRUHandler *mruHandler =
|
||||
new _PPPMRUHandler(*this);
|
||||
if(!LCP().AddOptionHandler(mruHandler) || mruHandler->InitCheck() != B_OK) {
|
||||
printf("PPPInterface: Could not add MRU handler!\n");
|
||||
dprintf("PPPInterface: Could not add MRU handler!\n");
|
||||
delete mruHandler;
|
||||
}
|
||||
// authentication
|
||||
@@ -115,14 +109,14 @@ PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID,
|
||||
new _PPPAuthenticationHandler(*this);
|
||||
if(!LCP().AddOptionHandler(authenticationHandler)
|
||||
|| authenticationHandler->InitCheck() != B_OK) {
|
||||
printf("PPPInterface: Could not add authentication handler!\n");
|
||||
dprintf("PPPInterface: Could not add authentication handler!\n");
|
||||
delete authenticationHandler;
|
||||
}
|
||||
// PFC
|
||||
_PPPPFCHandler *pfcHandler =
|
||||
new _PPPPFCHandler(fLocalPFCState, fPeerPFCState, *this);
|
||||
if(!LCP().AddOptionHandler(pfcHandler) || pfcHandler->InitCheck() != B_OK) {
|
||||
printf("PPPInterface: Could not add PFC handler!\n");
|
||||
dprintf("PPPInterface: Could not add PFC handler!\n");
|
||||
delete pfcHandler;
|
||||
}
|
||||
|
||||
@@ -133,7 +127,7 @@ PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID,
|
||||
// 1s delay between lost connection and redial
|
||||
|
||||
if(get_module(PPP_INTERFACE_MODULE_NAME, (module_info**) &fManager) != B_OK)
|
||||
printf("PPPInterface: Manager module not found!\n");
|
||||
dprintf("PPPInterface: Manager module not found!\n");
|
||||
|
||||
// are we a multilink subinterface?
|
||||
if(parent && parent->IsMultilink()) {
|
||||
@@ -186,7 +180,7 @@ PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID,
|
||||
|
||||
// load all protocols and the device
|
||||
if(!LoadModules(fSettings, 0, fSettings->parameter_count)) {
|
||||
printf("PPPInterface: Error loading modules!\n");
|
||||
dprintf("PPPInterface: Error loading modules!\n");
|
||||
fInitStatus = B_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +189,7 @@ PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID,
|
||||
PPPInterface::~PPPInterface()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: Destructor\n");
|
||||
dprintf("PPPInterface: Destructor\n");
|
||||
#endif
|
||||
|
||||
++fDeleteCounter;
|
||||
@@ -216,7 +210,7 @@ PPPInterface::~PPPInterface()
|
||||
fLock.Unlock();
|
||||
}
|
||||
|
||||
Report(PPP_DESTRUCTION_REPORT, 0, &fID, sizeof(interface_id));
|
||||
Report(PPP_DESTRUCTION_REPORT, 0, &fID, sizeof(ppp_interface_id));
|
||||
// tell all listeners that we are being destroyed
|
||||
|
||||
int32 tmp;
|
||||
@@ -267,8 +261,9 @@ PPPInterface::Delete()
|
||||
else {
|
||||
// We were not created by the manager.
|
||||
// Spawn a thread that will delete us.
|
||||
thread_id interfaceDeleterThread = spawn_thread(interface_deleter_thread,
|
||||
"PPPInterface: interface_deleter_thread", B_NORMAL_PRIORITY, this);
|
||||
thread_id interfaceDeleterThread
|
||||
= spawn_kernel_thread(interface_deleter_thread,
|
||||
"PPPInterface: interface_deleter_thread", B_NORMAL_PRIORITY, this);
|
||||
resume_thread(interfaceDeleterThread);
|
||||
}
|
||||
}
|
||||
@@ -298,7 +293,7 @@ bool
|
||||
PPPInterface::SetMRU(uint32 MRU)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: SetMRU(%ld)\n", MRU);
|
||||
dprintf("PPPInterface: SetMRU(%ld)\n", MRU);
|
||||
#endif
|
||||
|
||||
if(Device() && MRU > Device()->MTU() - 2)
|
||||
@@ -481,7 +476,7 @@ bool
|
||||
PPPInterface::SetDevice(PPPDevice *device)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: SetDevice(%p)\n", device);
|
||||
dprintf("PPPInterface: SetDevice(%p)\n", device);
|
||||
#endif
|
||||
|
||||
if(device && &device->Interface() != this)
|
||||
@@ -520,7 +515,7 @@ PPPInterface::AddProtocol(PPPProtocol *protocol)
|
||||
// with the same level.
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPInterface: AddProtocol(%X)\n",
|
||||
dprintf("PPPInterface: AddProtocol(%X)\n",
|
||||
protocol ? protocol->ProtocolNumber() : 0);
|
||||
#endif
|
||||
|
||||
@@ -578,7 +573,7 @@ bool
|
||||
PPPInterface::RemoveProtocol(PPPProtocol *protocol)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: RemoveProtocol(%X)\n",
|
||||
dprintf("PPPInterface: RemoveProtocol(%X)\n",
|
||||
protocol ? protocol->ProtocolNumber() : 0);
|
||||
#endif
|
||||
|
||||
@@ -649,7 +644,7 @@ PPPProtocol*
|
||||
PPPInterface::ProtocolFor(uint16 protocolNumber, PPPProtocol *start = NULL) const
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: ProtocolFor(%X), p&=%X\n", protocolNumber,
|
||||
dprintf("PPPInterface: ProtocolFor(%X), p&=%X\n", protocolNumber,
|
||||
protocolNumber & 0x7FFF);
|
||||
#endif
|
||||
|
||||
@@ -657,7 +652,7 @@ PPPInterface::ProtocolFor(uint16 protocolNumber, PPPProtocol *start = NULL) cons
|
||||
|
||||
for(; current; current = current->NextProtocol()) {
|
||||
#if DEBUG
|
||||
printf("PPPInterface: ProtocolFor(): c=%X, c&=%X\n", current->ProtocolNumber(),
|
||||
dprintf("PPPInterface: ProtocolFor(): c=%X, c&=%X\n", current->ProtocolNumber(),
|
||||
current->ProtocolNumber() & 0x7FFF);
|
||||
#endif
|
||||
|
||||
@@ -676,7 +671,7 @@ bool
|
||||
PPPInterface::AddChild(PPPInterface *child)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: AddChild(%lX)\n",
|
||||
dprintf("PPPInterface: AddChild(%lX)\n",
|
||||
child ? child->ID() : 0);
|
||||
#endif
|
||||
|
||||
@@ -698,7 +693,7 @@ bool
|
||||
PPPInterface::RemoveChild(PPPInterface *child)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: RemoveChild(%lX)\n",
|
||||
dprintf("PPPInterface: RemoveChild(%lX)\n",
|
||||
child ? child->ID() : 0);
|
||||
#endif
|
||||
|
||||
@@ -721,7 +716,7 @@ PPPInterface*
|
||||
PPPInterface::ChildAt(int32 index) const
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: ChildAt(%ld)\n", index);
|
||||
dprintf("PPPInterface: ChildAt(%ld)\n", index);
|
||||
#endif
|
||||
|
||||
PPPInterface *child = fChildren.ItemAt(index);
|
||||
@@ -737,7 +732,7 @@ void
|
||||
PPPInterface::SetAutoRedial(bool autoRedial = true)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false");
|
||||
dprintf("PPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false");
|
||||
#endif
|
||||
|
||||
if(Mode() != PPP_CLIENT_MODE)
|
||||
@@ -756,13 +751,13 @@ PPPInterface::SetDialOnDemand(bool dialOnDemand = true)
|
||||
// interface went down. This is the only situation where a change is relevant.
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false");
|
||||
dprintf("PPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false");
|
||||
#endif
|
||||
|
||||
// Only clients support DialOnDemand.
|
||||
if(Mode() != PPP_CLIENT_MODE) {
|
||||
#if DEBUG
|
||||
printf("PPPInterface::SetDialOnDemand(): Wrong mode!\n");
|
||||
dprintf("PPPInterface::SetDialOnDemand(): Wrong mode!\n");
|
||||
#endif
|
||||
fDialOnDemand = false;
|
||||
return;
|
||||
@@ -801,7 +796,7 @@ bool
|
||||
PPPInterface::SetPFCOptions(uint8 pfcOptions)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: SetPFCOptions(0x%X)\n", pfcOptions);
|
||||
dprintf("PPPInterface: SetPFCOptions(0x%X)\n", pfcOptions);
|
||||
#endif
|
||||
|
||||
if(PFCOptions() & PPP_FREEZE_PFC_OPTIONS)
|
||||
@@ -816,7 +811,7 @@ bool
|
||||
PPPInterface::Up()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: Up()\n");
|
||||
dprintf("PPPInterface: Up()\n");
|
||||
#endif
|
||||
|
||||
if(InitCheck() != B_OK || Phase() == PPP_TERMINATION_PHASE)
|
||||
@@ -845,7 +840,7 @@ PPPInterface::Up()
|
||||
int32 tmp;
|
||||
wait_for_thread(fOpenEventThread, &tmp);
|
||||
}
|
||||
fOpenEventThread = spawn_thread(call_open_event_thread,
|
||||
fOpenEventThread = spawn_kernel_thread(call_open_event_thread,
|
||||
"PPPInterface: call_open_event_thread", B_NORMAL_PRIORITY, this);
|
||||
resume_thread(fOpenEventThread);
|
||||
}
|
||||
@@ -864,7 +859,7 @@ PPPInterface::Up()
|
||||
continue;
|
||||
|
||||
//#if DEBUG
|
||||
// printf("PPPInterface::Up(): Report: Type = %ld Code = %ld\n", report.type,
|
||||
// dprintf("PPPInterface::Up(): Report: Type = %ld Code = %ld\n", report.type,
|
||||
// report.code);
|
||||
//#endif
|
||||
|
||||
@@ -950,7 +945,7 @@ PPPInterface::Up()
|
||||
if(report.code == PPP_REPORT_DEVICE_UP_FAILED) {
|
||||
if(fDialRetry >= fDialRetriesLimit) {
|
||||
#if DEBUG
|
||||
printf("PPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n");
|
||||
dprintf("PPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n");
|
||||
#endif
|
||||
fDialRetry = 0;
|
||||
fUpThread = -1;
|
||||
@@ -963,12 +958,12 @@ PPPInterface::Up()
|
||||
return false;
|
||||
} else {
|
||||
#if DEBUG
|
||||
printf("PPPInterface::Up(): DEVICE_UP_FAILED: <maxretries\n");
|
||||
dprintf("PPPInterface::Up(): DEVICE_UP_FAILED: <maxretries\n");
|
||||
#endif
|
||||
++fDialRetry;
|
||||
PPP_REPLY(sender, B_OK);
|
||||
#if DEBUG
|
||||
printf("PPPInterface::Up(): DEVICE_UP_FAILED: replied\n");
|
||||
dprintf("PPPInterface::Up(): DEVICE_UP_FAILED: replied\n");
|
||||
#endif
|
||||
Redial(DialRetryDelay());
|
||||
continue;
|
||||
@@ -1007,7 +1002,7 @@ bool
|
||||
PPPInterface::Down()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: Down()\n");
|
||||
dprintf("PPPInterface: Down()\n");
|
||||
#endif
|
||||
|
||||
if(InitCheck() != B_OK)
|
||||
@@ -1032,7 +1027,7 @@ PPPInterface::Down()
|
||||
wait_for_thread(fCloseEventThread, &tmp);
|
||||
}
|
||||
|
||||
fCloseEventThread = spawn_thread(call_close_event_thread,
|
||||
fCloseEventThread = spawn_kernel_thread(call_close_event_thread,
|
||||
"PPPInterface: call_close_event_thread", B_NORMAL_PRIORITY, this);
|
||||
resume_thread(fCloseEventThread);
|
||||
locker.UnlockNow();
|
||||
@@ -1075,7 +1070,7 @@ bool
|
||||
PPPInterface::LoadModules(driver_settings *settings, int32 start, int32 count)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: LoadModules()\n");
|
||||
dprintf("PPPInterface: LoadModules()\n");
|
||||
#endif
|
||||
|
||||
if(Phase() != PPP_DOWN_PHASE)
|
||||
@@ -1139,7 +1134,7 @@ PPPInterface::LoadModule(const char *name, driver_parameter *parameter,
|
||||
ppp_module_key_type type)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: LoadModule(%s)\n", name ? name : "XXX: NO NAME");
|
||||
dprintf("PPPInterface: LoadModule(%s)\n", name ? name : "XXX: NO NAME");
|
||||
#endif
|
||||
|
||||
if(Phase() != PPP_DOWN_PHASE)
|
||||
@@ -1176,7 +1171,7 @@ status_t
|
||||
PPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: Send(0x%X)\n", protocolNumber);
|
||||
dprintf("PPPInterface: Send(0x%X)\n", protocolNumber);
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
@@ -1207,21 +1202,21 @@ PPPInterface::Send(struct mbuf *packet, uint16 protocolNumber)
|
||||
|
||||
#if DEBUG
|
||||
if(!protocol)
|
||||
printf("PPPInterface::Send(): no protocol found!\n");
|
||||
dprintf("PPPInterface::Send(): no protocol found!\n");
|
||||
else if(!Device()->IsUp())
|
||||
printf("PPPInterface::Send(): device is not up!\n");
|
||||
dprintf("PPPInterface::Send(): device is not up!\n");
|
||||
else if(!protocol->IsEnabled())
|
||||
printf("PPPInterface::Send(): protocol not enabled!\n");
|
||||
dprintf("PPPInterface::Send(): protocol not enabled!\n");
|
||||
else if(!IsProtocolAllowed(*protocol))
|
||||
printf("PPPInterface::Send(): protocol not allowed to send!\n");
|
||||
dprintf("PPPInterface::Send(): protocol not allowed to send!\n");
|
||||
else
|
||||
printf("PPPInterface::Send(): protocol allowed\n");
|
||||
dprintf("PPPInterface::Send(): protocol allowed\n");
|
||||
#endif
|
||||
|
||||
// make sure that protocol is allowed to send and everything is up
|
||||
if(!Device()->IsUp() || !protocol || !protocol->IsEnabled()
|
||||
|| !IsProtocolAllowed(*protocol)) {
|
||||
printf("PPPInterface::Send(): cannot send!\n");
|
||||
dprintf("PPPInterface::Send(): cannot send!\n");
|
||||
m_freem(packet);
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -1270,7 +1265,7 @@ status_t
|
||||
PPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: Receive(0x%X)\n", protocolNumber);
|
||||
dprintf("PPPInterface: Receive(0x%X)\n", protocolNumber);
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
@@ -1298,7 +1293,7 @@ PPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
||||
protocol = protocol->NextProtocol() ?
|
||||
ProtocolFor(protocolNumber, protocol->NextProtocol()) : NULL) {
|
||||
#if DEBUG
|
||||
printf("PPPInterface::Receive(): trying protocol\n");
|
||||
dprintf("PPPInterface::Receive(): trying protocol\n");
|
||||
#endif
|
||||
|
||||
if(!protocol->IsEnabled() || !IsProtocolAllowed(*protocol))
|
||||
@@ -1313,7 +1308,7 @@ PPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber)
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPInterface::Receive(): trying parent\n");
|
||||
dprintf("PPPInterface::Receive(): trying parent\n");
|
||||
#endif
|
||||
|
||||
// maybe the parent interface can handle the packet
|
||||
@@ -1334,7 +1329,7 @@ status_t
|
||||
PPPInterface::ReceiveFromDevice(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: ReceiveFromDevice()\n");
|
||||
dprintf("PPPInterface: ReceiveFromDevice()\n");
|
||||
#endif
|
||||
|
||||
if(!packet)
|
||||
@@ -1379,7 +1374,7 @@ bool
|
||||
PPPInterface::RegisterInterface()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: RegisterInterface()\n");
|
||||
dprintf("PPPInterface: RegisterInterface()\n");
|
||||
#endif
|
||||
|
||||
if(fIfnet)
|
||||
@@ -1414,7 +1409,7 @@ bool
|
||||
PPPInterface::UnregisterInterface()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: UnregisterInterface()\n");
|
||||
dprintf("PPPInterface: UnregisterInterface()\n");
|
||||
#endif
|
||||
|
||||
if(!fIfnet)
|
||||
@@ -1443,7 +1438,7 @@ status_t
|
||||
PPPInterface::StackControl(uint32 op, void *data)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: StackControl(0x%lX)\n", op);
|
||||
dprintf("PPPInterface: StackControl(0x%lX)\n", op);
|
||||
#endif
|
||||
|
||||
switch(op) {
|
||||
@@ -1486,7 +1481,7 @@ status_t
|
||||
PPPInterface::StackControlEachHandler(uint32 op, void *data)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: StackControlEachHandler(0x%lX)\n", op);
|
||||
dprintf("PPPInterface: StackControlEachHandler(0x%lX)\n", op);
|
||||
#endif
|
||||
|
||||
status_t result = B_BAD_VALUE, tmp;
|
||||
@@ -1513,7 +1508,7 @@ void
|
||||
PPPInterface::CalculateInterfaceMTU()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: CalculateInterfaceMTU()\n");
|
||||
dprintf("PPPInterface: CalculateInterfaceMTU()\n");
|
||||
#endif
|
||||
|
||||
fInterfaceMTU = fMRU;
|
||||
@@ -1542,7 +1537,7 @@ void
|
||||
PPPInterface::CalculateBaudRate()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: CalculateBaudRate()\n");
|
||||
dprintf("PPPInterface: CalculateBaudRate()\n");
|
||||
#endif
|
||||
|
||||
if(!Ifnet())
|
||||
@@ -1564,7 +1559,7 @@ void
|
||||
PPPInterface::Redial(uint32 delay)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPInterface: Redial(%ld)\n", delay);
|
||||
dprintf("PPPInterface: Redial(%ld)\n", delay);
|
||||
#endif
|
||||
|
||||
if(fRedialThread != -1)
|
||||
@@ -1576,7 +1571,7 @@ PPPInterface::Redial(uint32 delay)
|
||||
info.thread = &fRedialThread;
|
||||
info.delay = delay;
|
||||
|
||||
fRedialThread = spawn_thread(redial_thread, "PPPInterface: redial_thread",
|
||||
fRedialThread = spawn_kernel_thread(redial_thread, "PPPInterface: redial_thread",
|
||||
B_NORMAL_PRIORITY, NULL);
|
||||
|
||||
resume_thread(fRedialThread);
|
||||
@@ -1597,9 +1592,9 @@ redial_thread(void *data)
|
||||
// we try to receive data instead of snooze, so we can quit on destruction
|
||||
if(receive_data_with_timeout(&sender, &code, NULL, 0, info.delay) == B_OK) {
|
||||
*info.thread = -1;
|
||||
interface_id id = info.interface->ID();
|
||||
ppp_interface_id id = info.interface->ID();
|
||||
info.interface->Report(PPP_CONNECTION_REPORT, PPP_REPORT_UP_ABORTED,
|
||||
&id, sizeof(interface_id));
|
||||
&id, sizeof(ppp_interface_id));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KPPPInterface.h>
|
||||
#include <KPPPDevice.h>
|
||||
@@ -17,15 +17,6 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#include <KernelExport.h>
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
PPPLCP::PPPLCP(PPPInterface& interface)
|
||||
: PPPProtocol("LCP", PPP_ESTABLISHMENT_PHASE, PPP_LCP_PROTOCOL, PPP_PROTOCOL_LEVEL,
|
||||
AF_UNSPEC, 0, interface, NULL, PPP_ALWAYS_ALLOWED),
|
||||
@@ -227,7 +218,7 @@ PPPLCP::Receive(struct mbuf *packet, uint16 protocolNumber)
|
||||
return B_ERROR;
|
||||
|
||||
if(protocolNumber != PPP_LCP_PROTOCOL) {
|
||||
printf("PPPLCP::Receive(): wrong protocol number!\n");
|
||||
dprintf("PPPLCP::Receive(): wrong protocol number!\n");
|
||||
return PPP_UNHANDLED;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KPPPLCPExtension.h>
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#include <kernel_cpp.h>
|
||||
#endif
|
||||
|
||||
#include <KPPPLayer.h>
|
||||
|
||||
@@ -12,15 +16,6 @@
|
||||
#include <core_funcs.h>
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#include <kernel_cpp.h>
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
PPPLayer::PPPLayer(const char *name, ppp_level level, uint32 overhead)
|
||||
: fInitStatus(B_OK),
|
||||
fOverhead(overhead),
|
||||
@@ -61,7 +56,7 @@ PPPLayer::SendToNext(struct mbuf *packet, uint16 protocolNumber) const
|
||||
else
|
||||
return Next()->SendToNext(packet, protocolNumber);
|
||||
} else {
|
||||
printf("PPPLayer: SendToNext() failed because there is no next handler!\n");
|
||||
dprintf("PPPLayer: SendToNext() failed because there is no next handler!\n");
|
||||
m_freem(packet);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KPPPOptionHandler.h>
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KPPPInterface.h>
|
||||
#include <KPPPUtils.h>
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KPPPReportManager.h>
|
||||
#include <LockerHelper.h>
|
||||
|
||||
#include <KPPPUtils.h>
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#include <KernelExport.h>
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
PPPReportManager::PPPReportManager(BLocker& lock)
|
||||
: fLock(lock)
|
||||
@@ -88,7 +80,7 @@ bool
|
||||
PPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 length)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPReportManager: Report(type=%d code=%ld length=%ld) to %ld receivers\n",
|
||||
dprintf("PPPReportManager: Report(type=%d code=%ld length=%ld) to %ld receivers\n",
|
||||
type, code, length, fReportRequests.CountItems());
|
||||
#endif
|
||||
|
||||
@@ -127,7 +119,7 @@ PPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 len
|
||||
|
||||
#if DEBUG
|
||||
if(result == B_TIMED_OUT)
|
||||
printf("PPPReportManager::Report(): timed out sending\n");
|
||||
dprintf("PPPReportManager::Report(): timed out sending\n");
|
||||
#endif
|
||||
|
||||
if(result == B_BAD_THREAD_ID || result == B_NO_MEMORY) {
|
||||
@@ -144,22 +136,30 @@ PPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 len
|
||||
// always check if the thread still exists
|
||||
while(sender != request->thread
|
||||
&& get_thread_info(request->thread, &info)
|
||||
!= B_BAD_THREAD_ID)
|
||||
!= B_BAD_THREAD_ID) {
|
||||
result = receive_data_with_timeout(&sender, &code, NULL, 0,
|
||||
PPP_REPORT_TIMEOUT);
|
||||
|
||||
if(request->flags & PPP_ALLOW_ANY_REPLY_THREAD)
|
||||
sender = request->thread;
|
||||
}
|
||||
} else {
|
||||
sender = -1;
|
||||
result = B_OK;
|
||||
while(sender != request->thread && result == B_OK)
|
||||
while(sender != request->thread && result == B_OK) {
|
||||
result = receive_data_with_timeout(&sender, &code, NULL, 0,
|
||||
PPP_REPORT_TIMEOUT);
|
||||
|
||||
if(request->flags & PPP_ALLOW_ANY_REPLY_THREAD)
|
||||
sender = request->thread;
|
||||
}
|
||||
}
|
||||
|
||||
if(result == B_OK && code != B_OK)
|
||||
acceptable = false;
|
||||
#if DEBUG
|
||||
if(result == B_TIMED_OUT)
|
||||
printf("PPPReportManager::Report(): reply timed out\n");
|
||||
dprintf("PPPReportManager::Report(): reply timed out\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ PPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 len
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPReportManager::Report(): returning: %s\n", acceptable?"true":"false");
|
||||
dprintf("PPPReportManager::Report(): returning: %s\n", acceptable?"true":"false");
|
||||
#endif
|
||||
|
||||
return acceptable;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
@@ -17,14 +17,6 @@
|
||||
#include <core_funcs.h>
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#define PPP_STATE_MACHINE_TIMEOUT 3000000
|
||||
// 3 seconds
|
||||
|
||||
@@ -71,7 +63,7 @@ void
|
||||
PPPStateMachine::NewState(ppp_state next)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: NewState(%d) state=%d\n", next, State());
|
||||
dprintf("PPPSM: NewState(%d) state=%d\n", next, State());
|
||||
#endif
|
||||
|
||||
// maybe we do not need the timer anymore
|
||||
@@ -90,7 +82,7 @@ PPPStateMachine::NewPhase(ppp_phase next)
|
||||
{
|
||||
#if DEBUG
|
||||
if(next <= PPP_ESTABLISHMENT_PHASE || next == PPP_ESTABLISHED_PHASE)
|
||||
printf("PPPSM: NewPhase(%d) phase=%d\n", next, Phase());
|
||||
dprintf("PPPSM: NewPhase(%d) phase=%d\n", next, Phase());
|
||||
#endif
|
||||
|
||||
// there is nothing after established phase and nothing before down phase
|
||||
@@ -120,7 +112,7 @@ PPPStateMachine::NewPhase(ppp_phase next)
|
||||
Interface().Ifnet()->if_flags |= IFF_UP | IFF_RUNNING;
|
||||
|
||||
Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_UP_SUCCESSFUL,
|
||||
&fInterface.fID, sizeof(interface_id));
|
||||
&fInterface.fID, sizeof(ppp_interface_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +122,7 @@ bool
|
||||
PPPStateMachine::Reconfigure()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: Reconfigure() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: Reconfigure() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -156,7 +148,7 @@ bool
|
||||
PPPStateMachine::SendEchoRequest()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendEchoRequest() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendEchoRequest() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -186,7 +178,7 @@ bool
|
||||
PPPStateMachine::SendDiscardRequest()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendDiscardRequest() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendDiscardRequest() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -216,7 +208,7 @@ void
|
||||
PPPStateMachine::LocalAuthenticationRequested()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: LocalAuthenticationRequested() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: LocalAuthenticationRequested() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -232,7 +224,7 @@ void
|
||||
PPPStateMachine::LocalAuthenticationAccepted(const char *name)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -247,7 +239,7 @@ PPPStateMachine::LocalAuthenticationAccepted(const char *name)
|
||||
|
||||
Interface().Report(PPP_CONNECTION_REPORT,
|
||||
PPP_REPORT_LOCAL_AUTHENTICATION_SUCCESSFUL, &fInterface.fID,
|
||||
sizeof(interface_id));
|
||||
sizeof(ppp_interface_id));
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +247,7 @@ void
|
||||
PPPStateMachine::LocalAuthenticationDenied(const char *name)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: LocalAuthenticationDenied() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: LocalAuthenticationDenied() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -274,7 +266,7 @@ void
|
||||
PPPStateMachine::PeerAuthenticationRequested()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: PeerAuthenticationRequested() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: PeerAuthenticationRequested() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -290,7 +282,7 @@ void
|
||||
PPPStateMachine::PeerAuthenticationAccepted(const char *name)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -305,7 +297,7 @@ PPPStateMachine::PeerAuthenticationAccepted(const char *name)
|
||||
|
||||
Interface().Report(PPP_CONNECTION_REPORT,
|
||||
PPP_REPORT_PEER_AUTHENTICATION_SUCCESSFUL, &fInterface.fID,
|
||||
sizeof(interface_id));
|
||||
sizeof(ppp_interface_id));
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +305,7 @@ void
|
||||
PPPStateMachine::PeerAuthenticationDenied(const char *name)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: PeerAuthenticationDenied() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: PeerAuthenticationDenied() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -334,7 +326,7 @@ void
|
||||
PPPStateMachine::UpFailedEvent(PPPInterface& interface)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: UpFailedEvent(interface) state=%d phase=%d\n",
|
||||
dprintf("PPPSM: UpFailedEvent(interface) state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -347,7 +339,7 @@ void
|
||||
PPPStateMachine::UpEvent(PPPInterface& interface)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: UpEvent(interface) state=%d phase=%d\n",
|
||||
dprintf("PPPSM: UpEvent(interface) state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -377,7 +369,7 @@ void
|
||||
PPPStateMachine::DownEvent(PPPInterface& interface)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: DownEvent(interface) state=%d phase=%d\n",
|
||||
dprintf("PPPSM: DownEvent(interface) state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -423,7 +415,7 @@ void
|
||||
PPPStateMachine::UpFailedEvent(PPPProtocol *protocol)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: UpFailedEvent(protocol) state=%d phase=%d\n",
|
||||
dprintf("PPPSM: UpFailedEvent(protocol) state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -448,7 +440,7 @@ void
|
||||
PPPStateMachine::UpEvent(PPPProtocol *protocol)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: UpEvent(protocol) state=%d phase=%d\n",
|
||||
dprintf("PPPSM: UpEvent(protocol) state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -463,7 +455,7 @@ void
|
||||
PPPStateMachine::DownEvent(PPPProtocol *protocol)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: DownEvent(protocol) state=%d phase=%d\n",
|
||||
dprintf("PPPSM: DownEvent(protocol) state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
}
|
||||
@@ -478,7 +470,7 @@ bool
|
||||
PPPStateMachine::TLSNotify()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: TLSNotify() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: TLSNotify() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -503,7 +495,7 @@ bool
|
||||
PPPStateMachine::TLFNotify()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: TLFNotify() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: TLFNotify() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -520,7 +512,7 @@ void
|
||||
PPPStateMachine::UpFailedEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: UpFailedEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: UpFailedEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -529,7 +521,7 @@ PPPStateMachine::UpFailedEvent()
|
||||
switch(State()) {
|
||||
case PPP_STARTING_STATE:
|
||||
Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_DEVICE_UP_FAILED,
|
||||
&fInterface.fID, sizeof(interface_id));
|
||||
&fInterface.fID, sizeof(ppp_interface_id));
|
||||
if(Interface().Parent())
|
||||
Interface().Parent()->StateMachine().UpFailedEvent(Interface());
|
||||
|
||||
@@ -548,7 +540,7 @@ void
|
||||
PPPStateMachine::UpEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: UpEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: UpEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -613,7 +605,7 @@ void
|
||||
PPPStateMachine::DownEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: DownEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: DownEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -674,12 +666,12 @@ PPPStateMachine::DownEvent()
|
||||
|| fLocalAuthenticationStatus == PPP_AUTHENTICATING)
|
||||
Interface().Report(PPP_CONNECTION_REPORT,
|
||||
PPP_REPORT_LOCAL_AUTHENTICATION_FAILED, &fInterface.fID,
|
||||
sizeof(interface_id));
|
||||
sizeof(ppp_interface_id));
|
||||
else if(fPeerAuthenticationStatus == PPP_AUTHENTICATION_FAILED
|
||||
|| fPeerAuthenticationStatus == PPP_AUTHENTICATING)
|
||||
Interface().Report(PPP_CONNECTION_REPORT,
|
||||
PPP_REPORT_PEER_AUTHENTICATION_FAILED, &fInterface.fID,
|
||||
sizeof(interface_id));
|
||||
sizeof(ppp_interface_id));
|
||||
else {
|
||||
// if we are going up and lost connection the redial attempt becomes
|
||||
// a dial retry which is managed by the main thread in Interface::Up()
|
||||
@@ -689,7 +681,7 @@ PPPStateMachine::DownEvent()
|
||||
// test if UpFailedEvent() was not called
|
||||
if(oldPhase != PPP_DOWN_PHASE)
|
||||
Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_CONNECTION_LOST,
|
||||
&fInterface.fID, sizeof(interface_id));
|
||||
&fInterface.fID, sizeof(ppp_interface_id));
|
||||
}
|
||||
|
||||
if(Interface().Parent())
|
||||
@@ -704,7 +696,7 @@ PPPStateMachine::DownEvent()
|
||||
Interface().Delete();
|
||||
} else {
|
||||
Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_DOWN_SUCCESSFUL,
|
||||
&fInterface.fID, sizeof(interface_id));
|
||||
&fInterface.fID, sizeof(ppp_interface_id));
|
||||
|
||||
if(!Interface().DoesDialOnDemand())
|
||||
Interface().Delete();
|
||||
@@ -717,7 +709,7 @@ void
|
||||
PPPStateMachine::OpenEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: OpenEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: OpenEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -732,7 +724,7 @@ PPPStateMachine::OpenEvent()
|
||||
switch(State()) {
|
||||
case PPP_INITIAL_STATE:
|
||||
if(!Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_GOING_UP,
|
||||
&fInterface.fID, sizeof(interface_id)))
|
||||
&fInterface.fID, sizeof(ppp_interface_id)))
|
||||
return;
|
||||
|
||||
if(Interface().Mode() == PPP_SERVER_MODE) {
|
||||
@@ -783,7 +775,7 @@ void
|
||||
PPPStateMachine::CloseEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: CloseEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: CloseEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -852,7 +844,7 @@ void
|
||||
PPPStateMachine::TOGoodEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: TOGoodEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: TOGoodEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -885,7 +877,7 @@ void
|
||||
PPPStateMachine::TOBadEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: TOBadEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: TOBadEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -920,7 +912,7 @@ void
|
||||
PPPStateMachine::RCRGoodEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RCRGoodEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RCRGoodEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -981,7 +973,7 @@ void
|
||||
PPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RCRBadEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RCRBadEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1042,7 +1034,7 @@ void
|
||||
PPPStateMachine::RCAEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RCAEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RCAEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1122,7 +1114,7 @@ void
|
||||
PPPStateMachine::RCNEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RCNEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RCNEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1205,7 +1197,7 @@ void
|
||||
PPPStateMachine::RTREvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RTREvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RTREvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1258,7 +1250,7 @@ void
|
||||
PPPStateMachine::RTAEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RTAEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RTAEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1318,7 +1310,7 @@ PPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber,
|
||||
uint8 code = PPP_PROTOCOL_REJECT)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RUCEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RUCEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1343,7 +1335,7 @@ void
|
||||
PPPStateMachine::RXJGoodEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RXJGoodEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RXJGoodEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1372,7 +1364,7 @@ void
|
||||
PPPStateMachine::RXJBadEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RXJBadEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RXJBadEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1425,7 +1417,7 @@ void
|
||||
PPPStateMachine::RXREvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RXREvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RXREvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1462,7 +1454,7 @@ PPPStateMachine::TimerEvent()
|
||||
{
|
||||
#if DEBUG
|
||||
if(fNextTimeout != 0)
|
||||
printf("PPPSM: TimerEvent()\n");
|
||||
dprintf("PPPSM: TimerEvent()\n");
|
||||
#endif
|
||||
|
||||
LockerHelper locker(fLock);
|
||||
@@ -1502,7 +1494,7 @@ void
|
||||
PPPStateMachine::RCREvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RCREvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RCREvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1525,14 +1517,14 @@ PPPStateMachine::RCREvent(struct mbuf *packet)
|
||||
optionHandler = LCP().OptionHandlerFor(request.ItemAt(index)->type);
|
||||
|
||||
if(!optionHandler || !optionHandler->IsEnabled()) {
|
||||
printf("PPPSM::RCREvent(): unknown type:%d\n", request.ItemAt(index)->type);
|
||||
dprintf("PPPSM::RCREvent(): unknown type:%d\n", request.ItemAt(index)->type);
|
||||
// unhandled items should be added to the reject
|
||||
reject.AddItem(request.ItemAt(index));
|
||||
continue;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPSM::RCREvent(): OH=%s\n", optionHandler->Name());
|
||||
dprintf("PPPSM::RCREvent(): OH=%s\n", optionHandler->Name());
|
||||
#endif
|
||||
result = optionHandler->ParseRequest(request, index, nak, reject);
|
||||
|
||||
@@ -1543,7 +1535,7 @@ PPPStateMachine::RCREvent(struct mbuf *packet)
|
||||
} else if(result != B_OK) {
|
||||
// the request contains a value that has been sent more than
|
||||
// once or the value is corrupted
|
||||
printf("PPPSM::RCREvent(): OptionHandler returned parse error!\n");
|
||||
dprintf("PPPSM::RCREvent(): OptionHandler returned parse error!\n");
|
||||
m_freem(packet);
|
||||
CloseEvent();
|
||||
return;
|
||||
@@ -1562,7 +1554,7 @@ PPPStateMachine::RCREvent(struct mbuf *packet)
|
||||
if(result != B_OK) {
|
||||
// the request contains a value that has been sent more than
|
||||
// once or the value is corrupted
|
||||
printf("PPPSM::RCREvent(): OptionHandler returned append error!\n");
|
||||
dprintf("PPPSM::RCREvent(): OptionHandler returned append error!\n");
|
||||
m_freem(packet);
|
||||
CloseEvent();
|
||||
return;
|
||||
@@ -1589,7 +1581,7 @@ void
|
||||
PPPStateMachine::RXJEvent(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: RXJEvent() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: RXJEvent() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1658,7 +1650,7 @@ PPPStateMachine::IllegalEvent(ppp_event event)
|
||||
{
|
||||
// TODO:
|
||||
// update error statistics
|
||||
printf("PPPSM: IllegalEvent(event=%d) state=%d phase=%d\n",
|
||||
dprintf("PPPSM: IllegalEvent(event=%d) state=%d phase=%d\n",
|
||||
event, State(), Phase());
|
||||
}
|
||||
|
||||
@@ -1667,7 +1659,7 @@ void
|
||||
PPPStateMachine::ThisLayerUp()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: ThisLayerUp() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: ThisLayerUp() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1692,7 +1684,7 @@ void
|
||||
PPPStateMachine::ThisLayerDown()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: ThisLayerDown() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: ThisLayerDown() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1705,7 +1697,7 @@ void
|
||||
PPPStateMachine::ThisLayerStarted()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: ThisLayerStarted() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: ThisLayerStarted() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1718,7 +1710,7 @@ void
|
||||
PPPStateMachine::ThisLayerFinished()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: ThisLayerFinished() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: ThisLayerFinished() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1749,7 +1741,7 @@ bool
|
||||
PPPStateMachine::SendConfigureRequest()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendConfigureRequest() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendConfigureRequest() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1779,7 +1771,7 @@ bool
|
||||
PPPStateMachine::SendConfigureAck(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendConfigureAck() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendConfigureAck() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1806,7 +1798,7 @@ bool
|
||||
PPPStateMachine::SendConfigureNak(struct mbuf *packet)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendConfigureNak() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendConfigureNak() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1830,7 +1822,7 @@ bool
|
||||
PPPStateMachine::SendTerminateRequest()
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendTerminateRequest() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendTerminateRequest() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1861,7 +1853,7 @@ bool
|
||||
PPPStateMachine::SendTerminateAck(struct mbuf *request = NULL)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendTerminateAck() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendTerminateAck() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1893,7 +1885,7 @@ bool
|
||||
PPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uint8 code)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendCodeReject(protocolNumber=%X;code=%d) state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendCodeReject(protocolNumber=%X;code=%d) state=%d phase=%d\n",
|
||||
protocolNumber, code, State(), Phase());
|
||||
#endif
|
||||
|
||||
@@ -1940,7 +1932,7 @@ bool
|
||||
PPPStateMachine::SendEchoReply(struct mbuf *request)
|
||||
{
|
||||
#if DEBUG
|
||||
printf("PPPSM: SendEchoReply() state=%d phase=%d\n",
|
||||
dprintf("PPPSM: SendEchoReply() state=%d phase=%d\n",
|
||||
State(), Phase());
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "_KPPPAuthenticationHandler.h"
|
||||
|
||||
@@ -13,15 +13,6 @@
|
||||
#include <netinet/in.h>
|
||||
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
#include <KernelExport.h>
|
||||
#define spawn_thread spawn_kernel_thread
|
||||
#define printf dprintf
|
||||
#elif DEBUG
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
#define AUTHENTICATION_TYPE 0x3
|
||||
#define AUTHENTICATOR_TYPE_STRING "Authenticator"
|
||||
|
||||
@@ -109,7 +100,7 @@ _PPPAuthenticationHandler::AddToRequest(PPPConfigurePacket& request)
|
||||
// no problem because the suggested authenticator will be accepted (hopefully)
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPAuthHandler: AddToRequest(%X)\n", authenticator->ProtocolNumber());
|
||||
dprintf("PPPAuthHandler: AddToRequest(%X)\n", authenticator->ProtocolNumber());
|
||||
#endif
|
||||
|
||||
authenticator->SetEnabled(true);
|
||||
@@ -203,7 +194,7 @@ _PPPAuthenticationHandler::ParseRequest(const PPPConfigurePacket& request,
|
||||
// no authentication requested by peer (index > request.CountItems())
|
||||
|
||||
#if DEBUG
|
||||
printf("PPPAuthHandler: ParseRequest(%X)\n", ntohs(item->protocolNumber));
|
||||
dprintf("PPPAuthHandler: ParseRequest(%X)\n", ntohs(item->protocolNumber));
|
||||
#endif
|
||||
|
||||
// try to find the requested protocol
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef __K_PPP_AUTHENTICATION_HANDLER__H
|
||||
#define __K_PPP_AUTHENTICATION_HANDLER__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "_KPPPMRUHandler.h"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef __K_PPP_MRU_HANDLER__H
|
||||
#define __K_PPP_MRU_HANDLER__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "_KPPPPFCHandler.h"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef __K_PPP_PFC_HANDLER__H
|
||||
#define __K_PPP_PFC_HANDLER__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP__H
|
||||
#define _K_PPP__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_CONFIGURE_PACKET__H
|
||||
#define _K_PPP_CONFIGURE_PACKET__H
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_DEFS__H
|
||||
#define _K_PPP_DEFS__H
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <PPPDefs.h>
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_DEVICE__H
|
||||
#define _K_PPP_DEVICE__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_INTERFACE__H
|
||||
#define _K_PPP_INTERFACE__H
|
||||
@@ -45,7 +45,7 @@ class PPPInterface : public PPPLayer {
|
||||
PPPInterface& operator= (const PPPInterface& copy);
|
||||
|
||||
// only PPPManager may construct us!
|
||||
PPPInterface(ppp_interface_entry *entry, interface_id ID,
|
||||
PPPInterface(ppp_interface_entry *entry, ppp_interface_id ID,
|
||||
const driver_settings *settings, PPPInterface *parent = NULL);
|
||||
~PPPInterface();
|
||||
|
||||
@@ -54,7 +54,7 @@ class PPPInterface : public PPPLayer {
|
||||
|
||||
virtual status_t InitCheck() const;
|
||||
|
||||
interface_id ID() const
|
||||
ppp_interface_id ID() const
|
||||
{ return fID; }
|
||||
|
||||
driver_settings* Settings() const
|
||||
@@ -204,7 +204,7 @@ class PPPInterface : public PPPLayer {
|
||||
{ fParent = parent; }
|
||||
|
||||
private:
|
||||
interface_id fID;
|
||||
ppp_interface_id fID;
|
||||
// the manager assigns an ID to every interface
|
||||
driver_settings *fSettings;
|
||||
struct ifnet *fIfnet;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_LCP__H
|
||||
#define _K_PPP_LCP__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef __K_PPP_LCP_EXTENSION__H
|
||||
#define __K_PPP_LCP_EXTENSION__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_LAYER__H
|
||||
#define _K_PPP_LAYER__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_MANAGER__H
|
||||
#define _K_PPP_MANAGER__H
|
||||
@@ -30,21 +30,21 @@ typedef struct ppp_interface_entry {
|
||||
typedef struct ppp_interface_module_info {
|
||||
kernel_net_module_info knminfo;
|
||||
|
||||
interface_id (*CreateInterface)(const driver_settings *settings,
|
||||
interface_id parentID = PPP_UNDEFINED_INTERFACE_ID);
|
||||
ppp_interface_id (*CreateInterface)(const driver_settings *settings,
|
||||
ppp_interface_id parentID = PPP_UNDEFINED_INTERFACE_ID);
|
||||
// you should always create interfaces using this function
|
||||
bool (*DeleteInterface)(interface_id ID);
|
||||
bool (*DeleteInterface)(ppp_interface_id ID);
|
||||
// this marks the interface for deletion
|
||||
bool (*RemoveInterface)(interface_id ID);
|
||||
bool (*RemoveInterface)(ppp_interface_id ID);
|
||||
// remove the interface from database (make sure you can delete it yourself!)
|
||||
|
||||
ifnet *(*RegisterInterface)(interface_id ID);
|
||||
bool (*UnregisterInterface)(interface_id ID);
|
||||
ifnet *(*RegisterInterface)(ppp_interface_id ID);
|
||||
bool (*UnregisterInterface)(ppp_interface_id ID);
|
||||
|
||||
status_t (*ControlInterface)(interface_id ID, uint32 op, void *data,
|
||||
status_t (*ControlInterface)(ppp_interface_id ID, uint32 op, void *data,
|
||||
size_t length);
|
||||
|
||||
int32 (*GetInterfaces)(interface_id *interfaces, int32 count,
|
||||
int32 (*GetInterfaces)(ppp_interface_id *interfaces, int32 count,
|
||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES);
|
||||
// make sure interfaces has enough space for count items
|
||||
int32 (*CountInterfaces)(ppp_interface_filter filter = PPP_REGISTERED_INTERFACES);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_MODULE__H
|
||||
#define _K_PPP_MODULE__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_OPTION_HANDLER__H
|
||||
#define _K_PPP_OPTION_HANDLER__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_PROTOCOL__H
|
||||
#define _K_PPP_PROTOCOL__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_REPORT_MANAGER__H
|
||||
#define _K_PPP_REPORT_MANAGER__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_STATE_MACHINE__H
|
||||
#define _K_PPP_STATE_MACHINE__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _K_PPP_UTILS__H
|
||||
#define _K_PPP_UTILS__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* LockerHelper.h
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _PPP_CONTROL__H
|
||||
#define _PPP_CONTROL__H
|
||||
@@ -84,13 +84,13 @@ enum ppp_control_ops {
|
||||
|
||||
typedef struct ppp_interface_settings_info {
|
||||
const driver_settings *settings;
|
||||
interface_id interface;
|
||||
ppp_interface_id interface;
|
||||
// only when creating: this is the id of the created interface
|
||||
} ppp_interface_settings_info;
|
||||
|
||||
|
||||
typedef struct ppp_get_interfaces_info {
|
||||
interface_id *interfaces;
|
||||
ppp_interface_id *interfaces;
|
||||
int32 count;
|
||||
ppp_interface_filter filter;
|
||||
int32 resultCount;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _PPP_DEFS__H
|
||||
#define _PPP_DEFS__H
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "net_module.h"
|
||||
|
||||
|
||||
typedef uint32 interface_id;
|
||||
typedef uint32 ppp_interface_id;
|
||||
|
||||
|
||||
// settings keys
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _PPP_REPORT_DEFS__H
|
||||
#define _PPP_REPORT_DEFS__H
|
||||
@@ -20,13 +20,15 @@
|
||||
|
||||
// report flags
|
||||
enum ppp_report_flags {
|
||||
PPP_WAIT_FOR_REPLY = 0x1,
|
||||
PPP_REMOVE_AFTER_REPORT = 0x2,
|
||||
PPP_NO_REPLY_TIMEOUT = 0x4
|
||||
PPP_WAIT_FOR_REPLY = 0x01,
|
||||
PPP_REMOVE_AFTER_REPORT = 0x02,
|
||||
PPP_NO_REPLY_TIMEOUT = 0x04,
|
||||
PPP_ALLOW_ANY_REPLY_THREAD = 0x08,
|
||||
};
|
||||
|
||||
// report types
|
||||
// the first 16 report types are reserved for the interface manager
|
||||
// the first 15 report types are reserved for the interface manager
|
||||
#define PPP_INTERFACE_REPORT_TYPE_MIN 16
|
||||
enum ppp_report_type {
|
||||
PPP_ALL_REPORTS = -1,
|
||||
// used only when disabling reports
|
||||
@@ -64,6 +66,7 @@ typedef struct ppp_report_packet {
|
||||
int32 type;
|
||||
int32 code;
|
||||
uint8 length;
|
||||
// length of data
|
||||
char data[PPP_REPORT_DATA_LIMIT];
|
||||
} ppp_report_packet;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include <KPPPDefs.h>
|
||||
#include <driver_settings.h>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _SETTINGS_TOOLS__H
|
||||
#define _SETTINGS_TOOLS__H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "PPPInterface.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "_libppputils.h"
|
||||
|
||||
|
||||
PPPInterface::PPPInterface(interface_id ID = PPP_UNDEFINED_INTERFACE_ID)
|
||||
PPPInterface::PPPInterface(ppp_interface_id ID = PPP_UNDEFINED_INTERFACE_ID)
|
||||
{
|
||||
fFD = open(get_stack_driver_path(), O_RDWR);
|
||||
|
||||
@@ -45,7 +45,7 @@ PPPInterface::InitCheck() const
|
||||
|
||||
|
||||
status_t
|
||||
PPPInterface::SetTo(interface_id ID)
|
||||
PPPInterface::SetTo(ppp_interface_id ID)
|
||||
{
|
||||
if(fFD < 0)
|
||||
return B_ERROR;
|
||||
|
||||
@@ -1,25 +1,109 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "PPPInterfaceListener.h"
|
||||
|
||||
#include "PPPInterface.h"
|
||||
|
||||
#include <Messenger.h>
|
||||
#include <Handler.h>
|
||||
#include <LockerHelper.h>
|
||||
|
||||
|
||||
#define REPORT_FLAGS PPP_WAIT_FOR_REPLY | PPP_NO_REPLY_TIMEOUT
|
||||
|
||||
#define QUIT_REPORT_THREAD 'QUIT'
|
||||
|
||||
|
||||
class PPPInterfaceListenerThread {
|
||||
public:
|
||||
PPPInterfaceListenerThread(PPPInterfaceListener *listener)
|
||||
: fListener(listener) {}
|
||||
|
||||
status_t Run();
|
||||
|
||||
private:
|
||||
PPPInterfaceListener *fListener;
|
||||
};
|
||||
|
||||
|
||||
status_t
|
||||
PPPInterfaceListenerThread::Run()
|
||||
{
|
||||
ppp_report_packet packet;
|
||||
ppp_interface_id *interfaceID;
|
||||
int32 code;
|
||||
thread_id sender;
|
||||
|
||||
BMessage message;
|
||||
bool sendMessage;
|
||||
|
||||
while(true) {
|
||||
code = receive_data(&sender, &packet, sizeof(packet));
|
||||
|
||||
if(code == QUIT_REPORT_THREAD)
|
||||
break;
|
||||
else if(code != PPP_REPORT_CODE)
|
||||
continue;
|
||||
|
||||
BMessenger messenger(fListener->Target());
|
||||
sendMessage = messenger.IsValid();
|
||||
|
||||
if(sendMessage) {
|
||||
message.MakeEmpty();
|
||||
|
||||
message.what = PPP_REPORT_MESSAGE;
|
||||
message.AddInt32("sender", sender);
|
||||
message.AddInt32("type", packet.type);
|
||||
message.AddInt32("code", packet.code);
|
||||
|
||||
if(packet.length >= sizeof(ppp_interface_id)
|
||||
&& ((packet.type == PPP_MANAGER_REPORT
|
||||
&& packet.code == PPP_REPORT_INTERFACE_CREATED)
|
||||
|| packet.type >= PPP_INTERFACE_REPORT_TYPE_MIN)) {
|
||||
interfaceID = reinterpret_cast<ppp_interface_id*>(packet.data);
|
||||
message.AddInt32("interface", static_cast<int32>(*interfaceID));
|
||||
}
|
||||
|
||||
messenger.SendMessage(&message);
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
status_t
|
||||
report_thread(void *data)
|
||||
{
|
||||
// Create BMessage for each report and send it to the target BHandler.
|
||||
// The target must send a reply to the interface!
|
||||
|
||||
PPPInterfaceListenerThread *thread
|
||||
= static_cast<PPPInterfaceListenerThread*>(data);
|
||||
|
||||
return thread->Run();
|
||||
}
|
||||
|
||||
|
||||
PPPInterfaceListener::PPPInterfaceListener(BHandler *target)
|
||||
: fTarget(target)
|
||||
: fTarget(target),
|
||||
fDoesWatch(false),
|
||||
fWatchingInterface(PPP_UNDEFINED_INTERFACE_ID)
|
||||
{
|
||||
Construct();
|
||||
}
|
||||
|
||||
|
||||
PPPInterfaceListener::PPPInterfaceListener(const PPPInterfaceListener& copy)
|
||||
: fTarget(copy.Target())
|
||||
: fTarget(copy.Target()),
|
||||
fDoesWatch(false),
|
||||
fWatchingInterface(PPP_UNDEFINED_INTERFACE_ID)
|
||||
{
|
||||
Construct();
|
||||
}
|
||||
@@ -27,9 +111,14 @@ PPPInterfaceListener::PPPInterfaceListener(const PPPInterfaceListener& copy)
|
||||
|
||||
PPPInterfaceListener::~PPPInterfaceListener()
|
||||
{
|
||||
// TODO: send exit code to thread
|
||||
// int32 tmp;
|
||||
// wait_for_thread(fReportThread, &tmp);
|
||||
// disable all report messages
|
||||
StopWatchingInterfaces();
|
||||
Manager().DisableReports(PPP_ALL_REPORTS, fReportThread);
|
||||
|
||||
// tell thread to quit
|
||||
send_data(fReportThread, QUIT_REPORT_THREAD, NULL, 0);
|
||||
int32 tmp;
|
||||
wait_for_thread(fReportThread, &tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +128,7 @@ PPPInterfaceListener::InitCheck() const
|
||||
if(fReportThread < 0)
|
||||
return B_ERROR;
|
||||
|
||||
return Manager()->InitCheck();
|
||||
return Manager().InitCheck();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +141,76 @@ PPPInterfaceListener::SetTarget(BHandler *target)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PPPInterfaceListener::WatchInterface(ppp_interface_id ID)
|
||||
{
|
||||
StopWatchingInterfaces();
|
||||
|
||||
// enable reports
|
||||
PPPInterface interface(ID);
|
||||
interface.EnableReports(PPP_CONNECTION_REPORT, fReportThread, REPORT_FLAGS);
|
||||
|
||||
fDoesWatch = true;
|
||||
fWatchingInterface = ID;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PPPInterfaceListener::WatchAllInterfaces()
|
||||
{
|
||||
StopWatchingInterfaces();
|
||||
|
||||
// enable interface reports
|
||||
int32 count;
|
||||
PPPInterface interface;
|
||||
ppp_interface_id *interfaceList;
|
||||
|
||||
interfaceList = Manager().Interfaces(&count);
|
||||
if(!interfaceList)
|
||||
return;
|
||||
|
||||
for(int32 index = 0; index < count; index++) {
|
||||
interface.SetTo(interfaceList[index]);
|
||||
interface.EnableReports(PPP_CONNECTION_REPORT, fReportThread, REPORT_FLAGS);
|
||||
}
|
||||
delete interfaceList;
|
||||
|
||||
fDoesWatch = true;
|
||||
fWatchingInterface = PPP_UNDEFINED_INTERFACE_ID;
|
||||
// this means watching all
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PPPInterfaceListener::StopWatchingInterfaces()
|
||||
{
|
||||
// disable reports
|
||||
int32 count;
|
||||
PPPInterface interface;
|
||||
ppp_interface_id *interfaceList;
|
||||
|
||||
interfaceList = Manager().Interfaces(&count);
|
||||
if(!interfaceList)
|
||||
return;
|
||||
|
||||
for(int32 index = 0; index < count; index++) {
|
||||
interface.SetTo(interfaceList[index]);
|
||||
interface.DisableReports(PPP_ALL_REPORTS, fReportThread);
|
||||
}
|
||||
delete interfaceList;
|
||||
|
||||
fDoesWatch = false;
|
||||
fWatchingInterface = PPP_UNDEFINED_INTERFACE_ID;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PPPInterfaceListener::Construct()
|
||||
{
|
||||
// TODO:
|
||||
// create report thread and register it as a receiver using PPPManager
|
||||
fReportThread = spawn_thread(report_thread, "report_thread",
|
||||
B_NORMAL_PRIORITY, new PPPInterfaceListenerThread(this));
|
||||
resume_thread(fReportThread);
|
||||
|
||||
// enable manager reports
|
||||
Manager().EnableReports(PPP_MANAGER_REPORT, fReportThread, REPORT_FLAGS);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "PPPManager.h"
|
||||
#include "PPPInterface.h"
|
||||
@@ -51,7 +51,7 @@ PPPManager::Control(uint32 op, void *data, size_t length) const
|
||||
return ioctl(fFD, NET_STACK_CONTROL_NET_MODULE, &args);
|
||||
}
|
||||
|
||||
interface_id
|
||||
ppp_interface_id
|
||||
PPPManager::CreateInterface(const driver_settings *settings) const
|
||||
{
|
||||
ppp_interface_settings_info info;
|
||||
@@ -65,7 +65,7 @@ PPPManager::CreateInterface(const driver_settings *settings) const
|
||||
|
||||
|
||||
bool
|
||||
PPPManager::DeleteInterface(interface_id ID) const
|
||||
PPPManager::DeleteInterface(ppp_interface_id ID) const
|
||||
{
|
||||
if(Control(PPPC_DELETE_INTERFACE, &ID, sizeof(ID)) != B_OK)
|
||||
return false;
|
||||
@@ -74,12 +74,12 @@ PPPManager::DeleteInterface(interface_id ID) const
|
||||
}
|
||||
|
||||
|
||||
interface_id*
|
||||
ppp_interface_id*
|
||||
PPPManager::Interfaces(int32 *count,
|
||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES) const
|
||||
{
|
||||
int32 requestCount;
|
||||
interface_id *interfaces;
|
||||
ppp_interface_id *interfaces;
|
||||
|
||||
// loop until we get all interfaces
|
||||
while(true) {
|
||||
@@ -89,7 +89,7 @@ PPPManager::Interfaces(int32 *count,
|
||||
|
||||
requestCount += 10;
|
||||
// request some more interfaces in case some are added in the mean time
|
||||
interfaces = new interface_id[requestCount];
|
||||
interfaces = new ppp_interface_id[requestCount];
|
||||
*count = GetInterfaces(interfaces, requestCount, filter);
|
||||
if(*count == -1) {
|
||||
delete interfaces;
|
||||
@@ -107,7 +107,7 @@ PPPManager::Interfaces(int32 *count,
|
||||
|
||||
|
||||
int32
|
||||
PPPManager::GetInterfaces(interface_id *interfaces, int32 count,
|
||||
PPPManager::GetInterfaces(ppp_interface_id *interfaces, int32 count,
|
||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES) const
|
||||
{
|
||||
ppp_get_interfaces_info info;
|
||||
@@ -122,16 +122,16 @@ PPPManager::GetInterfaces(interface_id *interfaces, int32 count,
|
||||
}
|
||||
|
||||
|
||||
interface_id
|
||||
ppp_interface_id
|
||||
PPPManager::InterfaceWithSettings(const driver_settings *settings) const
|
||||
{
|
||||
int32 count;
|
||||
interface_id *interfaces = Interfaces(&count, PPP_ALL_INTERFACES);
|
||||
ppp_interface_id *interfaces = Interfaces(&count, PPP_ALL_INTERFACES);
|
||||
|
||||
if(!interfaces)
|
||||
return PPP_UNDEFINED_INTERFACE_ID;
|
||||
|
||||
interface_id id = PPP_UNDEFINED_INTERFACE_ID;
|
||||
ppp_interface_id id = PPP_UNDEFINED_INTERFACE_ID;
|
||||
PPPInterface interface;
|
||||
ppp_interface_info_t info;
|
||||
|
||||
@@ -150,16 +150,16 @@ PPPManager::InterfaceWithSettings(const driver_settings *settings) const
|
||||
}
|
||||
|
||||
|
||||
interface_id
|
||||
ppp_interface_id
|
||||
PPPManager::InterfaceWithUnit(int32 if_unit)
|
||||
{
|
||||
int32 count;
|
||||
interface_id *interfaces = Interfaces(&count, PPP_REGISTERED_INTERFACES);
|
||||
ppp_interface_id *interfaces = Interfaces(&count, PPP_REGISTERED_INTERFACES);
|
||||
|
||||
if(!interfaces)
|
||||
return PPP_UNDEFINED_INTERFACE_ID;
|
||||
|
||||
interface_id id = PPP_UNDEFINED_INTERFACE_ID;
|
||||
ppp_interface_id id = PPP_UNDEFINED_INTERFACE_ID;
|
||||
PPPInterface interface;
|
||||
ppp_interface_info_t info;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _PPP_INTERFACE__H
|
||||
#define _PPP_INTERFACE__H
|
||||
@@ -13,14 +13,14 @@
|
||||
|
||||
class PPPInterface {
|
||||
public:
|
||||
PPPInterface(interface_id ID = PPP_UNDEFINED_INTERFACE_ID);
|
||||
PPPInterface(ppp_interface_id ID = PPP_UNDEFINED_INTERFACE_ID);
|
||||
PPPInterface(const PPPInterface& copy);
|
||||
~PPPInterface();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
status_t SetTo(interface_id ID);
|
||||
interface_id ID() const
|
||||
status_t SetTo(ppp_interface_id ID);
|
||||
ppp_interface_id ID() const
|
||||
{ return fID; }
|
||||
|
||||
status_t Control(uint32 op, void *data, size_t length) const;
|
||||
@@ -36,11 +36,11 @@ class PPPInterface {
|
||||
|
||||
PPPInterface& operator= (const PPPInterface& copy)
|
||||
{ SetTo(copy.ID()); return *this; }
|
||||
PPPInterface& operator= (interface_id ID)
|
||||
PPPInterface& operator= (ppp_interface_id ID)
|
||||
{ SetTo(ID); return *this; }
|
||||
|
||||
private:
|
||||
interface_id fID;
|
||||
ppp_interface_id fID;
|
||||
|
||||
int fFD;
|
||||
ppp_interface_info_t fInfo;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _PPP_INTERFACE_LISTENER__H
|
||||
#define _PPP_INTERFACE_LISTENER__H
|
||||
@@ -19,6 +19,8 @@ class BHandler;
|
||||
|
||||
|
||||
class PPPInterfaceListener {
|
||||
friend class PPPInterfaceListenerThread;
|
||||
|
||||
public:
|
||||
PPPInterfaceListener(BHandler *target);
|
||||
PPPInterfaceListener(const PPPInterfaceListener& copy);
|
||||
@@ -30,8 +32,17 @@ class PPPInterfaceListener {
|
||||
{ return fTarget; }
|
||||
void SetTarget(BHandler *target);
|
||||
|
||||
const PPPManager *Manager() const
|
||||
{ return &fManager; }
|
||||
bool DoesWatch() const
|
||||
{ return fDoesWatch; }
|
||||
ppp_interface_id WatchingInterface() const
|
||||
{ return fWatchingInterface; }
|
||||
|
||||
const PPPManager& Manager() const
|
||||
{ return fManager; }
|
||||
|
||||
void WatchInterface(ppp_interface_id ID);
|
||||
void WatchAllInterfaces();
|
||||
void StopWatchingInterfaces();
|
||||
|
||||
PPPInterfaceListener& operator= (const PPPInterfaceListener& copy)
|
||||
{ SetTarget(copy.Target()); return *this; }
|
||||
@@ -44,6 +55,9 @@ class PPPInterfaceListener {
|
||||
BHandler *fTarget;
|
||||
thread_id fReportThread;
|
||||
|
||||
bool fDoesWatch;
|
||||
ppp_interface_id fWatchingInterface;
|
||||
|
||||
PPPManager fManager;
|
||||
BLocker fLock;
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// Copyright (c) 2003 Waldemar Kornewald, [email protected]
|
||||
//---------------------------------------------------------------------
|
||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#ifndef _PPP_MANAGER__H
|
||||
#define _PPP_MANAGER__H
|
||||
@@ -25,17 +25,17 @@ class PPPManager {
|
||||
|
||||
status_t Control(uint32 op, void *data, size_t length) const;
|
||||
|
||||
interface_id CreateInterface(const driver_settings *settings) const;
|
||||
bool DeleteInterface(interface_id ID) const;
|
||||
ppp_interface_id CreateInterface(const driver_settings *settings) const;
|
||||
bool DeleteInterface(ppp_interface_id ID) const;
|
||||
|
||||
interface_id *Interfaces(int32 *count,
|
||||
ppp_interface_id *Interfaces(int32 *count,
|
||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES) const;
|
||||
// the user is responsible for deleting the returned array!
|
||||
int32 GetInterfaces(interface_id *interfaces, int32 count,
|
||||
int32 GetInterfaces(ppp_interface_id *interfaces, int32 count,
|
||||
ppp_interface_filter filter = PPP_REGISTERED_INTERFACES) const;
|
||||
// make sure interfaces has enough space for count items
|
||||
interface_id InterfaceWithSettings(const driver_settings *settings) const;
|
||||
interface_id InterfaceWithUnit(int32 if_unit);
|
||||
ppp_interface_id InterfaceWithSettings(const driver_settings *settings) const;
|
||||
ppp_interface_id InterfaceWithUnit(int32 if_unit);
|
||||
int32 CountInterfaces(ppp_interface_filter filter =
|
||||
PPP_REGISTERED_INTERFACES) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user