diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/Jamfile b/src/add-ons/kernel/network/ppp/shared/libkernelppp/Jamfile index 015917b325..dae7380a00 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/Jamfile +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/Jamfile @@ -16,6 +16,7 @@ R5KernelStaticLibrary kernelppp : KPPPLCP.cpp KPPPLCPExtension.cpp KPPPOptionHandler.cpp + KPPPProfile.cpp KPPPProtocol.cpp KPPPReportManager.cpp KPPPStateMachine.cpp diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPConfigurePacket.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPConfigurePacket.cpp index da1247e76f..05355c13f9 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPConfigurePacket.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPConfigurePacket.cpp @@ -11,14 +11,14 @@ #include -PPPConfigurePacket::PPPConfigurePacket(uint8 code) +KPPPConfigurePacket::KPPPConfigurePacket(uint8 code) : fCode(code), fID(0) { } -PPPConfigurePacket::PPPConfigurePacket(struct mbuf *packet) +KPPPConfigurePacket::KPPPConfigurePacket(struct mbuf *packet) { // decode packet ppp_lcp_packet *header = mtod(packet, ppp_lcp_packet*); @@ -48,7 +48,7 @@ PPPConfigurePacket::PPPConfigurePacket(struct mbuf *packet) } -PPPConfigurePacket::~PPPConfigurePacket() +KPPPConfigurePacket::~KPPPConfigurePacket() { for(int32 index = 0; index < CountItems(); index++) free(ItemAt(index)); @@ -56,7 +56,7 @@ PPPConfigurePacket::~PPPConfigurePacket() bool -PPPConfigurePacket::SetCode(uint8 code) +KPPPConfigurePacket::SetCode(uint8 code) { // only configure codes are allowed! if(code < PPP_CONFIGURE_REQUEST || code > PPP_CONFIGURE_REJECT) @@ -69,7 +69,7 @@ PPPConfigurePacket::SetCode(uint8 code) bool -PPPConfigurePacket::AddItem(const ppp_configure_item *item, int32 index = -1) +KPPPConfigurePacket::AddItem(const ppp_configure_item *item, int32 index = -1) { if(!item || item->length < 2) return false; @@ -92,7 +92,7 @@ PPPConfigurePacket::AddItem(const ppp_configure_item *item, int32 index = -1) bool -PPPConfigurePacket::RemoveItem(ppp_configure_item *item) +KPPPConfigurePacket::RemoveItem(ppp_configure_item *item) { if(!fItems.HasItem(item)) return false; @@ -105,7 +105,7 @@ PPPConfigurePacket::RemoveItem(ppp_configure_item *item) ppp_configure_item* -PPPConfigurePacket::ItemAt(int32 index) const +KPPPConfigurePacket::ItemAt(int32 index) const { ppp_configure_item *item = fItems.ItemAt(index); @@ -117,7 +117,7 @@ PPPConfigurePacket::ItemAt(int32 index) const ppp_configure_item* -PPPConfigurePacket::ItemWithType(uint8 type) const +KPPPConfigurePacket::ItemWithType(uint8 type) const { ppp_configure_item *item; @@ -132,7 +132,7 @@ PPPConfigurePacket::ItemWithType(uint8 type) const struct mbuf* -PPPConfigurePacket::ToMbuf(uint32 MRU, uint32 reserve = 0) +KPPPConfigurePacket::ToMbuf(uint32 MRU, uint32 reserve = 0) { struct mbuf *packet = m_gethdr(MT_DATA); packet->m_data += reserve; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPDevice.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPDevice.cpp index 61667c2f4b..3bb134a6dd 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPDevice.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPDevice.cpp @@ -13,9 +13,9 @@ #include -PPPDevice::PPPDevice(const char *name, uint32 overhead, PPPInterface& interface, +KPPPDevice::KPPPDevice(const char *name, uint32 overhead, KPPPInterface& interface, driver_parameter *settings) - : PPPLayer(name, PPP_DEVICE_LEVEL, overhead), + : KPPPLayer(name, PPP_DEVICE_LEVEL, overhead), fMTU(1500), fInterface(interface), fSettings(settings), @@ -24,7 +24,7 @@ PPPDevice::PPPDevice(const char *name, uint32 overhead, PPPInterface& interface, } -PPPDevice::~PPPDevice() +KPPPDevice::~KPPPDevice() { if(Interface().Device() == this) Interface().SetDevice(NULL); @@ -32,7 +32,7 @@ PPPDevice::~PPPDevice() status_t -PPPDevice::Control(uint32 op, void *data, size_t length) +KPPPDevice::Control(uint32 op, void *data, size_t length) { switch(op) { case PPPC_GET_DEVICE_INFO: { @@ -42,7 +42,6 @@ PPPDevice::Control(uint32 op, void *data, size_t length) ppp_device_info *info = (ppp_device_info*) data; memset(info, 0, sizeof(ppp_device_info_t)); strncpy(info->name, Name(), PPP_HANDLER_NAME_LENGTH_LIMIT); - info->settings = Settings(); info->MTU = MTU(); info->inputTransferRate = InputTransferRate(); info->outputTransferRate = OutputTransferRate(); @@ -59,7 +58,7 @@ PPPDevice::Control(uint32 op, void *data, size_t length) bool -PPPDevice::IsAllowedToSend() const +KPPPDevice::IsAllowedToSend() const { return true; // our connection status will be reported in Send() @@ -67,7 +66,7 @@ PPPDevice::IsAllowedToSend() const status_t -PPPDevice::Receive(struct mbuf *packet, uint16 protocolNumber) +KPPPDevice::Receive(struct mbuf *packet, uint16 protocolNumber) { // let the interface handle the packet if(protocolNumber == 0) @@ -78,14 +77,14 @@ PPPDevice::Receive(struct mbuf *packet, uint16 protocolNumber) void -PPPDevice::Pulse() +KPPPDevice::Pulse() { // do nothing by default } bool -PPPDevice::UpStarted() +KPPPDevice::UpStarted() { fConnectionPhase = PPP_ESTABLISHMENT_PHASE; @@ -94,7 +93,7 @@ PPPDevice::UpStarted() bool -PPPDevice::DownStarted() +KPPPDevice::DownStarted() { fConnectionPhase = PPP_TERMINATION_PHASE; @@ -103,7 +102,7 @@ PPPDevice::DownStarted() void -PPPDevice::UpFailedEvent() +KPPPDevice::UpFailedEvent() { fConnectionPhase = PPP_DOWN_PHASE; @@ -112,7 +111,7 @@ PPPDevice::UpFailedEvent() void -PPPDevice::UpEvent() +KPPPDevice::UpEvent() { fConnectionPhase = PPP_ESTABLISHED_PHASE; @@ -121,7 +120,7 @@ PPPDevice::UpEvent() void -PPPDevice::DownEvent() +KPPPDevice::DownEvent() { fConnectionPhase = PPP_DOWN_PHASE; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp index b0781a9335..73d09a532b 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp @@ -5,7 +5,7 @@ // Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de //----------------------------------------------------------------------- -// cstdio must be included before PPPModule.h/PPPManager.h because +// cstdio must be included before KPPPModule.h/KPPPManager.h because // ddprintf is defined twice with different return values, once with // void (KernelExport.h) and once with int (stdio.h). #include @@ -39,11 +39,12 @@ // TODO: // - implement timers with support for settings next time instead of receiving timer // events periodically +// - add missing settings support (DialRetryDelay, etc.) // needed for redial: typedef struct redial_info { - PPPInterface *interface; + KPPPInterface *interface; thread_id *thread; uint32 delay; } redial_info; @@ -56,9 +57,10 @@ status_t call_open_event_thread(void *data); status_t call_close_event_thread(void *data); -PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID, - const driver_settings *settings, PPPInterface *parent = NULL) - : PPPLayer("PPPInterface", PPP_INTERFACE_LEVEL, 2), +KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry, + ppp_interface_id ID, const driver_settings *settings, + const driver_settings *profile, KPPPInterface *parent = NULL) + : KPPPLayer(name, PPP_INTERFACE_LEVEL, 2), fID(ID), fSettings(dup_driver_settings(settings)), fIfnet(NULL), @@ -85,12 +87,15 @@ PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID, fFirstProtocol(NULL), fStateMachine(*this), fLCP(*this), + fProfile(*this), fReportManager(StateMachine().fLock), fLock(StateMachine().fLock), fDeleteCounter(0) { entry->interface = this; + fProfile.LoadSettings(profile, fSettings); + // add internal modules // LCP if(!AddProtocol(&LCP())) { @@ -98,25 +103,25 @@ PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID, return; } // MRU - _PPPMRUHandler *mruHandler = - new _PPPMRUHandler(*this); + _KPPPMRUHandler *mruHandler = + new _KPPPMRUHandler(*this); if(!LCP().AddOptionHandler(mruHandler) || mruHandler->InitCheck() != B_OK) { - dprintf("PPPInterface: Could not add MRU handler!\n"); + dprintf("KPPPInterface: Could not add MRU handler!\n"); delete mruHandler; } // authentication - _PPPAuthenticationHandler *authenticationHandler = - new _PPPAuthenticationHandler(*this); + _KPPPAuthenticationHandler *authenticationHandler = + new _KPPPAuthenticationHandler(*this); if(!LCP().AddOptionHandler(authenticationHandler) || authenticationHandler->InitCheck() != B_OK) { - dprintf("PPPInterface: Could not add authentication handler!\n"); + dprintf("KPPPInterface: Could not add authentication handler!\n"); delete authenticationHandler; } // PFC - _PPPPFCHandler *pfcHandler = - new _PPPPFCHandler(fLocalPFCState, fPeerPFCState, *this); + _KPPPPFCHandler *pfcHandler = + new _KPPPPFCHandler(fLocalPFCState, fPeerPFCState, *this); if(!LCP().AddOptionHandler(pfcHandler) || pfcHandler->InitCheck() != B_OK) { - dprintf("PPPInterface: Could not add PFC handler!\n"); + dprintf("KPPPInterface: Could not add PFC handler!\n"); delete pfcHandler; } @@ -127,7 +132,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) - dprintf("PPPInterface: Manager module not found!\n"); + dprintf("KPPPInterface: Manager module not found!\n"); // are we a multilink subinterface? if(parent && parent->IsMultilink()) { @@ -180,16 +185,16 @@ PPPInterface::PPPInterface(ppp_interface_entry *entry, uint32 ID, // load all protocols and the device if(!LoadModules(fSettings, 0, fSettings->parameter_count)) { - dprintf("PPPInterface: Error loading modules!\n"); + dprintf("KPPPInterface: Error loading modules!\n"); fInitStatus = B_ERROR; } } -PPPInterface::~PPPInterface() +KPPPInterface::~KPPPInterface() { #if DEBUG - dprintf("PPPInterface: Destructor\n"); + dprintf("KPPPInterface: Destructor\n"); #endif ++fDeleteCounter; @@ -248,7 +253,7 @@ PPPInterface::~PPPInterface() void -PPPInterface::Delete() +KPPPInterface::Delete() { if(atomic_add(&fDeleteCounter, 1) > 0) return; @@ -263,14 +268,14 @@ PPPInterface::Delete() // Spawn a thread that will delete us. thread_id interfaceDeleterThread = spawn_kernel_thread(interface_deleter_thread, - "PPPInterface: interface_deleter_thread", B_NORMAL_PRIORITY, this); + "KPPPInterface: interface_deleter_thread", B_NORMAL_PRIORITY, this); resume_thread(interfaceDeleterThread); } } status_t -PPPInterface::InitCheck() const +KPPPInterface::InitCheck() const { if(fInitStatus != B_OK) return fInitStatus; @@ -290,10 +295,10 @@ PPPInterface::InitCheck() const bool -PPPInterface::SetMRU(uint32 MRU) +KPPPInterface::SetMRU(uint32 MRU) { #if DEBUG - dprintf("PPPInterface: SetMRU(%ld)\n", MRU); + dprintf("KPPPInterface: SetMRU(%ld)\n", MRU); #endif if(Device() && MRU > Device()->MTU() - 2) @@ -310,7 +315,7 @@ PPPInterface::SetMRU(uint32 MRU) uint32 -PPPInterface::PacketOverhead() const +KPPPInterface::PacketOverhead() const { uint32 overhead = fHeaderLength + 2; @@ -322,7 +327,7 @@ PPPInterface::PacketOverhead() const status_t -PPPInterface::Control(uint32 op, void *data, size_t length) +KPPPInterface::Control(uint32 op, void *data, size_t length) { switch(op) { case PPPC_GET_INTERFACE_INFO: { @@ -331,7 +336,7 @@ PPPInterface::Control(uint32 op, void *data, size_t length) ppp_interface_info *info = (ppp_interface_info*) data; memset(info, 0, sizeof(ppp_interface_info_t)); - info->settings = Settings(); + strncpy(info->name, Name(), PPP_HANDLER_NAME_LENGTH_LIMIT); if(Ifnet()) info->if_unit = Ifnet()->if_unit; else @@ -386,6 +391,16 @@ PPPInterface::Control(uint32 op, void *data, size_t length) SetAutoRedial(*((uint32*)data)); break; + case PPPC_HAS_INTERFACE_SETTINGS: + if(length < sizeof(driver_settings) || !data) + return B_ERROR; + + if(equal_interface_settings(Settings(), (driver_settings*) data)) + return B_OK; + else + return B_ERROR; + break; + case PPPC_ENABLE_REPORTS: { if(length < sizeof(ppp_report_request) || !data) return B_ERROR; @@ -419,7 +434,7 @@ PPPInterface::Control(uint32 op, void *data, size_t length) return B_ERROR; ppp_control_info *control = (ppp_control_info*) data; - PPPProtocol *protocol = ProtocolAt(control->index); + KPPPProtocol *protocol = ProtocolAt(control->index); if(!protocol) return B_BAD_INDEX; @@ -431,7 +446,7 @@ PPPInterface::Control(uint32 op, void *data, size_t length) return B_ERROR; ppp_control_info *control = (ppp_control_info*) data; - PPPOptionHandler *optionHandler = LCP().OptionHandlerAt(control->index); + KPPPOptionHandler *optionHandler = LCP().OptionHandlerAt(control->index); if(!optionHandler) return B_BAD_INDEX; @@ -444,7 +459,7 @@ PPPInterface::Control(uint32 op, void *data, size_t length) return B_ERROR; ppp_control_info *control = (ppp_control_info*) data; - PPPLCPExtension *lcpExtension = LCP().LCPExtensionAt(control->index); + KPPPLCPExtension *lcpExtension = LCP().LCPExtensionAt(control->index); if(!lcpExtension) return B_BAD_INDEX; @@ -457,7 +472,7 @@ PPPInterface::Control(uint32 op, void *data, size_t length) return B_ERROR; ppp_control_info *control = (ppp_control_info*) data; - PPPInterface *child = ChildAt(control->index); + KPPPInterface *child = ChildAt(control->index); if(!child) return B_BAD_INDEX; @@ -473,10 +488,10 @@ PPPInterface::Control(uint32 op, void *data, size_t length) bool -PPPInterface::SetDevice(PPPDevice *device) +KPPPInterface::SetDevice(KPPPDevice *device) { #if DEBUG - dprintf("PPPInterface: SetDevice(%p)\n", device); + dprintf("KPPPInterface: SetDevice(%p)\n", device); #endif if(device && &device->Interface() != this) @@ -509,13 +524,13 @@ PPPInterface::SetDevice(PPPDevice *device) bool -PPPInterface::AddProtocol(PPPProtocol *protocol) +KPPPInterface::AddProtocol(KPPPProtocol *protocol) { // Find instert position after the last protocol // with the same level. #if DEBUG - dprintf("PPPInterface: AddProtocol(%X)\n", + dprintf("KPPPInterface: AddProtocol(%X)\n", protocol ? protocol->ProtocolNumber() : 0); #endif @@ -529,7 +544,7 @@ PPPInterface::AddProtocol(PPPProtocol *protocol) return false; // a running connection may not change - PPPProtocol *current = fFirstProtocol, *previous = NULL; + KPPPProtocol *current = fFirstProtocol, *previous = NULL; while(current) { if(current->Level() < protocol->Level()) @@ -570,10 +585,10 @@ PPPInterface::AddProtocol(PPPProtocol *protocol) bool -PPPInterface::RemoveProtocol(PPPProtocol *protocol) +KPPPInterface::RemoveProtocol(KPPPProtocol *protocol) { #if DEBUG - dprintf("PPPInterface: RemoveProtocol(%X)\n", + dprintf("KPPPInterface: RemoveProtocol(%X)\n", protocol ? protocol->ProtocolNumber() : 0); #endif @@ -583,7 +598,7 @@ PPPInterface::RemoveProtocol(PPPProtocol *protocol) return false; // a running connection may not change - PPPProtocol *current = fFirstProtocol, *previous = NULL; + KPPPProtocol *current = fFirstProtocol, *previous = NULL; while(current) { if(current == protocol) { @@ -615,9 +630,9 @@ PPPInterface::RemoveProtocol(PPPProtocol *protocol) int32 -PPPInterface::CountProtocols() const +KPPPInterface::CountProtocols() const { - PPPProtocol *protocol = FirstProtocol(); + KPPPProtocol *protocol = FirstProtocol(); int32 count = 0; for(; protocol; protocol = protocol->NextProtocol()) @@ -627,10 +642,10 @@ PPPInterface::CountProtocols() const } -PPPProtocol* -PPPInterface::ProtocolAt(int32 index) const +KPPPProtocol* +KPPPInterface::ProtocolAt(int32 index) const { - PPPProtocol *protocol = FirstProtocol(); + KPPPProtocol *protocol = FirstProtocol(); int32 currentIndex = 0; for(; protocol && currentIndex != index; protocol = protocol->NextProtocol()) @@ -640,19 +655,19 @@ PPPInterface::ProtocolAt(int32 index) const } -PPPProtocol* -PPPInterface::ProtocolFor(uint16 protocolNumber, PPPProtocol *start = NULL) const +KPPPProtocol* +KPPPInterface::ProtocolFor(uint16 protocolNumber, KPPPProtocol *start = NULL) const { #if DEBUG - dprintf("PPPInterface: ProtocolFor(%X), p&=%X\n", protocolNumber, + dprintf("KPPPInterface: ProtocolFor(%X), p&=%X\n", protocolNumber, protocolNumber & 0x7FFF); #endif - PPPProtocol *current = start ? start : FirstProtocol(); + KPPPProtocol *current = start ? start : FirstProtocol(); for(; current; current = current->NextProtocol()) { #if DEBUG - dprintf("PPPInterface: ProtocolFor(): c=%X, c&=%X\n", current->ProtocolNumber(), + dprintf("KPPPInterface: ProtocolFor(): c=%X, c&=%X\n", current->ProtocolNumber(), current->ProtocolNumber() & 0x7FFF); #endif @@ -668,10 +683,10 @@ PPPInterface::ProtocolFor(uint16 protocolNumber, PPPProtocol *start = NULL) cons bool -PPPInterface::AddChild(PPPInterface *child) +KPPPInterface::AddChild(KPPPInterface *child) { #if DEBUG - dprintf("PPPInterface: AddChild(%lX)\n", + dprintf("KPPPInterface: AddChild(%lX)\n", child ? child->ID() : 0); #endif @@ -690,10 +705,10 @@ PPPInterface::AddChild(PPPInterface *child) bool -PPPInterface::RemoveChild(PPPInterface *child) +KPPPInterface::RemoveChild(KPPPInterface *child) { #if DEBUG - dprintf("PPPInterface: RemoveChild(%lX)\n", + dprintf("KPPPInterface: RemoveChild(%lX)\n", child ? child->ID() : 0); #endif @@ -712,14 +727,14 @@ PPPInterface::RemoveChild(PPPInterface *child) } -PPPInterface* -PPPInterface::ChildAt(int32 index) const +KPPPInterface* +KPPPInterface::ChildAt(int32 index) const { #if DEBUG - dprintf("PPPInterface: ChildAt(%ld)\n", index); + dprintf("KPPPInterface: ChildAt(%ld)\n", index); #endif - PPPInterface *child = fChildren.ItemAt(index); + KPPPInterface *child = fChildren.ItemAt(index); if(child == fChildren.GetDefaultItem()) return NULL; @@ -729,10 +744,10 @@ PPPInterface::ChildAt(int32 index) const void -PPPInterface::SetAutoRedial(bool autoRedial = true) +KPPPInterface::SetAutoRedial(bool autoRedial = true) { #if DEBUG - dprintf("PPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false"); + dprintf("KPPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false"); #endif if(Mode() != PPP_CLIENT_MODE) @@ -745,19 +760,19 @@ PPPInterface::SetAutoRedial(bool autoRedial = true) void -PPPInterface::SetDialOnDemand(bool dialOnDemand = true) +KPPPInterface::SetDialOnDemand(bool dialOnDemand = true) { // All protocols must check if DialOnDemand was enabled/disabled after this // interface went down. This is the only situation where a change is relevant. #if DEBUG - dprintf("PPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false"); + dprintf("KPPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false"); #endif // Only clients support DialOnDemand. if(Mode() != PPP_CLIENT_MODE) { #if DEBUG - dprintf("PPPInterface::SetDialOnDemand(): Wrong mode!\n"); + dprintf("KPPPInterface::SetDialOnDemand(): Wrong mode!\n"); #endif fDialOnDemand = false; return; @@ -793,10 +808,10 @@ PPPInterface::SetDialOnDemand(bool dialOnDemand = true) bool -PPPInterface::SetPFCOptions(uint8 pfcOptions) +KPPPInterface::SetPFCOptions(uint8 pfcOptions) { #if DEBUG - dprintf("PPPInterface: SetPFCOptions(0x%X)\n", pfcOptions); + dprintf("KPPPInterface: SetPFCOptions(0x%X)\n", pfcOptions); #endif if(PFCOptions() & PPP_FREEZE_PFC_OPTIONS) @@ -808,10 +823,10 @@ PPPInterface::SetPFCOptions(uint8 pfcOptions) bool -PPPInterface::Up() +KPPPInterface::Up() { #if DEBUG - dprintf("PPPInterface: Up()\n"); + dprintf("KPPPInterface: Up()\n"); #endif if(InitCheck() != B_OK || Phase() == PPP_TERMINATION_PHASE) @@ -841,7 +856,7 @@ PPPInterface::Up() wait_for_thread(fOpenEventThread, &tmp); } fOpenEventThread = spawn_kernel_thread(call_open_event_thread, - "PPPInterface: call_open_event_thread", B_NORMAL_PRIORITY, this); + "KPPPInterface: call_open_event_thread", B_NORMAL_PRIORITY, this); resume_thread(fOpenEventThread); } fLock.Unlock(); @@ -859,7 +874,7 @@ PPPInterface::Up() continue; //#if DEBUG -// dprintf("PPPInterface::Up(): Report: Type = %ld Code = %ld\n", report.type, +// dprintf("KPPPInterface::Up(): Report: Type = %ld Code = %ld\n", report.type, // report.code); //#endif @@ -945,7 +960,7 @@ PPPInterface::Up() if(report.code == PPP_REPORT_DEVICE_UP_FAILED) { if(fDialRetry >= fDialRetriesLimit) { #if DEBUG - dprintf("PPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n"); + dprintf("KPPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n"); #endif fDialRetry = 0; fUpThread = -1; @@ -958,12 +973,12 @@ PPPInterface::Up() return false; } else { #if DEBUG - dprintf("PPPInterface::Up(): DEVICE_UP_FAILED: CreateInterface(settings, ID()); + fManager->CreateInterface(settings, Profile().Settings(), ID()); return true; } @@ -1130,11 +1145,11 @@ PPPInterface::LoadModules(driver_settings *settings, int32 start, int32 count) bool -PPPInterface::LoadModule(const char *name, driver_parameter *parameter, +KPPPInterface::LoadModule(const char *name, driver_parameter *parameter, ppp_module_key_type type) { #if DEBUG - dprintf("PPPInterface: LoadModule(%s)\n", name ? name : "XXX: NO NAME"); + dprintf("KPPPInterface: LoadModule(%s)\n", name ? name : "XXX: NO NAME"); #endif if(Phase() != PPP_DOWN_PHASE) @@ -1161,17 +1176,17 @@ PPPInterface::LoadModule(const char *name, driver_parameter *parameter, bool -PPPInterface::IsAllowedToSend() const +KPPPInterface::IsAllowedToSend() const { return true; } status_t -PPPInterface::Send(struct mbuf *packet, uint16 protocolNumber) +KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber) { #if DEBUG - dprintf("PPPInterface: Send(0x%X)\n", protocolNumber); + dprintf("KPPPInterface: Send(0x%X)\n", protocolNumber); #endif if(!packet) @@ -1195,28 +1210,28 @@ PPPInterface::Send(struct mbuf *packet, uint16 protocolNumber) } // find the protocol handler for the current protocol number - PPPProtocol *protocol = ProtocolFor(protocolNumber); + KPPPProtocol *protocol = ProtocolFor(protocolNumber); while(protocol && !protocol->IsEnabled()) protocol = protocol->NextProtocol() ? ProtocolFor(protocolNumber, protocol->NextProtocol()) : NULL; #if DEBUG if(!protocol) - dprintf("PPPInterface::Send(): no protocol found!\n"); + dprintf("KPPPInterface::Send(): no protocol found!\n"); else if(!Device()->IsUp()) - dprintf("PPPInterface::Send(): device is not up!\n"); + dprintf("KPPPInterface::Send(): device is not up!\n"); else if(!protocol->IsEnabled()) - dprintf("PPPInterface::Send(): protocol not enabled!\n"); + dprintf("KPPPInterface::Send(): protocol not enabled!\n"); else if(!IsProtocolAllowed(*protocol)) - dprintf("PPPInterface::Send(): protocol not allowed to send!\n"); + dprintf("KPPPInterface::Send(): protocol not allowed to send!\n"); else - dprintf("PPPInterface::Send(): protocol allowed\n"); + dprintf("KPPPInterface::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)) { - dprintf("PPPInterface::Send(): cannot send!\n"); + dprintf("KPPPInterface::Send(): cannot send!\n"); m_freem(packet); return B_ERROR; } @@ -1262,10 +1277,10 @@ PPPInterface::Send(struct mbuf *packet, uint16 protocolNumber) status_t -PPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) +KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) { #if DEBUG - dprintf("PPPInterface: Receive(0x%X)\n", protocolNumber); + dprintf("KPPPInterface: Receive(0x%X)\n", protocolNumber); #endif if(!packet) @@ -1288,12 +1303,12 @@ PPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) // The handler does need not be up because if we are a server // the handler might be upped by this packet. // If authenticating we only allow authentication phase protocols. - PPPProtocol *protocol = ProtocolFor(protocolNumber); + KPPPProtocol *protocol = ProtocolFor(protocolNumber); for(; protocol; protocol = protocol->NextProtocol() ? ProtocolFor(protocolNumber, protocol->NextProtocol()) : NULL) { #if DEBUG - dprintf("PPPInterface::Receive(): trying protocol\n"); + dprintf("KPPPInterface::Receive(): trying protocol\n"); #endif if(!protocol->IsEnabled() || !IsProtocolAllowed(*protocol)) @@ -1308,7 +1323,7 @@ PPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) } #if DEBUG - dprintf("PPPInterface::Receive(): trying parent\n"); + dprintf("KPPPInterface::Receive(): trying parent\n"); #endif // maybe the parent interface can handle the packet @@ -1326,10 +1341,10 @@ PPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) status_t -PPPInterface::ReceiveFromDevice(struct mbuf *packet) +KPPPInterface::ReceiveFromDevice(struct mbuf *packet) { #if DEBUG - dprintf("PPPInterface: ReceiveFromDevice()\n"); + dprintf("KPPPInterface: ReceiveFromDevice()\n"); #endif if(!packet) @@ -1354,12 +1369,12 @@ PPPInterface::ReceiveFromDevice(struct mbuf *packet) void -PPPInterface::Pulse() +KPPPInterface::Pulse() { if(Device()) Device()->Pulse(); - PPPProtocol *protocol = FirstProtocol(); + KPPPProtocol *protocol = FirstProtocol(); for(; protocol; protocol = protocol->NextProtocol()) protocol->Pulse(); @@ -1371,10 +1386,10 @@ PPPInterface::Pulse() bool -PPPInterface::RegisterInterface() +KPPPInterface::RegisterInterface() { #if DEBUG - dprintf("PPPInterface: RegisterInterface()\n"); + dprintf("KPPPInterface: RegisterInterface()\n"); #endif if(fIfnet) @@ -1406,10 +1421,10 @@ PPPInterface::RegisterInterface() bool -PPPInterface::UnregisterInterface() +KPPPInterface::UnregisterInterface() { #if DEBUG - dprintf("PPPInterface: UnregisterInterface()\n"); + dprintf("KPPPInterface: UnregisterInterface()\n"); #endif if(!fIfnet) @@ -1433,12 +1448,12 @@ PPPInterface::UnregisterInterface() } -// called by PPPManager: manager routes stack ioctls to interface +// called by KPPPManager: manager routes stack ioctls to interface status_t -PPPInterface::StackControl(uint32 op, void *data) +KPPPInterface::StackControl(uint32 op, void *data) { #if DEBUG - dprintf("PPPInterface: StackControl(0x%lX)\n", op); + dprintf("KPPPInterface: StackControl(0x%lX)\n", op); #endif switch(op) { @@ -1478,15 +1493,15 @@ class CallStackControl { // B_BAD_VALUE: no handler was found // any other value: the error value that was returned by the last handler that failed status_t -PPPInterface::StackControlEachHandler(uint32 op, void *data) +KPPPInterface::StackControlEachHandler(uint32 op, void *data) { #if DEBUG - dprintf("PPPInterface: StackControlEachHandler(0x%lX)\n", op); + dprintf("KPPPInterface: StackControlEachHandler(0x%lX)\n", op); #endif status_t result = B_BAD_VALUE, tmp; - PPPProtocol *protocol = FirstProtocol(); + KPPPProtocol *protocol = FirstProtocol(); for(; protocol; protocol = protocol->NextProtocol()) { tmp = protocol->StackControl(op, data); if(tmp == B_OK && result == B_BAD_VALUE) @@ -1496,26 +1511,26 @@ PPPInterface::StackControlEachHandler(uint32 op, void *data) } ForEachItem(LCP().fLCPExtensions, - CallStackControl(op, data, result)); + CallStackControl(op, data, result)); ForEachItem(LCP().fOptionHandlers, - CallStackControl(op, data, result)); + CallStackControl(op, data, result)); return result; } void -PPPInterface::CalculateInterfaceMTU() +KPPPInterface::CalculateInterfaceMTU() { #if DEBUG - dprintf("PPPInterface: CalculateInterfaceMTU()\n"); + dprintf("KPPPInterface: CalculateInterfaceMTU()\n"); #endif fInterfaceMTU = fMRU; fHeaderLength = 2; // sum all headers (the protocol field is not counted) - PPPProtocol *protocol = FirstProtocol(); + KPPPProtocol *protocol = FirstProtocol(); for(; protocol; protocol = protocol->NextProtocol()) { if(protocol->Level() < PPP_PROTOCOL_LEVEL) fHeaderLength += protocol->Overhead(); @@ -1534,10 +1549,10 @@ PPPInterface::CalculateInterfaceMTU() void -PPPInterface::CalculateBaudRate() +KPPPInterface::CalculateBaudRate() { #if DEBUG - dprintf("PPPInterface: CalculateBaudRate()\n"); + dprintf("KPPPInterface: CalculateBaudRate()\n"); #endif if(!Ifnet()) @@ -1556,10 +1571,10 @@ PPPInterface::CalculateBaudRate() void -PPPInterface::Redial(uint32 delay) +KPPPInterface::Redial(uint32 delay) { #if DEBUG - dprintf("PPPInterface: Redial(%ld)\n", delay); + dprintf("KPPPInterface: Redial(%ld)\n", delay); #endif if(fRedialThread != -1) @@ -1571,7 +1586,7 @@ PPPInterface::Redial(uint32 delay) info.thread = &fRedialThread; info.delay = delay; - fRedialThread = spawn_kernel_thread(redial_thread, "PPPInterface: redial_thread", + fRedialThread = spawn_kernel_thread(redial_thread, "KPPPInterface: redial_thread", B_NORMAL_PRIORITY, NULL); resume_thread(fRedialThread); @@ -1608,13 +1623,13 @@ redial_thread(void *data) // ---------------------------------- // Function: interface_deleter_thread // ---------------------------------- -class PPPInterfaceAccess { +class KPPPInterfaceAccess { public: - PPPInterfaceAccess() {} + KPPPInterfaceAccess() {} - void Delete(PPPInterface *interface) + void Delete(KPPPInterface *interface) { delete interface; } - void CallOpenEvent(PPPInterface *interface) + void CallOpenEvent(KPPPInterface *interface) { while(interface->fLock.LockWithTimeout(100000) != B_NO_ERROR) if(interface->fDeleteCounter > 0) @@ -1623,7 +1638,7 @@ class PPPInterfaceAccess { interface->fOpenEventThread = -1; interface->fLock.Unlock(); } - void CallCloseEvent(PPPInterface *interface) + void CallCloseEvent(KPPPInterface *interface) { while(interface->fLock.LockWithTimeout(100000) != B_NO_ERROR) if(interface->fDeleteCounter > 0) @@ -1638,8 +1653,8 @@ class PPPInterfaceAccess { status_t interface_deleter_thread(void *data) { - PPPInterfaceAccess access; - access.Delete((PPPInterface*) data); + KPPPInterfaceAccess access; + access.Delete((KPPPInterface*) data); return B_OK; } @@ -1648,8 +1663,8 @@ interface_deleter_thread(void *data) status_t call_open_event_thread(void *data) { - PPPInterfaceAccess access; - access.CallOpenEvent((PPPInterface*) data); + KPPPInterfaceAccess access; + access.CallOpenEvent((KPPPInterface*) data); return B_OK; } @@ -1658,8 +1673,8 @@ call_open_event_thread(void *data) status_t call_close_event_thread(void *data) { - PPPInterfaceAccess access; - access.CallCloseEvent((PPPInterface*) data); + KPPPInterfaceAccess access; + access.CallCloseEvent((KPPPInterface*) data); return B_OK; } diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCP.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCP.cpp index 99f6e34bb1..b72a68c7a0 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCP.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCP.cpp @@ -17,8 +17,8 @@ #include -PPPLCP::PPPLCP(PPPInterface& interface) - : PPPProtocol("LCP", PPP_ESTABLISHMENT_PHASE, PPP_LCP_PROTOCOL, PPP_PROTOCOL_LEVEL, +KPPPLCP::KPPPLCP(KPPPInterface& interface) + : KPPPProtocol("LCP", PPP_ESTABLISHMENT_PHASE, PPP_LCP_PROTOCOL, PPP_PROTOCOL_LEVEL, AF_UNSPEC, 0, interface, NULL, PPP_ALWAYS_ALLOWED), fStateMachine(interface.StateMachine()), fTarget(NULL) @@ -28,7 +28,7 @@ PPPLCP::PPPLCP(PPPInterface& interface) } -PPPLCP::~PPPLCP() +KPPPLCP::~KPPPLCP() { while(CountOptionHandlers()) delete OptionHandlerAt(0); @@ -38,7 +38,7 @@ PPPLCP::~PPPLCP() bool -PPPLCP::AddOptionHandler(PPPOptionHandler *optionHandler) +KPPPLCP::AddOptionHandler(KPPPOptionHandler *optionHandler) { if(!optionHandler || &optionHandler->Interface() != &Interface()) return false; @@ -55,7 +55,7 @@ PPPLCP::AddOptionHandler(PPPOptionHandler *optionHandler) bool -PPPLCP::RemoveOptionHandler(PPPOptionHandler *optionHandler) +KPPPLCP::RemoveOptionHandler(KPPPOptionHandler *optionHandler) { LockerHelper locker(StateMachine().fLock); @@ -67,10 +67,10 @@ PPPLCP::RemoveOptionHandler(PPPOptionHandler *optionHandler) } -PPPOptionHandler* -PPPLCP::OptionHandlerAt(int32 index) const +KPPPOptionHandler* +KPPPLCP::OptionHandlerAt(int32 index) const { - PPPOptionHandler *optionHandler = fOptionHandlers.ItemAt(index); + KPPPOptionHandler *optionHandler = fOptionHandlers.ItemAt(index); if(optionHandler == fOptionHandlers.GetDefaultItem()) return NULL; @@ -79,8 +79,8 @@ PPPLCP::OptionHandlerAt(int32 index) const } -PPPOptionHandler* -PPPLCP::OptionHandlerFor(uint8 type, int32 *start = NULL) const +KPPPOptionHandler* +KPPPLCP::OptionHandlerFor(uint8 type, int32 *start = NULL) const { // The iteration style in this method is strange C/C++. // Explanation: I use this style because it makes extending all XXXFor @@ -91,7 +91,7 @@ PPPLCP::OptionHandlerFor(uint8 type, int32 *start = NULL) const if(index < 0) return NULL; - PPPOptionHandler *current = OptionHandlerAt(index); + KPPPOptionHandler *current = OptionHandlerAt(index); for(; current; current = OptionHandlerAt(++index)) { if(current->Type() == type) { @@ -106,7 +106,7 @@ PPPLCP::OptionHandlerFor(uint8 type, int32 *start = NULL) const bool -PPPLCP::AddLCPExtension(PPPLCPExtension *lcpExtension) +KPPPLCP::AddLCPExtension(KPPPLCPExtension *lcpExtension) { if(!lcpExtension || &lcpExtension->Interface() != &Interface()) return false; @@ -122,7 +122,7 @@ PPPLCP::AddLCPExtension(PPPLCPExtension *lcpExtension) bool -PPPLCP::RemoveLCPExtension(PPPLCPExtension *lcpExtension) +KPPPLCP::RemoveLCPExtension(KPPPLCPExtension *lcpExtension) { LockerHelper locker(StateMachine().fLock); @@ -134,10 +134,10 @@ PPPLCP::RemoveLCPExtension(PPPLCPExtension *lcpExtension) } -PPPLCPExtension* -PPPLCP::LCPExtensionAt(int32 index) const +KPPPLCPExtension* +KPPPLCP::LCPExtensionAt(int32 index) const { - PPPLCPExtension *lcpExtension = fLCPExtensions.ItemAt(index); + KPPPLCPExtension *lcpExtension = fLCPExtensions.ItemAt(index); if(lcpExtension == fLCPExtensions.GetDefaultItem()) return NULL; @@ -146,8 +146,8 @@ PPPLCP::LCPExtensionAt(int32 index) const } -PPPLCPExtension* -PPPLCP::LCPExtensionFor(uint8 code, int32 *start = NULL) const +KPPPLCPExtension* +KPPPLCP::LCPExtensionFor(uint8 code, int32 *start = NULL) const { // The iteration style in this method is strange C/C++. // Explanation: I use this style because it makes extending all XXXFor @@ -158,7 +158,7 @@ PPPLCP::LCPExtensionFor(uint8 code, int32 *start = NULL) const if(index < 0) return NULL; - PPPLCPExtension *current = LCPExtensionAt(index); + KPPPLCPExtension *current = LCPExtensionAt(index); for(; current; current = LCPExtensionAt(++index)) { if(current->Code() == code) { @@ -173,7 +173,7 @@ PPPLCP::LCPExtensionFor(uint8 code, int32 *start = NULL) const uint32 -PPPLCP::AdditionalOverhead() const +KPPPLCP::AdditionalOverhead() const { uint32 overhead = Interface().Overhead(); @@ -188,21 +188,21 @@ PPPLCP::AdditionalOverhead() const bool -PPPLCP::Up() +KPPPLCP::Up() { return true; } bool -PPPLCP::Down() +KPPPLCP::Down() { return true; } status_t -PPPLCP::Send(struct mbuf *packet, uint16 protocolNumber = PPP_LCP_PROTOCOL) +KPPPLCP::Send(struct mbuf *packet, uint16 protocolNumber = PPP_LCP_PROTOCOL) { if(Target()) return Target()->Send(packet, PPP_LCP_PROTOCOL); @@ -212,13 +212,13 @@ PPPLCP::Send(struct mbuf *packet, uint16 protocolNumber = PPP_LCP_PROTOCOL) status_t -PPPLCP::Receive(struct mbuf *packet, uint16 protocolNumber) +KPPPLCP::Receive(struct mbuf *packet, uint16 protocolNumber) { if(!packet) return B_ERROR; if(protocolNumber != PPP_LCP_PROTOCOL) { - dprintf("PPPLCP::Receive(): wrong protocol number!\n"); + dprintf("KPPPLCP::Receive(): wrong protocol number!\n"); return PPP_UNHANDLED; } @@ -295,7 +295,7 @@ PPPLCP::Receive(struct mbuf *packet, uint16 protocolNumber) // Try to find LCP extensions that can handle this code. // We must duplicate the packet in order to ask all handlers. int32 index = 0; - PPPLCPExtension *lcpExtension = LCPExtensionFor(data->code, &index); + KPPPLCPExtension *lcpExtension = LCPExtensionFor(data->code, &index); for(; lcpExtension; lcpExtension = LCPExtensionFor(data->code, &(++index))) { if(!lcpExtension->IsEnabled()) continue; @@ -323,7 +323,7 @@ PPPLCP::Receive(struct mbuf *packet, uint16 protocolNumber) void -PPPLCP::Pulse() +KPPPLCP::Pulse() { StateMachine().TimerEvent(); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp index df51af1939..b5a58cc53b 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp @@ -10,7 +10,7 @@ #include -PPPLCPExtension::PPPLCPExtension(const char *name, uint8 code, PPPInterface& interface, +KPPPLCPExtension::KPPPLCPExtension(const char *name, uint8 code, KPPPInterface& interface, driver_parameter *settings) : fInterface(interface), fSettings(settings), @@ -24,7 +24,7 @@ PPPLCPExtension::PPPLCPExtension(const char *name, uint8 code, PPPInterface& int } -PPPLCPExtension::~PPPLCPExtension() +KPPPLCPExtension::~KPPPLCPExtension() { free(fName); @@ -33,14 +33,14 @@ PPPLCPExtension::~PPPLCPExtension() status_t -PPPLCPExtension::InitCheck() const +KPPPLCPExtension::InitCheck() const { return fInitStatus; } status_t -PPPLCPExtension::Control(uint32 op, void *data, size_t length) +KPPPLCPExtension::Control(uint32 op, void *data, size_t length) { switch(op) { case PPPC_GET_SIMPLE_HANDLER_INFO: { @@ -50,7 +50,6 @@ PPPLCPExtension::Control(uint32 op, void *data, size_t length) ppp_simple_handler_info *info = (ppp_simple_handler_info*) data; memset(info, 0, sizeof(ppp_simple_handler_info_t)); strncpy(info->name, Name(), PPP_HANDLER_NAME_LENGTH_LIMIT); - info->settings = Settings(); info->isEnabled = IsEnabled(); } break; @@ -70,7 +69,7 @@ PPPLCPExtension::Control(uint32 op, void *data, size_t length) status_t -PPPLCPExtension::StackControl(uint32 op, void *data) +KPPPLCPExtension::StackControl(uint32 op, void *data) { switch(op) { default: @@ -82,14 +81,14 @@ PPPLCPExtension::StackControl(uint32 op, void *data) void -PPPLCPExtension::Reset() +KPPPLCPExtension::Reset() { // do nothing by default } void -PPPLCPExtension::Pulse() +KPPPLCPExtension::Pulse() { // do nothing by default } diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLayer.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLayer.cpp index 3cbda2cf3e..0f3cd212a4 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLayer.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLayer.cpp @@ -16,34 +16,31 @@ #include -PPPLayer::PPPLayer(const char *name, ppp_level level, uint32 overhead) +KPPPLayer::KPPPLayer(const char *name, ppp_level level, uint32 overhead) : fInitStatus(B_OK), fOverhead(overhead), fLevel(level), fNext(NULL) { - if(name) - fName = strdup(name); - else - fName = strdup("Unknown"); + SetName(name); } -PPPLayer::~PPPLayer() +KPPPLayer::~KPPPLayer() { free(fName); } status_t -PPPLayer::InitCheck() const +KPPPLayer::InitCheck() const { return fInitStatus; } status_t -PPPLayer::SendToNext(struct mbuf *packet, uint16 protocolNumber) const +KPPPLayer::SendToNext(struct mbuf *packet, uint16 protocolNumber) const { if(!packet) return B_ERROR; @@ -56,7 +53,7 @@ PPPLayer::SendToNext(struct mbuf *packet, uint16 protocolNumber) const else return Next()->SendToNext(packet, protocolNumber); } else { - dprintf("PPPLayer: SendToNext() failed because there is no next handler!\n"); + dprintf("KPPPLayer: SendToNext() failed because there is no next handler!\n"); m_freem(packet); return B_ERROR; } @@ -64,7 +61,19 @@ PPPLayer::SendToNext(struct mbuf *packet, uint16 protocolNumber) const void -PPPLayer::Pulse() +KPPPLayer::Pulse() { // do nothing by default } + + +void +KPPPLayer::SetName(const char *name) +{ + free(fName); + + if(name) + fName = strdup(name); + else + fName = strdup("Unknown"); +} diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPOptionHandler.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPOptionHandler.cpp index 63ca4b7743..2cce49d1b5 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPOptionHandler.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPOptionHandler.cpp @@ -10,8 +10,8 @@ #include -PPPOptionHandler::PPPOptionHandler(const char *name, uint8 type, - PPPInterface& interface, driver_parameter *settings) +KPPPOptionHandler::KPPPOptionHandler(const char *name, uint8 type, + KPPPInterface& interface, driver_parameter *settings) : fInitStatus(B_OK), fType(type), fInterface(interface), @@ -25,7 +25,7 @@ PPPOptionHandler::PPPOptionHandler(const char *name, uint8 type, } -PPPOptionHandler::~PPPOptionHandler() +KPPPOptionHandler::~KPPPOptionHandler() { free(fName); @@ -34,14 +34,14 @@ PPPOptionHandler::~PPPOptionHandler() status_t -PPPOptionHandler::InitCheck() const +KPPPOptionHandler::InitCheck() const { return fInitStatus; } status_t -PPPOptionHandler::Control(uint32 op, void *data, size_t length) +KPPPOptionHandler::Control(uint32 op, void *data, size_t length) { switch(op) { case PPPC_GET_SIMPLE_HANDLER_INFO: { @@ -51,7 +51,6 @@ PPPOptionHandler::Control(uint32 op, void *data, size_t length) ppp_simple_handler_info *info = (ppp_simple_handler_info*) data; memset(info, 0, sizeof(ppp_simple_handler_info_t)); strncpy(info->name, Name(), PPP_HANDLER_NAME_LENGTH_LIMIT); - info->settings = Settings(); info->isEnabled = IsEnabled(); } break; @@ -71,7 +70,7 @@ PPPOptionHandler::Control(uint32 op, void *data, size_t length) status_t -PPPOptionHandler::StackControl(uint32 op, void *data) +KPPPOptionHandler::StackControl(uint32 op, void *data) { switch(op) { default: diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProfile.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProfile.cpp new file mode 100644 index 0000000000..cd3d0b6581 --- /dev/null +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProfile.cpp @@ -0,0 +1,134 @@ +//----------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +// +// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de +//----------------------------------------------------------------------- + +/*! \class KPPPProfile + \brief Manages profiles for KPPPInterface. + + PPP modules should store their user-specific and private settings in profiles. + This allows one interface description to be used by multiple users although + they have different logins. Temporary profiles are used when you enter a password + in the connection prompt. + PPP servers may use \c Request() to communicate with the userland PPP add-ons. + These add-ons could, for instance, forward all requests to a central server or + database. +*/ + +#include + +#include +#include "settings_tools.h" + + +//! Initializes profile. +KPPPProfile::KPPPProfile(KPPPInterface& interface) + : fInterface(interface), + fSettings(NULL) +{ +} + + +//! Frees profile settings. +KPPPProfile::~KPPPProfile() +{ + if(fSettings != Interface().Settings()) + free_driver_settings(fSettings); +} + + +/*! \brief Loads profile settings. + + Search order for profiles: + - given profile + - profile mentioned in interface settings ("profile $type { name $name }") + - profile description file with name of this interface + - the interface's settings (to stay compatible with the simple in-settings + description format) + + \param profile The dynamically created profile for this interface (if defined). + \param interfaceSettings The interface's settings. +*/ +void +KPPPProfile::LoadSettings(const driver_settings *profile, + driver_settings *interfaceSettings) +{ + // ----------------------------- + // given profile + // ----------------------------- + if(profile) { + fSettings = dup_driver_settings(profile); + return; + } + + // ----------------------------- + // profile in settings and + // profile with interface's name + // TODO: try /etc/ppp/profile if local profile could not be found + // ----------------------------- + const char *name = NULL; + char path[B_PATH_NAME_LENGTH]; + const driver_parameter *parameter = get_parameter_with_name("profile", + interfaceSettings); + + // TODO: add support for "ppp_server" profile type + if(parameter && parameter->value_count > 0 && parameter->parameter_count > 0 + && !strcasecmp(parameter->values[0], "file")) + name = get_parameter_value("name", parameter); + else if(Interface().Name()) + name = Interface().Name(); + + if(name) { + sprintf(path, "pppidf/profile/%s", name); + void *handle = load_driver_settings(path); + fSettings = dup_driver_settings(get_driver_settings(handle)); + + if(handle) + unload_driver_settings(handle); + + if(fSettings) + return; + } + + // ----------------------------- + // interface's settings + // ----------------------------- + fSettings = interfaceSettings; +} + + +/*! \brief Finds a parameter with name \a type that has a value of \a name. + + This method is intended for modules. + + \param type Module's type (e.g.: "authenticator"). + \param name Module's name (e.g.: "pap"). + + \return + \c NULL: No parameter was found. +*/ +const driver_parameter* +KPPPProfile::SettingsFor(const char *type, const char *name) const +{ + if(!Settings() || !type) + return NULL; + + const driver_parameter *parameter; + for(int32 index = 0; index < Settings()->parameter_count; index++) { + parameter = &Settings()->parameters[index]; + + if(!strcasecmp(parameter->name, type)) { + if(name) { + for(int32 valueIndex = 0; valueIndex < parameter->value_count; + valueIndex++) + if(!strcasecmp(parameter->values[index], name)) + return parameter; + } else + return parameter; + } + } + + return NULL; +} diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProtocol.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProtocol.cpp index 5bddb64c7e..0e8b9315fc 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProtocol.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProtocol.cpp @@ -13,12 +13,12 @@ #include -PPPProtocol::PPPProtocol(const char *name, ppp_phase activationPhase, +KPPPProtocol::KPPPProtocol(const char *name, ppp_phase activationPhase, uint16 protocolNumber, ppp_level level, int32 addressFamily, - uint32 overhead, PPPInterface& interface, + uint32 overhead, KPPPInterface& interface, driver_parameter *settings, int32 flags = PPP_NO_FLAGS, - const char *type = NULL, PPPOptionHandler *optionHandler = NULL) - : PPPLayer(name, level, overhead), + const char *type = NULL, KPPPOptionHandler *optionHandler = NULL) + : KPPPLayer(name, level, overhead), fActivationPhase(activationPhase), fProtocolNumber(protocolNumber), fAddressFamily(addressFamily), @@ -48,7 +48,7 @@ PPPProtocol::PPPProtocol(const char *name, ppp_phase activationPhase, } -PPPProtocol::~PPPProtocol() +KPPPProtocol::~KPPPProtocol() { Interface().RemoveProtocol(this); @@ -57,7 +57,7 @@ PPPProtocol::~PPPProtocol() status_t -PPPProtocol::Control(uint32 op, void *data, size_t length) +KPPPProtocol::Control(uint32 op, void *data, size_t length) { switch(op) { case PPPC_GET_PROTOCOL_INFO: { @@ -68,7 +68,6 @@ PPPProtocol::Control(uint32 op, void *data, size_t length) memset(info, 0, sizeof(ppp_protocol_info_t)); strncpy(info->name, Name(), PPP_HANDLER_NAME_LENGTH_LIMIT); strncpy(info->type, Type(), PPP_HANDLER_NAME_LENGTH_LIMIT); - info->settings = Settings(); info->activationPhase = ActivationPhase(); info->addressFamily = AddressFamily(); info->flags = Flags(); @@ -97,7 +96,7 @@ PPPProtocol::Control(uint32 op, void *data, size_t length) status_t -PPPProtocol::StackControl(uint32 op, void *data) +KPPPProtocol::StackControl(uint32 op, void *data) { switch(op) { default: @@ -109,7 +108,7 @@ PPPProtocol::StackControl(uint32 op, void *data) void -PPPProtocol::SetEnabled(bool enabled = true) +KPPPProtocol::SetEnabled(bool enabled = true) { fEnabled = enabled; @@ -122,28 +121,28 @@ PPPProtocol::SetEnabled(bool enabled = true) bool -PPPProtocol::IsAllowedToSend() const +KPPPProtocol::IsAllowedToSend() const { return IsEnabled() && IsUp() && IsProtocolAllowed(*this); } void -PPPProtocol::UpStarted() +KPPPProtocol::UpStarted() { fConnectionPhase = PPP_ESTABLISHMENT_PHASE; } void -PPPProtocol::DownStarted() +KPPPProtocol::DownStarted() { fConnectionPhase = PPP_TERMINATION_PHASE; } void -PPPProtocol::UpFailedEvent() +KPPPProtocol::UpFailedEvent() { fConnectionPhase = PPP_DOWN_PHASE; @@ -152,7 +151,7 @@ PPPProtocol::UpFailedEvent() void -PPPProtocol::UpEvent() +KPPPProtocol::UpEvent() { fConnectionPhase = PPP_ESTABLISHED_PHASE; @@ -161,7 +160,7 @@ PPPProtocol::UpEvent() void -PPPProtocol::DownEvent() +KPPPProtocol::DownEvent() { fConnectionPhase = PPP_DOWN_PHASE; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPReportManager.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPReportManager.cpp index 1209f9c5ca..5a007b86cf 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPReportManager.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPReportManager.cpp @@ -11,13 +11,13 @@ #include -PPPReportManager::PPPReportManager(BLocker& lock) +KPPPReportManager::KPPPReportManager(BLocker& lock) : fLock(lock) { } -PPPReportManager::~PPPReportManager() +KPPPReportManager::~KPPPReportManager() { for(int32 index = 0; index < fReportRequests.CountItems(); index++) delete fReportRequests.ItemAt(index); @@ -25,7 +25,7 @@ PPPReportManager::~PPPReportManager() void -PPPReportManager::EnableReports(ppp_report_type type, thread_id thread, +KPPPReportManager::EnableReports(ppp_report_type type, thread_id thread, int32 flags = PPP_NO_FLAGS) { LockerHelper locker(fLock); @@ -40,7 +40,7 @@ PPPReportManager::EnableReports(ppp_report_type type, thread_id thread, void -PPPReportManager::DisableReports(ppp_report_type type, thread_id thread) +KPPPReportManager::DisableReports(ppp_report_type type, thread_id thread) { LockerHelper locker(fLock); @@ -59,7 +59,7 @@ PPPReportManager::DisableReports(ppp_report_type type, thread_id thread) bool -PPPReportManager::DoesReport(ppp_report_type type, thread_id thread) +KPPPReportManager::DoesReport(ppp_report_type type, thread_id thread) { LockerHelper locker(fLock); @@ -77,10 +77,10 @@ PPPReportManager::DoesReport(ppp_report_type type, thread_id thread) bool -PPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 length) +KPPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 length) { #if DEBUG - dprintf("PPPReportManager: Report(type=%d code=%ld length=%ld) to %ld receivers\n", + dprintf("KPPPReportManager: Report(type=%d code=%ld length=%ld) to %ld receivers\n", type, code, length, fReportRequests.CountItems()); #endif @@ -119,7 +119,7 @@ PPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 len #if DEBUG if(result == B_TIMED_OUT) - dprintf("PPPReportManager::Report(): timed out sending\n"); + dprintf("KPPPReportManager::Report(): timed out sending\n"); #endif if(result == B_BAD_THREAD_ID || result == B_NO_MEMORY) { @@ -159,7 +159,7 @@ PPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 len acceptable = false; #if DEBUG if(result == B_TIMED_OUT) - dprintf("PPPReportManager::Report(): reply timed out\n"); + dprintf("KPPPReportManager::Report(): reply timed out\n"); #endif } } @@ -171,7 +171,7 @@ PPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 len } #if DEBUG - dprintf("PPPReportManager::Report(): returning: %s\n", acceptable?"true":"false"); + dprintf("KPPPReportManager::Report(): returning: %s\n", acceptable?"true":"false"); #endif return acceptable; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp index 98b6b2a422..6f31c8daf1 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp @@ -13,6 +13,8 @@ #include #include +#include + #include #include @@ -21,7 +23,7 @@ // 3 seconds -PPPStateMachine::PPPStateMachine(PPPInterface& interface) +KPPPStateMachine::KPPPStateMachine(KPPPInterface& interface) : fInterface(interface), fLCP(interface.LCP()), fState(PPP_INITIAL_STATE), @@ -43,7 +45,7 @@ PPPStateMachine::PPPStateMachine(PPPInterface& interface) } -PPPStateMachine::~PPPStateMachine() +KPPPStateMachine::~KPPPStateMachine() { free(fLocalAuthenticationName); free(fPeerAuthenticationName); @@ -51,7 +53,7 @@ PPPStateMachine::~PPPStateMachine() uint8 -PPPStateMachine::NextID() +KPPPStateMachine::NextID() { return (uint8) atomic_add(&fID, 1); } @@ -60,10 +62,10 @@ PPPStateMachine::NextID() // remember: NewState() must always be called _after_ IllegalEvent() // because IllegalEvent() also looks at the current state. void -PPPStateMachine::NewState(ppp_state next) +KPPPStateMachine::NewState(ppp_state next) { #if DEBUG - dprintf("PPPSM: NewState(%d) state=%d\n", next, State()); + dprintf("KPPPSM: NewState(%d) state=%d\n", next, State()); #endif // maybe we do not need the timer anymore @@ -78,11 +80,11 @@ PPPStateMachine::NewState(ppp_state next) void -PPPStateMachine::NewPhase(ppp_phase next) +KPPPStateMachine::NewPhase(ppp_phase next) { #if DEBUG if(next <= PPP_ESTABLISHMENT_PHASE || next == PPP_ESTABLISHED_PHASE) - dprintf("PPPSM: NewPhase(%d) phase=%d\n", next, Phase()); + dprintf("KPPPSM: NewPhase(%d) phase=%d\n", next, Phase()); #endif // there is nothing after established phase and nothing before down phase @@ -119,10 +121,10 @@ PPPStateMachine::NewPhase(ppp_phase next) // public actions bool -PPPStateMachine::Reconfigure() +KPPPStateMachine::Reconfigure() { #if DEBUG - dprintf("PPPSM: Reconfigure() state=%d phase=%d\n", + dprintf("KPPPSM: Reconfigure() state=%d phase=%d\n", State(), Phase()); #endif @@ -145,10 +147,10 @@ PPPStateMachine::Reconfigure() bool -PPPStateMachine::SendEchoRequest() +KPPPStateMachine::SendEchoRequest() { #if DEBUG - dprintf("PPPSM: SendEchoRequest() state=%d phase=%d\n", + dprintf("KPPPSM: SendEchoRequest() state=%d phase=%d\n", State(), Phase()); #endif @@ -175,10 +177,10 @@ PPPStateMachine::SendEchoRequest() bool -PPPStateMachine::SendDiscardRequest() +KPPPStateMachine::SendDiscardRequest() { #if DEBUG - dprintf("PPPSM: SendDiscardRequest() state=%d phase=%d\n", + dprintf("KPPPSM: SendDiscardRequest() state=%d phase=%d\n", State(), Phase()); #endif @@ -205,10 +207,10 @@ PPPStateMachine::SendDiscardRequest() // authentication events void -PPPStateMachine::LocalAuthenticationRequested() +KPPPStateMachine::LocalAuthenticationRequested() { #if DEBUG - dprintf("PPPSM: LocalAuthenticationRequested() state=%d phase=%d\n", + dprintf("KPPPSM: LocalAuthenticationRequested() state=%d phase=%d\n", State(), Phase()); #endif @@ -221,10 +223,10 @@ PPPStateMachine::LocalAuthenticationRequested() void -PPPStateMachine::LocalAuthenticationAccepted(const char *name) +KPPPStateMachine::LocalAuthenticationAccepted(const char *name) { #if DEBUG - dprintf("PPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n", + dprintf("KPPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n", State(), Phase()); #endif @@ -244,10 +246,10 @@ PPPStateMachine::LocalAuthenticationAccepted(const char *name) void -PPPStateMachine::LocalAuthenticationDenied(const char *name) +KPPPStateMachine::LocalAuthenticationDenied(const char *name) { #if DEBUG - dprintf("PPPSM: LocalAuthenticationDenied() state=%d phase=%d\n", + dprintf("KPPPSM: LocalAuthenticationDenied() state=%d phase=%d\n", State(), Phase()); #endif @@ -263,10 +265,10 @@ PPPStateMachine::LocalAuthenticationDenied(const char *name) void -PPPStateMachine::PeerAuthenticationRequested() +KPPPStateMachine::PeerAuthenticationRequested() { #if DEBUG - dprintf("PPPSM: PeerAuthenticationRequested() state=%d phase=%d\n", + dprintf("KPPPSM: PeerAuthenticationRequested() state=%d phase=%d\n", State(), Phase()); #endif @@ -279,10 +281,10 @@ PPPStateMachine::PeerAuthenticationRequested() void -PPPStateMachine::PeerAuthenticationAccepted(const char *name) +KPPPStateMachine::PeerAuthenticationAccepted(const char *name) { #if DEBUG - dprintf("PPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n", + dprintf("KPPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n", State(), Phase()); #endif @@ -302,10 +304,10 @@ PPPStateMachine::PeerAuthenticationAccepted(const char *name) void -PPPStateMachine::PeerAuthenticationDenied(const char *name) +KPPPStateMachine::PeerAuthenticationDenied(const char *name) { #if DEBUG - dprintf("PPPSM: PeerAuthenticationDenied() state=%d phase=%d\n", + dprintf("KPPPSM: PeerAuthenticationDenied() state=%d phase=%d\n", State(), Phase()); #endif @@ -323,10 +325,10 @@ PPPStateMachine::PeerAuthenticationDenied(const char *name) void -PPPStateMachine::UpFailedEvent(PPPInterface& interface) +KPPPStateMachine::UpFailedEvent(KPPPInterface& interface) { #if DEBUG - dprintf("PPPSM: UpFailedEvent(interface) state=%d phase=%d\n", + dprintf("KPPPSM: UpFailedEvent(interface) state=%d phase=%d\n", State(), Phase()); #endif @@ -336,10 +338,10 @@ PPPStateMachine::UpFailedEvent(PPPInterface& interface) void -PPPStateMachine::UpEvent(PPPInterface& interface) +KPPPStateMachine::UpEvent(KPPPInterface& interface) { #if DEBUG - dprintf("PPPSM: UpEvent(interface) state=%d phase=%d\n", + dprintf("KPPPSM: UpEvent(interface) state=%d phase=%d\n", State(), Phase()); #endif @@ -366,10 +368,10 @@ PPPStateMachine::UpEvent(PPPInterface& interface) void -PPPStateMachine::DownEvent(PPPInterface& interface) +KPPPStateMachine::DownEvent(KPPPInterface& interface) { #if DEBUG - dprintf("PPPSM: DownEvent(interface) state=%d phase=%d\n", + dprintf("KPPPSM: DownEvent(interface) state=%d phase=%d\n", State(), Phase()); #endif @@ -383,7 +385,7 @@ PPPStateMachine::DownEvent(PPPInterface& interface) // when all children are down we should not be running if(Interface().IsMultilink() && !Interface().Parent()) { uint32 count = 0; - PPPInterface *child; + KPPPInterface *child; for(int32 index = 0; index < Interface().CountChildren(); index++) { child = Interface().ChildAt(index); @@ -412,10 +414,10 @@ PPPStateMachine::DownEvent(PPPInterface& interface) void -PPPStateMachine::UpFailedEvent(PPPProtocol *protocol) +KPPPStateMachine::UpFailedEvent(KPPPProtocol *protocol) { #if DEBUG - dprintf("PPPSM: UpFailedEvent(protocol) state=%d phase=%d\n", + dprintf("KPPPSM: UpFailedEvent(protocol) state=%d phase=%d\n", State(), Phase()); #endif @@ -437,10 +439,10 @@ PPPStateMachine::UpFailedEvent(PPPProtocol *protocol) void -PPPStateMachine::UpEvent(PPPProtocol *protocol) +KPPPStateMachine::UpEvent(KPPPProtocol *protocol) { #if DEBUG - dprintf("PPPSM: UpEvent(protocol) state=%d phase=%d\n", + dprintf("KPPPSM: UpEvent(protocol) state=%d phase=%d\n", State(), Phase()); #endif @@ -452,10 +454,10 @@ PPPStateMachine::UpEvent(PPPProtocol *protocol) void -PPPStateMachine::DownEvent(PPPProtocol *protocol) +KPPPStateMachine::DownEvent(KPPPProtocol *protocol) { #if DEBUG - dprintf("PPPSM: DownEvent(protocol) state=%d phase=%d\n", + dprintf("KPPPSM: DownEvent(protocol) state=%d phase=%d\n", State(), Phase()); #endif } @@ -467,10 +469,10 @@ PPPStateMachine::DownEvent(PPPProtocol *protocol) // The return value says if we are waiting for an UpEvent(). If false is // returned the device should immediately abort its attempt to connect. bool -PPPStateMachine::TLSNotify() +KPPPStateMachine::TLSNotify() { #if DEBUG - dprintf("PPPSM: TLSNotify() state=%d phase=%d\n", + dprintf("KPPPSM: TLSNotify() state=%d phase=%d\n", State(), Phase()); #endif @@ -492,10 +494,10 @@ PPPStateMachine::TLSNotify() // If false is returned we want to stay connected, though we called // Device::Down(). bool -PPPStateMachine::TLFNotify() +KPPPStateMachine::TLFNotify() { #if DEBUG - dprintf("PPPSM: TLFNotify() state=%d phase=%d\n", + dprintf("KPPPSM: TLFNotify() state=%d phase=%d\n", State(), Phase()); #endif @@ -509,10 +511,10 @@ PPPStateMachine::TLFNotify() void -PPPStateMachine::UpFailedEvent() +KPPPStateMachine::UpFailedEvent() { #if DEBUG - dprintf("PPPSM: UpFailedEvent() state=%d phase=%d\n", + dprintf("KPPPSM: UpFailedEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -537,10 +539,10 @@ PPPStateMachine::UpFailedEvent() void -PPPStateMachine::UpEvent() +KPPPStateMachine::UpEvent() { #if DEBUG - dprintf("PPPSM: UpEvent() state=%d phase=%d\n", + dprintf("KPPPSM: UpEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -602,10 +604,10 @@ PPPStateMachine::UpEvent() void -PPPStateMachine::DownEvent() +KPPPStateMachine::DownEvent() { #if DEBUG - dprintf("PPPSM: DownEvent() state=%d phase=%d\n", + dprintf("KPPPSM: DownEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -706,10 +708,10 @@ PPPStateMachine::DownEvent() // private events void -PPPStateMachine::OpenEvent() +KPPPStateMachine::OpenEvent() { #if DEBUG - dprintf("PPPSM: OpenEvent() state=%d phase=%d\n", + dprintf("KPPPSM: OpenEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -772,10 +774,10 @@ PPPStateMachine::OpenEvent() void -PPPStateMachine::CloseEvent() +KPPPStateMachine::CloseEvent() { #if DEBUG - dprintf("PPPSM: CloseEvent() state=%d phase=%d\n", + dprintf("KPPPSM: CloseEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -841,10 +843,10 @@ PPPStateMachine::CloseEvent() // timeout (restart counters are > 0) void -PPPStateMachine::TOGoodEvent() +KPPPStateMachine::TOGoodEvent() { #if DEBUG - dprintf("PPPSM: TOGoodEvent() state=%d phase=%d\n", + dprintf("KPPPSM: TOGoodEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -874,10 +876,10 @@ PPPStateMachine::TOGoodEvent() // timeout (restart counters are <= 0) void -PPPStateMachine::TOBadEvent() +KPPPStateMachine::TOBadEvent() { #if DEBUG - dprintf("PPPSM: TOBadEvent() state=%d phase=%d\n", + dprintf("KPPPSM: TOBadEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -909,10 +911,10 @@ PPPStateMachine::TOBadEvent() // receive configure request (acceptable request) void -PPPStateMachine::RCRGoodEvent(struct mbuf *packet) +KPPPStateMachine::RCRGoodEvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RCRGoodEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RCRGoodEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -970,10 +972,10 @@ PPPStateMachine::RCRGoodEvent(struct mbuf *packet) // receive configure request (unacceptable request) void -PPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject) +KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject) { #if DEBUG - dprintf("PPPSM: RCRBadEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RCRBadEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1031,10 +1033,10 @@ PPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject) // receive configure ack void -PPPStateMachine::RCAEvent(struct mbuf *packet) +KPPPStateMachine::RCAEvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RCAEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RCAEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1050,8 +1052,8 @@ PPPStateMachine::RCAEvent(struct mbuf *packet) } // let the option handlers parse this ack - PPPConfigurePacket ack(packet); - PPPOptionHandler *optionHandler; + KPPPConfigurePacket ack(packet); + KPPPOptionHandler *optionHandler; for(int32 index = 0; index < LCP().CountOptionHandlers(); index++) { optionHandler = LCP().OptionHandlerAt(index); if(optionHandler->ParseAck(ack) != B_OK) { @@ -1111,10 +1113,10 @@ PPPStateMachine::RCAEvent(struct mbuf *packet) // receive configure nak/reject void -PPPStateMachine::RCNEvent(struct mbuf *packet) +KPPPStateMachine::RCNEvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RCNEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RCNEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1130,8 +1132,8 @@ PPPStateMachine::RCNEvent(struct mbuf *packet) } // let the option handlers parse this nak/reject - PPPConfigurePacket nak_reject(packet); - PPPOptionHandler *optionHandler; + KPPPConfigurePacket nak_reject(packet); + KPPPOptionHandler *optionHandler; for(int32 index = 0; index < LCP().CountOptionHandlers(); index++) { optionHandler = LCP().OptionHandlerAt(index); @@ -1194,10 +1196,10 @@ PPPStateMachine::RCNEvent(struct mbuf *packet) // receive terminate request void -PPPStateMachine::RTREvent(struct mbuf *packet) +KPPPStateMachine::RTREvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RTREvent() state=%d phase=%d\n", + dprintf("KPPPSM: RTREvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1247,10 +1249,10 @@ PPPStateMachine::RTREvent(struct mbuf *packet) // receive terminate ack void -PPPStateMachine::RTAEvent(struct mbuf *packet) +KPPPStateMachine::RTAEvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RTAEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RTAEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1306,11 +1308,11 @@ PPPStateMachine::RTAEvent(struct mbuf *packet) // receive unknown code void -PPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber, +KPPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber, uint8 code = PPP_PROTOCOL_REJECT) { #if DEBUG - dprintf("PPPSM: RUCEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RUCEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1332,10 +1334,10 @@ PPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber, // receive code/protocol reject (acceptable such as IPX reject) void -PPPStateMachine::RXJGoodEvent(struct mbuf *packet) +KPPPStateMachine::RXJGoodEvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RXJGoodEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RXJGoodEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1361,10 +1363,10 @@ PPPStateMachine::RXJGoodEvent(struct mbuf *packet) // receive code/protocol reject (catastrophic such as LCP reject) void -PPPStateMachine::RXJBadEvent(struct mbuf *packet) +KPPPStateMachine::RXJBadEvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RXJBadEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RXJBadEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1414,10 +1416,10 @@ PPPStateMachine::RXJBadEvent(struct mbuf *packet) // receive echo request/reply, discard request void -PPPStateMachine::RXREvent(struct mbuf *packet) +KPPPStateMachine::RXREvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RXREvent() state=%d phase=%d\n", + dprintf("KPPPSM: RXREvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1450,11 +1452,11 @@ PPPStateMachine::RXREvent(struct mbuf *packet) // general events (for Good/Bad events) void -PPPStateMachine::TimerEvent() +KPPPStateMachine::TimerEvent() { #if DEBUG if(fNextTimeout != 0) - dprintf("PPPSM: TimerEvent()\n"); + dprintf("KPPPSM: TimerEvent()\n"); #endif LockerHelper locker(fLock); @@ -1491,16 +1493,16 @@ PPPStateMachine::TimerEvent() // Here we get a configure-request packet from LCP and aks all OptionHandlers // if its values are acceptable. From here we call our Good/Bad counterparts. void -PPPStateMachine::RCREvent(struct mbuf *packet) +KPPPStateMachine::RCREvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RCREvent() state=%d phase=%d\n", + dprintf("KPPPSM: RCREvent() state=%d phase=%d\n", State(), Phase()); #endif - PPPConfigurePacket request(packet); - PPPConfigurePacket nak(PPP_CONFIGURE_NAK); - PPPConfigurePacket reject(PPP_CONFIGURE_REJECT); + KPPPConfigurePacket request(packet); + KPPPConfigurePacket nak(PPP_CONFIGURE_NAK); + KPPPConfigurePacket reject(PPP_CONFIGURE_REJECT); // we should not use the same id as the peer if(fID == mtod(packet, ppp_lcp_packet*)->id) @@ -1512,19 +1514,19 @@ PPPStateMachine::RCREvent(struct mbuf *packet) // each handler should add unacceptable values for each item status_t result; // the return value of ParseRequest() - PPPOptionHandler *optionHandler; + KPPPOptionHandler *optionHandler; for(int32 index = 0; index < request.CountItems(); index++) { optionHandler = LCP().OptionHandlerFor(request.ItemAt(index)->type); if(!optionHandler || !optionHandler->IsEnabled()) { - dprintf("PPPSM::RCREvent(): unknown type:%d\n", request.ItemAt(index)->type); + dprintf("KPPPSM::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 - dprintf("PPPSM::RCREvent(): OH=%s\n", optionHandler->Name()); + dprintf("KPPPSM::RCREvent(): OH=%s\n", optionHandler->Name()); #endif result = optionHandler->ParseRequest(request, index, nak, reject); @@ -1535,7 +1537,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 - dprintf("PPPSM::RCREvent(): OptionHandler returned parse error!\n"); + dprintf("KPPPSM::RCREvent(): OptionHandler returned parse error!\n"); m_freem(packet); CloseEvent(); return; @@ -1554,7 +1556,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 - dprintf("PPPSM::RCREvent(): OptionHandler returned append error!\n"); + dprintf("KPPPSM::RCREvent(): OptionHandler returned append error!\n"); m_freem(packet); CloseEvent(); return; @@ -1578,10 +1580,10 @@ PPPStateMachine::RCREvent(struct mbuf *packet) // LCP received a code/protocol-reject packet and we look if it is acceptable. // From here we call our Good/Bad counterparts. void -PPPStateMachine::RXJEvent(struct mbuf *packet) +KPPPStateMachine::RXJEvent(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: RXJEvent() state=%d phase=%d\n", + dprintf("KPPPSM: RXJEvent() state=%d phase=%d\n", State(), Phase()); #endif @@ -1604,7 +1606,7 @@ PPPStateMachine::RXJEvent(struct mbuf *packet) } // find the LCP extension and disable it - PPPLCPExtension *lcpExtension; + KPPPLCPExtension *lcpExtension; for(int32 index = 0; index < LCP().CountLCPExtensions(); index++) { lcpExtension = LCP().LCPExtensionAt(index); @@ -1625,7 +1627,7 @@ PPPStateMachine::RXJEvent(struct mbuf *packet) } // disable protocols with the rejected protocol number - PPPProtocol *protocol = Interface().FirstProtocol(); + KPPPProtocol *protocol = Interface().FirstProtocol(); for(; protocol; protocol = protocol->NextProtocol()) { if(protocol->ProtocolNumber() == rejected) protocol->SetEnabled(false); @@ -1646,20 +1648,20 @@ PPPStateMachine::RXJEvent(struct mbuf *packet) // actions (all private) void -PPPStateMachine::IllegalEvent(ppp_event event) +KPPPStateMachine::IllegalEvent(ppp_event event) { // TODO: // update error statistics - dprintf("PPPSM: IllegalEvent(event=%d) state=%d phase=%d\n", + dprintf("KPPPSM: IllegalEvent(event=%d) state=%d phase=%d\n", event, State(), Phase()); } void -PPPStateMachine::ThisLayerUp() +KPPPStateMachine::ThisLayerUp() { #if DEBUG - dprintf("PPPSM: ThisLayerUp() state=%d phase=%d\n", + dprintf("KPPPSM: ThisLayerUp() state=%d phase=%d\n", State(), Phase()); #endif @@ -1681,23 +1683,23 @@ PPPStateMachine::ThisLayerUp() void -PPPStateMachine::ThisLayerDown() +KPPPStateMachine::ThisLayerDown() { #if DEBUG - dprintf("PPPSM: ThisLayerDown() state=%d phase=%d\n", + dprintf("KPPPSM: ThisLayerDown() state=%d phase=%d\n", State(), Phase()); #endif - // PPPProtocol::Down() should block if needed. + // KPPPProtocol::Down() should block if needed. DownProtocols(); } void -PPPStateMachine::ThisLayerStarted() +KPPPStateMachine::ThisLayerStarted() { #if DEBUG - dprintf("PPPSM: ThisLayerStarted() state=%d phase=%d\n", + dprintf("KPPPSM: ThisLayerStarted() state=%d phase=%d\n", State(), Phase()); #endif @@ -1707,10 +1709,10 @@ PPPStateMachine::ThisLayerStarted() void -PPPStateMachine::ThisLayerFinished() +KPPPStateMachine::ThisLayerFinished() { #if DEBUG - dprintf("PPPSM: ThisLayerFinished() state=%d phase=%d\n", + dprintf("KPPPSM: ThisLayerFinished() state=%d phase=%d\n", State(), Phase()); #endif @@ -1720,7 +1722,7 @@ PPPStateMachine::ThisLayerFinished() void -PPPStateMachine::InitializeRestartCount() +KPPPStateMachine::InitializeRestartCount() { fRequestCounter = fMaxRequest; fTerminateCounter = fMaxTerminate; @@ -1729,7 +1731,7 @@ PPPStateMachine::InitializeRestartCount() void -PPPStateMachine::ZeroRestartCount() +KPPPStateMachine::ZeroRestartCount() { fRequestCounter = 0; fTerminateCounter = 0; @@ -1738,10 +1740,10 @@ PPPStateMachine::ZeroRestartCount() bool -PPPStateMachine::SendConfigureRequest() +KPPPStateMachine::SendConfigureRequest() { #if DEBUG - dprintf("PPPSM: SendConfigureRequest() state=%d phase=%d\n", + dprintf("KPPPSM: SendConfigureRequest() state=%d phase=%d\n", State(), Phase()); #endif @@ -1750,7 +1752,7 @@ PPPStateMachine::SendConfigureRequest() fNextTimeout = system_time() + PPP_STATE_MACHINE_TIMEOUT; locker.UnlockNow(); - PPPConfigurePacket request(PPP_CONFIGURE_REQUEST); + KPPPConfigurePacket request(PPP_CONFIGURE_REQUEST); request.SetID(NextID()); fRequestID = request.ID(); @@ -1768,10 +1770,10 @@ PPPStateMachine::SendConfigureRequest() bool -PPPStateMachine::SendConfigureAck(struct mbuf *packet) +KPPPStateMachine::SendConfigureAck(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: SendConfigureAck() state=%d phase=%d\n", + dprintf("KPPPSM: SendConfigureAck() state=%d phase=%d\n", State(), Phase()); #endif @@ -1779,7 +1781,7 @@ PPPStateMachine::SendConfigureAck(struct mbuf *packet) return false; mtod(packet, ppp_lcp_packet*)->code = PPP_CONFIGURE_ACK; - PPPConfigurePacket ack(packet); + KPPPConfigurePacket ack(packet); // notify all option handlers that we are sending an ack for each value for(int32 index = 0; index < LCP().CountOptionHandlers(); index++) { @@ -1795,10 +1797,10 @@ PPPStateMachine::SendConfigureAck(struct mbuf *packet) bool -PPPStateMachine::SendConfigureNak(struct mbuf *packet) +KPPPStateMachine::SendConfigureNak(struct mbuf *packet) { #if DEBUG - dprintf("PPPSM: SendConfigureNak() state=%d phase=%d\n", + dprintf("KPPPSM: SendConfigureNak() state=%d phase=%d\n", State(), Phase()); #endif @@ -1819,10 +1821,10 @@ PPPStateMachine::SendConfigureNak(struct mbuf *packet) bool -PPPStateMachine::SendTerminateRequest() +KPPPStateMachine::SendTerminateRequest() { #if DEBUG - dprintf("PPPSM: SendTerminateRequest() state=%d phase=%d\n", + dprintf("KPPPSM: SendTerminateRequest() state=%d phase=%d\n", State(), Phase()); #endif @@ -1850,10 +1852,10 @@ PPPStateMachine::SendTerminateRequest() bool -PPPStateMachine::SendTerminateAck(struct mbuf *request = NULL) +KPPPStateMachine::SendTerminateAck(struct mbuf *request = NULL) { #if DEBUG - dprintf("PPPSM: SendTerminateAck() state=%d phase=%d\n", + dprintf("KPPPSM: SendTerminateAck() state=%d phase=%d\n", State(), Phase()); #endif @@ -1882,10 +1884,10 @@ PPPStateMachine::SendTerminateAck(struct mbuf *request = NULL) bool -PPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uint8 code) +KPPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uint8 code) { #if DEBUG - dprintf("PPPSM: SendCodeReject(protocolNumber=%X;code=%d) state=%d phase=%d\n", + dprintf("KPPPSM: SendCodeReject(protocolNumber=%X;code=%d) state=%d phase=%d\n", protocolNumber, code, State(), Phase()); #endif @@ -1929,10 +1931,10 @@ PPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uint bool -PPPStateMachine::SendEchoReply(struct mbuf *request) +KPPPStateMachine::SendEchoReply(struct mbuf *request) { #if DEBUG - dprintf("PPPSM: SendEchoReply() state=%d phase=%d\n", + dprintf("KPPPSM: SendEchoReply() state=%d phase=%d\n", State(), Phase()); #endif @@ -1955,7 +1957,7 @@ PPPStateMachine::SendEchoReply(struct mbuf *request) // methods for bringing protocols up void -PPPStateMachine::BringProtocolsUp() +KPPPStateMachine::BringProtocolsUp() { // use a simple check for phase changes (e.g., caused by CloseEvent()) while(Phase() <= PPP_ESTABLISHED_PHASE && Phase() >= PPP_AUTHENTICATION_PHASE) { @@ -1979,7 +1981,7 @@ PPPStateMachine::BringProtocolsUp() // this returns the number of handlers waiting to go up uint32 -PPPStateMachine::BringPhaseUp() +KPPPStateMachine::BringPhaseUp() { // Servers do not need to bring all protocols up. // The client specifies which protocols he wants to go up. @@ -1991,7 +1993,7 @@ PPPStateMachine::BringPhaseUp() return 0; uint32 count = 0; - PPPProtocol *protocol = Interface().FirstProtocol(); + KPPPProtocol *protocol = Interface().FirstProtocol(); for(; protocol; protocol = protocol->NextProtocol()) { if(protocol->IsEnabled() && protocol->ActivationPhase() == Phase()) { if(protocol->IsGoingUp() && Interface().Mode() == PPP_CLIENT_MODE) @@ -2016,9 +2018,9 @@ PPPStateMachine::BringPhaseUp() void -PPPStateMachine::DownProtocols() +KPPPStateMachine::DownProtocols() { - PPPProtocol *protocol = Interface().FirstProtocol(); + KPPPProtocol *protocol = Interface().FirstProtocol(); for(; protocol; protocol = protocol->NextProtocol()) if(protocol->IsEnabled()) @@ -2027,7 +2029,7 @@ PPPStateMachine::DownProtocols() void -PPPStateMachine::ResetLCPHandlers() +KPPPStateMachine::ResetLCPHandlers() { for(int32 index = 0; index < LCP().CountOptionHandlers(); index++) LCP().OptionHandlerAt(index)->Reset(); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPUtils.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPUtils.cpp index 191fa4e298..a9cc5f6d72 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPUtils.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPUtils.cpp @@ -12,7 +12,7 @@ bool -IsProtocolAllowed(const PPPProtocol& protocol) +IsProtocolAllowed(const KPPPProtocol& protocol) { if(protocol.ProtocolNumber() == PPP_LCP_PROTOCOL) return true; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/TODO b/src/add-ons/kernel/network/ppp/shared/libkernelppp/TODO index 4028db94a3..4d4184746a 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/TODO +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/TODO @@ -1,2 +1,3 @@ -- finish support for server mode +- add missing settings support (DialRetryDelay, etc.) +- finish support for server mode (profiles, etc.) - add callback support diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.cpp index 6484555f49..fa41210cb2 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.cpp @@ -23,8 +23,8 @@ typedef struct authentication_item { } authentication_item; -_PPPAuthenticationHandler::_PPPAuthenticationHandler(PPPInterface& interface) - : PPPOptionHandler("Authentication Handler", AUTHENTICATION_TYPE, interface, NULL), +_KPPPAuthenticationHandler::_KPPPAuthenticationHandler(KPPPInterface& interface) + : KPPPOptionHandler("Authentication Handler", AUTHENTICATION_TYPE, interface, NULL), fLocalAuthenticator(NULL), fPeerAuthenticator(NULL), fSuggestedLocalAuthenticator(NULL), @@ -34,12 +34,12 @@ _PPPAuthenticationHandler::_PPPAuthenticationHandler(PPPInterface& interface) } -PPPProtocol* -_PPPAuthenticationHandler::NextAuthenticator(const PPPProtocol *start, +KPPPProtocol* +_KPPPAuthenticationHandler::NextAuthenticator(const KPPPProtocol *start, ppp_side side) const { // find the next authenticator for side, beginning at start - PPPProtocol *current = start ? start->NextProtocol() : Interface().FirstProtocol(); + KPPPProtocol *current = start ? start->NextProtocol() : Interface().FirstProtocol(); for(; current; current = current->NextProtocol()) { if(!strcasecmp(current->Type(), AUTHENTICATOR_TYPE_STRING) @@ -52,7 +52,7 @@ _PPPAuthenticationHandler::NextAuthenticator(const PPPProtocol *start, status_t -_PPPAuthenticationHandler::AddToRequest(PPPConfigurePacket& request) +_KPPPAuthenticationHandler::AddToRequest(KPPPConfigurePacket& request) { // AddToRequest(): Check if peer must authenticate itself and // add an authentication request if needed. This request is added @@ -63,7 +63,7 @@ _PPPAuthenticationHandler::AddToRequest(PPPConfigurePacket& request) if(fSuggestedPeerAuthenticator) fSuggestedPeerAuthenticator->SetEnabled(false); - PPPProtocol *authenticator; + KPPPProtocol *authenticator; if(fPeerAuthenticatorRejected) { if(!fSuggestedPeerAuthenticator) { // This happens when the protocol is rejected, but no alternative @@ -100,7 +100,7 @@ _PPPAuthenticationHandler::AddToRequest(PPPConfigurePacket& request) // no problem because the suggested authenticator will be accepted (hopefully) #if DEBUG - dprintf("PPPAuthHandler: AddToRequest(%X)\n", authenticator->ProtocolNumber()); + dprintf("KPPPAuthHandler: AddToRequest(%X)\n", authenticator->ProtocolNumber()); #endif authenticator->SetEnabled(true); @@ -110,7 +110,7 @@ _PPPAuthenticationHandler::AddToRequest(PPPConfigurePacket& request) status_t -_PPPAuthenticationHandler::ParseNak(const PPPConfigurePacket& nak) +_KPPPAuthenticationHandler::ParseNak(const KPPPConfigurePacket& nak) { // The authenticator's OptionHandler is not notified. @@ -135,7 +135,7 @@ _PPPAuthenticationHandler::ParseNak(const PPPConfigurePacket& nak) } fPeerAuthenticatorRejected = true; - PPPProtocol *authenticator = Interface().ProtocolFor(ntohs(item->protocolNumber)); + KPPPProtocol *authenticator = Interface().ProtocolFor(ntohs(item->protocolNumber)); if(authenticator && !strcasecmp(authenticator->Type(), AUTHENTICATOR_TYPE_STRING) && authenticator->OptionHandler()) @@ -148,7 +148,7 @@ _PPPAuthenticationHandler::ParseNak(const PPPConfigurePacket& nak) status_t -_PPPAuthenticationHandler::ParseReject(const PPPConfigurePacket& reject) +_KPPPAuthenticationHandler::ParseReject(const KPPPConfigurePacket& reject) { // an authentication request must not be rejected! if(reject.ItemWithType(AUTHENTICATION_TYPE)) @@ -159,7 +159,7 @@ _PPPAuthenticationHandler::ParseReject(const PPPConfigurePacket& reject) status_t -_PPPAuthenticationHandler::ParseAck(const PPPConfigurePacket& ack) +_KPPPAuthenticationHandler::ParseAck(const KPPPConfigurePacket& ack) { authentication_item *item = (authentication_item*) ack.ItemWithType(AUTHENTICATION_TYPE); @@ -182,8 +182,8 @@ _PPPAuthenticationHandler::ParseAck(const PPPConfigurePacket& ack) status_t -_PPPAuthenticationHandler::ParseRequest(const PPPConfigurePacket& request, - int32 index, PPPConfigurePacket& nak, PPPConfigurePacket& reject) +_KPPPAuthenticationHandler::ParseRequest(const KPPPConfigurePacket& request, + int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject) { if(fLocalAuthenticator) fLocalAuthenticator->SetEnabled(false); @@ -194,7 +194,7 @@ _PPPAuthenticationHandler::ParseRequest(const PPPConfigurePacket& request, // no authentication requested by peer (index > request.CountItems()) #if DEBUG - dprintf("PPPAuthHandler: ParseRequest(%X)\n", ntohs(item->protocolNumber)); + dprintf("KPPPAuthHandler: ParseRequest(%X)\n", ntohs(item->protocolNumber)); #endif // try to find the requested protocol @@ -206,7 +206,7 @@ _PPPAuthenticationHandler::ParseRequest(const PPPConfigurePacket& request, nak, reject); // suggest another authentication protocol - PPPProtocol *nextAuthenticator = + KPPPProtocol *nextAuthenticator = NextAuthenticator(fSuggestedLocalAuthenticator, PPP_LOCAL_SIDE); if(!nextAuthenticator) { @@ -233,7 +233,7 @@ _PPPAuthenticationHandler::ParseRequest(const PPPConfigurePacket& request, status_t -_PPPAuthenticationHandler::SendingAck(const PPPConfigurePacket& ack) +_KPPPAuthenticationHandler::SendingAck(const KPPPConfigurePacket& ack) { // do not insist on authenticating our side of the link ;) @@ -260,7 +260,7 @@ _PPPAuthenticationHandler::SendingAck(const PPPConfigurePacket& ack) void -_PPPAuthenticationHandler::Reset() +_KPPPAuthenticationHandler::Reset() { if(fLocalAuthenticator) { fLocalAuthenticator->SetEnabled(false); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.h index b6c795c76a..ed26ca1185 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.h @@ -11,25 +11,26 @@ #include -class _PPPAuthenticationHandler : public PPPOptionHandler { +class _KPPPAuthenticationHandler : public KPPPOptionHandler { public: - _PPPAuthenticationHandler(PPPInterface& interface); + _KPPPAuthenticationHandler(KPPPInterface& interface); - PPPProtocol *NextAuthenticator(const PPPProtocol *start, ppp_side side) const; + KPPPProtocol *NextAuthenticator(const KPPPProtocol *start, + ppp_side side) const; - virtual status_t AddToRequest(PPPConfigurePacket& request); - virtual status_t ParseNak(const PPPConfigurePacket& nak); - virtual status_t ParseReject(const PPPConfigurePacket& reject); - virtual status_t ParseAck(const PPPConfigurePacket& ack); + virtual status_t AddToRequest(KPPPConfigurePacket& request); + virtual status_t ParseNak(const KPPPConfigurePacket& nak); + virtual status_t ParseReject(const KPPPConfigurePacket& reject); + virtual status_t ParseAck(const KPPPConfigurePacket& ack); - virtual status_t ParseRequest(const PPPConfigurePacket& request, - int32 index, PPPConfigurePacket& nak, PPPConfigurePacket& reject); - virtual status_t SendingAck(const PPPConfigurePacket& ack); + virtual status_t ParseRequest(const KPPPConfigurePacket& request, + int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject); + virtual status_t SendingAck(const KPPPConfigurePacket& ack); virtual void Reset(); private: - PPPProtocol *fLocalAuthenticator, *fPeerAuthenticator, + KPPPProtocol *fLocalAuthenticator, *fPeerAuthenticator, *fSuggestedLocalAuthenticator, *fSuggestedPeerAuthenticator; bool fPeerAuthenticatorRejected; }; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.cpp index 5eae289278..b1cb2064d8 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.cpp @@ -21,18 +21,18 @@ typedef struct mru_item { uint16 MRU _PACKED; } mru_item; -status_t ParseRequestedItem(mru_item *item, PPPInterface& interface); +status_t ParseRequestedItem(mru_item *item, KPPPInterface& interface); -_PPPMRUHandler::_PPPMRUHandler(PPPInterface& interface) - : PPPOptionHandler("MRU Handler", MRU_TYPE, interface, NULL) +_KPPPMRUHandler::_KPPPMRUHandler(KPPPInterface& interface) + : KPPPOptionHandler("MRU Handler", MRU_TYPE, interface, NULL) { Reset(); } status_t -_PPPMRUHandler::AddToRequest(PPPConfigurePacket& request) +_KPPPMRUHandler::AddToRequest(KPPPConfigurePacket& request) { if(!Interface().Device() || Interface().MRU() == 1500) return B_OK; @@ -47,7 +47,7 @@ _PPPMRUHandler::AddToRequest(PPPConfigurePacket& request) status_t -_PPPMRUHandler::ParseNak(const PPPConfigurePacket& nak) +_KPPPMRUHandler::ParseNak(const KPPPConfigurePacket& nak) { mru_item *item = (mru_item*) nak.ItemWithType(MRU_TYPE); if(!item || item->length != 4) @@ -62,7 +62,7 @@ _PPPMRUHandler::ParseNak(const PPPConfigurePacket& nak) status_t -_PPPMRUHandler::ParseReject(const PPPConfigurePacket& reject) +_KPPPMRUHandler::ParseReject(const KPPPConfigurePacket& reject) { if(reject.ItemWithType(MRU_TYPE)) return B_ERROR; @@ -72,7 +72,7 @@ _PPPMRUHandler::ParseReject(const PPPConfigurePacket& reject) status_t -_PPPMRUHandler::ParseAck(const PPPConfigurePacket& ack) +_KPPPMRUHandler::ParseAck(const KPPPConfigurePacket& ack) { uint16 MRU = 1500; mru_item *item = (mru_item*) ack.ItemWithType(MRU_TYPE); @@ -88,8 +88,8 @@ _PPPMRUHandler::ParseAck(const PPPConfigurePacket& ack) status_t -_PPPMRUHandler::ParseRequest(const PPPConfigurePacket& request, - int32 index, PPPConfigurePacket& nak, PPPConfigurePacket& reject) +_KPPPMRUHandler::ParseRequest(const KPPPConfigurePacket& request, + int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject) { if(index == reject.CountItems()) return B_OK; @@ -101,7 +101,7 @@ _PPPMRUHandler::ParseRequest(const PPPConfigurePacket& request, status_t -_PPPMRUHandler::SendingAck(const PPPConfigurePacket& ack) +_KPPPMRUHandler::SendingAck(const KPPPConfigurePacket& ack) { return ParseRequestedItem((mru_item*) ack.ItemWithType(MRU_TYPE), Interface()); } @@ -109,7 +109,7 @@ _PPPMRUHandler::SendingAck(const PPPConfigurePacket& ack) // this function contains code shared by ParseRequest and SendingAck status_t -ParseRequestedItem(mru_item *item, PPPInterface& interface) +ParseRequestedItem(mru_item *item, KPPPInterface& interface) { uint16 MRU = 1500; @@ -129,7 +129,7 @@ ParseRequestedItem(mru_item *item, PPPInterface& interface) void -_PPPMRUHandler::Reset() +_KPPPMRUHandler::Reset() { if(Interface().Device()) { fLocalMRU = Interface().Device()->MTU() - 2; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.h index 7f70c2cf2e..3c31ab109c 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.h @@ -11,18 +11,18 @@ #include -class _PPPMRUHandler : public PPPOptionHandler { +class _KPPPMRUHandler : public KPPPOptionHandler { public: - _PPPMRUHandler(PPPInterface& interface); + _KPPPMRUHandler(KPPPInterface& interface); - virtual status_t AddToRequest(PPPConfigurePacket& request); - virtual status_t ParseNak(const PPPConfigurePacket& nak); - virtual status_t ParseReject(const PPPConfigurePacket& reject); - virtual status_t ParseAck(const PPPConfigurePacket& ack); + virtual status_t AddToRequest(KPPPConfigurePacket& request); + virtual status_t ParseNak(const KPPPConfigurePacket& nak); + virtual status_t ParseReject(const KPPPConfigurePacket& reject); + virtual status_t ParseAck(const KPPPConfigurePacket& ack); - virtual status_t ParseRequest(const PPPConfigurePacket& request, - int32 index, PPPConfigurePacket& nak, PPPConfigurePacket& reject); - virtual status_t SendingAck(const PPPConfigurePacket& ack); + virtual status_t ParseRequest(const KPPPConfigurePacket& request, + int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject); + virtual status_t SendingAck(const KPPPConfigurePacket& ack); virtual void Reset(); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.cpp index 5cc20f20ce..03a4de0e91 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.cpp @@ -13,9 +13,9 @@ #define PFC_TYPE 0x7 -_PPPPFCHandler::_PPPPFCHandler(ppp_pfc_state& localPFCState, - ppp_pfc_state& peerPFCState, PPPInterface& interface) - : PPPOptionHandler("PFC Handler", PFC_TYPE, interface, NULL), +_KPPPPFCHandler::_KPPPPFCHandler(ppp_pfc_state& localPFCState, + ppp_pfc_state& peerPFCState, KPPPInterface& interface) + : KPPPOptionHandler("PFC Handler", PFC_TYPE, interface, NULL), fLocalPFCState(localPFCState), fPeerPFCState(peerPFCState) { @@ -23,7 +23,7 @@ _PPPPFCHandler::_PPPPFCHandler(ppp_pfc_state& localPFCState, status_t -_PPPPFCHandler::AddToRequest(PPPConfigurePacket& request) +_KPPPPFCHandler::AddToRequest(KPPPConfigurePacket& request) { // is PFC not requested or was it rejected? if(fLocalPFCState == PPP_PFC_REJECTED @@ -39,7 +39,7 @@ _PPPPFCHandler::AddToRequest(PPPConfigurePacket& request) status_t -_PPPPFCHandler::ParseNak(const PPPConfigurePacket& nak) +_KPPPPFCHandler::ParseNak(const KPPPConfigurePacket& nak) { // naks do not contain PFC items if(nak.ItemWithType(PFC_TYPE)) @@ -50,7 +50,7 @@ _PPPPFCHandler::ParseNak(const PPPConfigurePacket& nak) status_t -_PPPPFCHandler::ParseReject(const PPPConfigurePacket& reject) +_KPPPPFCHandler::ParseReject(const KPPPConfigurePacket& reject) { if(reject.ItemWithType(PFC_TYPE)) { fLocalPFCState = PPP_PFC_REJECTED; @@ -64,7 +64,7 @@ _PPPPFCHandler::ParseReject(const PPPConfigurePacket& reject) status_t -_PPPPFCHandler::ParseAck(const PPPConfigurePacket& ack) +_KPPPPFCHandler::ParseAck(const KPPPConfigurePacket& ack) { if(ack.ItemWithType(PFC_TYPE)) fLocalPFCState = PPP_PFC_ACCEPTED; @@ -80,8 +80,8 @@ _PPPPFCHandler::ParseAck(const PPPConfigurePacket& ack) status_t -_PPPPFCHandler::ParseRequest(const PPPConfigurePacket& request, - int32 index, PPPConfigurePacket& nak, PPPConfigurePacket& reject) +_KPPPPFCHandler::ParseRequest(const KPPPConfigurePacket& request, + int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject) { if(!request.ItemWithType(PFC_TYPE)) return B_OK; @@ -98,7 +98,7 @@ _PPPPFCHandler::ParseRequest(const PPPConfigurePacket& request, status_t -_PPPPFCHandler::SendingAck(const PPPConfigurePacket& ack) +_KPPPPFCHandler::SendingAck(const KPPPConfigurePacket& ack) { ppp_configure_item *item = ack.ItemWithType(PFC_TYPE); @@ -115,7 +115,7 @@ _PPPPFCHandler::SendingAck(const PPPConfigurePacket& ack) void -_PPPPFCHandler::Reset() +_KPPPPFCHandler::Reset() { fLocalPFCState = fPeerPFCState = PPP_PFC_DISABLED; } diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.h index 28e9bcc307..3971e9da5e 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.h @@ -11,19 +11,19 @@ #include -class _PPPPFCHandler : public PPPOptionHandler { +class _KPPPPFCHandler : public KPPPOptionHandler { public: - _PPPPFCHandler(ppp_pfc_state& localPFCState, ppp_pfc_state& peerPFCState, - PPPInterface& interface); + _KPPPPFCHandler(ppp_pfc_state& localPFCState, ppp_pfc_state& peerPFCState, + KPPPInterface& interface); - virtual status_t AddToRequest(PPPConfigurePacket& request); - virtual status_t ParseNak(const PPPConfigurePacket& nak); - virtual status_t ParseReject(const PPPConfigurePacket& reject); - virtual status_t ParseAck(const PPPConfigurePacket& ack); + virtual status_t AddToRequest(KPPPConfigurePacket& request); + virtual status_t ParseNak(const KPPPConfigurePacket& nak); + virtual status_t ParseReject(const KPPPConfigurePacket& reject); + virtual status_t ParseAck(const KPPPConfigurePacket& ack); - virtual status_t ParseRequest(const PPPConfigurePacket& request, - int32 index, PPPConfigurePacket& nak, PPPConfigurePacket& reject); - virtual status_t SendingAck(const PPPConfigurePacket& ack); + virtual status_t ParseRequest(const KPPPConfigurePacket& request, + int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject); + virtual status_t SendingAck(const KPPPConfigurePacket& ack); virtual void Reset(); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPConfigurePacket.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPConfigurePacket.h index a186af0d62..e5b4d63c7f 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPConfigurePacket.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPConfigurePacket.h @@ -12,7 +12,6 @@ struct mbuf; - typedef struct ppp_configure_item { uint8 type; uint8 length; @@ -21,16 +20,16 @@ typedef struct ppp_configure_item { } ppp_configure_item; -class PPPConfigurePacket { +class KPPPConfigurePacket { private: // copies are not allowed! - PPPConfigurePacket(const PPPConfigurePacket& copy); - PPPConfigurePacket& operator= (const PPPConfigurePacket& copy); + KPPPConfigurePacket(const KPPPConfigurePacket& copy); + KPPPConfigurePacket& operator= (const KPPPConfigurePacket& copy); public: - PPPConfigurePacket(uint8 code); - PPPConfigurePacket(struct mbuf *packet); - ~PPPConfigurePacket(); + KPPPConfigurePacket(uint8 code); + KPPPConfigurePacket(struct mbuf *packet); + ~KPPPConfigurePacket(); bool SetCode(uint8 code); uint8 Code() const diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDefs.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDefs.h index 5db7dbbab2..d8f52134d8 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDefs.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDefs.h @@ -12,13 +12,14 @@ #include +extern struct core_module_info *core; + // needed by core quick-access function defines + + // various constants #define PPP_PULSE_RATE 500000 -extern struct core_module_info *core; - - // module key types (used when loading a module) enum ppp_module_key_type { PPP_UNDEFINED_KEY_TYPE = -1, @@ -69,4 +70,5 @@ enum ppp_lcp_code { #define PPP_MIN_LCP_CODE PPP_CONFIGURE_REQUEST #define PPP_MAX_LCP_CODE PPP_DISCARD_REQUEST + #endif diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDevice.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDevice.h index 13cc96f111..3a9566624e 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDevice.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDevice.h @@ -16,18 +16,18 @@ #endif -class PPPDevice : public PPPLayer { - friend class PPPStateMachine; +class KPPPDevice : public KPPPLayer { + friend class KPPPStateMachine; protected: - // PPPDevice must be subclassed - PPPDevice(const char *name, uint32 overhead, PPPInterface& interface, + // KPPPDevice must be subclassed + KPPPDevice(const char *name, uint32 overhead, KPPPInterface& interface, driver_parameter *settings); public: - virtual ~PPPDevice(); + virtual ~KPPPDevice(); - PPPInterface& Interface() const + KPPPInterface& Interface() const { return fInterface; } driver_parameter *Settings() const { return fSettings; } @@ -90,7 +90,7 @@ class PPPDevice : public PPPLayer { private: char *fName; - PPPInterface& fInterface; + KPPPInterface& fInterface; driver_parameter *fSettings; ppp_phase fConnectionPhase; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPInterface.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPInterface.h index d920f754ce..0e694139a1 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPInterface.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPInterface.h @@ -10,44 +10,52 @@ #include +#ifndef _K_PPP_DEFS__H #include +#endif #ifndef _K_PPP_LCP__H #include #endif +#ifndef _K_PPP_PROFILE__H +#include +#endif + +#ifndef _K_PPP_REPORT_MANAGER__H #include +#endif #ifndef _K_PPP_STATE_MACHINE__H #include #endif #include -#include -class PPPDevice; -class PPPProtocol; -class PPPOptionHandler; +class KPPPDevice; +class KPPPProtocol; +class KPPPOptionHandler; struct ppp_interface_module_info; struct ppp_module_info; struct ppp_interface_entry; -class PPPInterface : public PPPLayer { - friend class PPPStateMachine; +class KPPPInterface : public KPPPLayer { friend class PPPManager; - friend class PPPInterfaceAccess; + friend class KPPPStateMachine; + friend class KPPPInterfaceAccess; private: // copies are not allowed! - PPPInterface(const PPPInterface& copy); - PPPInterface& operator= (const PPPInterface& copy); + KPPPInterface(const KPPPInterface& copy); + KPPPInterface& operator= (const KPPPInterface& copy); // only PPPManager may construct us! - PPPInterface(ppp_interface_entry *entry, ppp_interface_id ID, - const driver_settings *settings, PPPInterface *parent = NULL); - ~PPPInterface(); + KPPPInterface(const char *name, ppp_interface_entry *entry, + ppp_interface_id ID, const driver_settings *settings, + const driver_settings *profile, KPPPInterface *parent = NULL); + ~KPPPInterface(); public: void Delete(); @@ -60,10 +68,12 @@ class PPPInterface : public PPPLayer { driver_settings* Settings() const { return fSettings; } - PPPStateMachine& StateMachine() + KPPPStateMachine& StateMachine() { return fStateMachine; } - PPPLCP& LCP() + KPPPLCP& LCP() { return fLCP; } + KPPPProfile& Profile() + { return fProfile; } struct ifnet *Ifnet() const { return fIfnet; } @@ -94,25 +104,26 @@ class PPPInterface : public PPPLayer { virtual status_t Control(uint32 op, void *data, size_t length); - bool SetDevice(PPPDevice *device); - PPPDevice *Device() const + bool SetDevice(KPPPDevice *device); + KPPPDevice *Device() const { return fDevice; } - bool AddProtocol(PPPProtocol *protocol); - bool RemoveProtocol(PPPProtocol *protocol); + bool AddProtocol(KPPPProtocol *protocol); + bool RemoveProtocol(KPPPProtocol *protocol); int32 CountProtocols() const; - PPPProtocol *ProtocolAt(int32 index) const; - PPPProtocol *FirstProtocol() const + KPPPProtocol *ProtocolAt(int32 index) const; + KPPPProtocol *FirstProtocol() const { return fFirstProtocol; } - PPPProtocol *ProtocolFor(uint16 protocolNumber, PPPProtocol *start = NULL) const; + KPPPProtocol *ProtocolFor(uint16 protocolNumber, + KPPPProtocol *start = NULL) const; // multilink methods - bool AddChild(PPPInterface *child); - bool RemoveChild(PPPInterface *child); + bool AddChild(KPPPInterface *child); + bool RemoveChild(KPPPInterface *child); int32 CountChildren() const { return fChildren.CountItems(); } - PPPInterface *ChildAt(int32 index) const; - PPPInterface *Parent() const + KPPPInterface *ChildAt(int32 index) const; + KPPPInterface *Parent() const { return fParent; } bool IsMultilink() const { return fIsMultilink; } @@ -153,7 +164,7 @@ class PPPInterface : public PPPLayer { virtual bool Down(); bool IsUp() const; - PPPReportManager& ReportManager() + KPPPReportManager& ReportManager() { return fReportManager; } bool Report(ppp_report_type type, int32 code, void *data, int32 length) { return ReportManager().Report(type, code, data, length); } @@ -172,7 +183,7 @@ class PPPInterface : public PPPLayer { virtual status_t Receive(struct mbuf *packet, uint16 protocolNumber); status_t ReceiveFromDevice(struct mbuf *packet); - // This must not block PPPDevice::Send()! + // This must not block KPPPDevice::Send()! void Pulse(); // this manages all timeouts, etc. @@ -183,6 +194,8 @@ class PPPInterface : public PPPLayer { // saves the returned ifnet structure bool UnregisterInterface(); + void SetName(const char *name); + status_t StackControl(uint32 op, void *data); // stack routes ioctls to interface status_t StackControlEachHandler(uint32 op, void *data); @@ -200,7 +213,7 @@ class PPPInterface : public PPPLayer { void Redial(uint32 delay); // multilink methods - void SetParent(PPPInterface *parent) + void SetParent(KPPPInterface *parent) { fParent = parent; } private: @@ -220,8 +233,8 @@ class PPPInterface : public PPPLayer { uint32 fIdleSince, fDisconnectAfterIdleSince; uint32 fMRU, fInterfaceMTU, fHeaderLength; - PPPInterface *fParent; - TemplateList fChildren; + KPPPInterface *fParent; + TemplateList fChildren; bool fIsMultilink; bool fAutoRedial, fDialOnDemand; @@ -230,13 +243,14 @@ class PPPInterface : public PPPLayer { ppp_pfc_state fLocalPFCState, fPeerPFCState; uint8 fPFCOptions; - PPPDevice *fDevice; - PPPProtocol *fFirstProtocol; + KPPPDevice *fDevice; + KPPPProtocol *fFirstProtocol; TemplateList fModules; - PPPStateMachine fStateMachine; - PPPLCP fLCP; - PPPReportManager fReportManager; + KPPPStateMachine fStateMachine; + KPPPLCP fLCP; + KPPPProfile fProfile; + KPPPReportManager fReportManager; BLocker& fLock; int32 fDeleteCounter; }; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCP.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCP.h index 2890c87917..db13934b95 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCP.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCP.h @@ -22,8 +22,8 @@ #include #endif -class PPPLCPExtension; -class PPPOptionHandler; +class KPPPLCPExtension; +class KPPPOptionHandler; typedef struct ppp_lcp_packet { @@ -34,41 +34,41 @@ typedef struct ppp_lcp_packet { } ppp_lcp_packet; -class PPPLCP : public PPPProtocol { - friend class PPPInterface; +class KPPPLCP : public KPPPProtocol { + friend class KPPPInterface; private: - // may only be constructed/destructed by PPPInterface - PPPLCP(PPPInterface& interface); - virtual ~PPPLCP(); + // may only be constructed/destructed by KPPPInterface + KPPPLCP(KPPPInterface& interface); + virtual ~KPPPLCP(); // copies are not allowed! - PPPLCP(const PPPLCP& copy); - PPPLCP& operator= (const PPPLCP& copy); + KPPPLCP(const KPPPLCP& copy); + KPPPLCP& operator= (const KPPPLCP& copy); public: - PPPStateMachine& StateMachine() const + KPPPStateMachine& StateMachine() const { return fStateMachine; } - bool AddOptionHandler(PPPOptionHandler *handler); - bool RemoveOptionHandler(PPPOptionHandler *handler); + bool AddOptionHandler(KPPPOptionHandler *handler); + bool RemoveOptionHandler(KPPPOptionHandler *handler); int32 CountOptionHandlers() const { return fOptionHandlers.CountItems(); } - PPPOptionHandler *OptionHandlerAt(int32 index) const; - PPPOptionHandler *OptionHandlerFor(uint8 type, int32 *start = NULL) const; + KPPPOptionHandler *OptionHandlerAt(int32 index) const; + KPPPOptionHandler *OptionHandlerFor(uint8 type, int32 *start = NULL) const; - bool AddLCPExtension(PPPLCPExtension *extension); - bool RemoveLCPExtension(PPPLCPExtension *extension); + bool AddLCPExtension(KPPPLCPExtension *extension); + bool RemoveLCPExtension(KPPPLCPExtension *extension); int32 CountLCPExtensions() const { return fLCPExtensions.CountItems(); } - PPPLCPExtension *LCPExtensionAt(int32 index) const; - PPPLCPExtension *LCPExtensionFor(uint8 code, int32 *start = NULL) const; + KPPPLCPExtension *LCPExtensionAt(int32 index) const; + KPPPLCPExtension *LCPExtensionFor(uint8 code, int32 *start = NULL) const; - void SetTarget(PPPProtocol *target) + void SetTarget(KPPPProtocol *target) { fTarget = target; } // if target != NULL all packtes will be passed to the protocol // instead of the interface/device - PPPProtocol *Target() const + KPPPProtocol *Target() const { return fTarget; } uint32 AdditionalOverhead() const; @@ -84,12 +84,12 @@ class PPPLCP : public PPPProtocol { virtual void Pulse(); private: - PPPStateMachine& fStateMachine; + KPPPStateMachine& fStateMachine; - TemplateList fOptionHandlers; - TemplateList fLCPExtensions; + TemplateList fOptionHandlers; + TemplateList fLCPExtensions; - PPPProtocol *fTarget; + KPPPProtocol *fTarget; }; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h index 12bce077a0..d4f49c0c92 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h @@ -15,21 +15,21 @@ #endif -class PPPLCPExtension { +class KPPPLCPExtension { protected: - // PPPLCPExtension must be subclassed - PPPLCPExtension(const char *name, uint8 code, PPPInterface& interface, + // KPPPLCPExtension must be subclassed + KPPPLCPExtension(const char *name, uint8 code, KPPPInterface& interface, driver_parameter *settings); public: - virtual ~PPPLCPExtension(); + virtual ~KPPPLCPExtension(); virtual status_t InitCheck() const; const char *Name() const { return fName; } - PPPInterface& Interface() const + KPPPInterface& Interface() const { return fInterface; } driver_parameter *Settings() const { return fSettings; } @@ -44,7 +44,7 @@ class PPPLCPExtension { virtual status_t Control(uint32 op, void *data, size_t length); virtual status_t StackControl(uint32 op, void *data); - // called by netstack (forwarded by PPPInterface) + // called by netstack (forwarded by KPPPInterface) virtual status_t Receive(struct mbuf *packet, uint8 code) = 0; @@ -56,7 +56,7 @@ class PPPLCPExtension { private: char *fName; - PPPInterface& fInterface; + KPPPInterface& fInterface; driver_parameter *fSettings; uint8 fCode; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h index f5fe3580be..9539671dcb 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h @@ -11,13 +11,13 @@ #include -class PPPLayer { +class KPPPLayer { protected: - // PPPLayer must be subclassed - PPPLayer(const char *name, ppp_level level, uint32 overhead); + // KPPPLayer must be subclassed + KPPPLayer(const char *name, ppp_level level, uint32 overhead); public: - virtual ~PPPLayer(); + virtual ~KPPPLayer(); virtual status_t InitCheck() const; @@ -29,9 +29,9 @@ class PPPLayer { uint32 Overhead() const { return fOverhead; } - void SetNext(PPPLayer *next) + void SetNext(KPPPLayer *next) { fNext = next; } - PPPLayer *Next() const + KPPPLayer *Next() const { return fNext; } virtual bool Up() = 0; @@ -48,6 +48,8 @@ class PPPLayer { virtual void Pulse(); protected: + void SetName(const char *name); + status_t fInitStatus; uint32 fOverhead; @@ -55,7 +57,7 @@ class PPPLayer { char *fName; ppp_level fLevel; - PPPLayer *fNext; + KPPPLayer *fNext; }; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPManager.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPManager.h index 17f15523d4..2072dd9e39 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPManager.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPManager.h @@ -19,20 +19,30 @@ // create_interface() returns this value on failure -class PPPInterface; +class KPPPInterface; typedef struct ppp_interface_entry { - PPPInterface *interface; + KPPPInterface *interface; vint32 accessing; bool deleting; } ppp_interface_entry; +/*! \brief Exported by the PPP interface manager kernel module. + + You should always create interfaces using either of the CreateInterface() + functions. The manager keeps track of all running connections and automatically + deletes them when they are not needed anymore. +*/ typedef struct ppp_interface_module_info { kernel_net_module_info knminfo; + //!< Exports needed network module functions. ppp_interface_id (*CreateInterface)(const driver_settings *settings, + const driver_settings *profile = NULL, + ppp_interface_id parentID = PPP_UNDEFINED_INTERFACE_ID); + ppp_interface_id (*CreateInterfaceWithName)(const char *name, + const driver_settings *profile = NULL, ppp_interface_id parentID = PPP_UNDEFINED_INTERFACE_ID); - // you should always create interfaces using this function bool (*DeleteInterface)(ppp_interface_id ID); // this marks the interface for deletion bool (*RemoveInterface)(ppp_interface_id ID); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPModule.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPModule.h index 5cf5d98515..a035513026 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPModule.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPModule.h @@ -10,18 +10,42 @@ #include -class PPPInterface; +class KPPPInterface; +//! This structure is exported by PPP kernel modules. typedef struct ppp_module_info { module_info minfo; + //!< Default kernel module structure. + + //! You may define this \e optional function if you want to export a private API. status_t (*control)(uint32 op, void *data, size_t length); - bool (*add_to)(PPPInterface& mainInterface, PPPInterface *subInterface, + + /*! \brief Signals your module to add its handlers to the PPP interface. + + This function \e must be exported. + + Multilink-only: Handlers that must run on a bundle's child should be + added to \a subInterface while \a mainInterface handlers are used for the + bundle interfaces. For example, devices must be added to every child + individually because every \a subInterface establishes its own connection + while the IP Control Protocol is added to the \a mainInterface because + it is shared by all interfaces of the bundle. + + \param mainInterface The multilink bundle or (if subInterface == NULL) the + actual interface object. + \param subInterface If defined, this is a child interface of a bundle. + \param settings The settings for your module. + \param type Specifies which key caused loading the module. This would be + \c PPP_AUTHENTICATOR_KEY_TYPE for "authenticator". You should check + if \a type is correct (e.g.: loading an authenticator with "device" + should fail). + + \return + \c true: Modules could be added successfully. + */ + bool (*add_to)(KPPPInterface& mainInterface, KPPPInterface *subInterface, driver_parameter *settings, ppp_module_key_type type); - // multilink: handlers that must run on a real device - // should be added to subInterface (may be NULL) - // while mainInterface handlers are used for the - // bundle of interfaces } ppp_module_info; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h index a9830d7f5e..44e68361a9 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h @@ -14,17 +14,17 @@ #include #endif -class PPPConfigurePacket; +class KPPPConfigurePacket; -class PPPOptionHandler { +class KPPPOptionHandler { protected: - // PPPOptionHandler must be subclassed - PPPOptionHandler(const char *name, uint8 type, PPPInterface& interface, + // KPPPOptionHandler must be subclassed + KPPPOptionHandler(const char *name, uint8 type, KPPPInterface& interface, driver_parameter *settings); public: - virtual ~PPPOptionHandler(); + virtual ~KPPPOptionHandler(); virtual status_t InitCheck() const; @@ -34,7 +34,7 @@ class PPPOptionHandler { uint8 Type() const { return fType; } - PPPInterface& Interface() const + KPPPInterface& Interface() const { return fInterface; } driver_parameter *Settings() const { return fSettings; } @@ -46,23 +46,23 @@ class PPPOptionHandler { virtual status_t Control(uint32 op, void *data, size_t length); virtual status_t StackControl(uint32 op, void *data); - // called by netstack (forwarded by PPPInterface) + // called by netstack (forwarded by KPPPInterface) // we want to send a configure request or we received a reply - virtual status_t AddToRequest(PPPConfigurePacket& request) = 0; - virtual status_t ParseNak(const PPPConfigurePacket& nak) = 0; + virtual status_t AddToRequest(KPPPConfigurePacket& request) = 0; + virtual status_t ParseNak(const KPPPConfigurePacket& nak) = 0; // create next request based on these and previous values - virtual status_t ParseReject(const PPPConfigurePacket& reject) = 0; + virtual status_t ParseReject(const KPPPConfigurePacket& reject) = 0; // create next request based on these and previous values - virtual status_t ParseAck(const PPPConfigurePacket& ack) = 0; + virtual status_t ParseAck(const KPPPConfigurePacket& ack) = 0; // this is called for all handlers // peer sent configure request - virtual status_t ParseRequest(const PPPConfigurePacket& request, - int32 index, PPPConfigurePacket& nak, PPPConfigurePacket& reject) = 0; + virtual status_t ParseRequest(const KPPPConfigurePacket& request, + int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject) = 0; // index may be behind the last item which means additional values can be // appended - virtual status_t SendingAck(const PPPConfigurePacket& ack) = 0; + virtual status_t SendingAck(const KPPPConfigurePacket& ack) = 0; // notification that we ack these values virtual void Reset() = 0; @@ -74,7 +74,7 @@ class PPPOptionHandler { private: char *fName; uint8 fType; - PPPInterface& fInterface; + KPPPInterface& fInterface; driver_parameter *fSettings; bool fEnabled; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProfile.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProfile.h new file mode 100644 index 0000000000..cea85ac9e4 --- /dev/null +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProfile.h @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +// +// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de +//----------------------------------------------------------------------- + +#ifndef _K_PPP_PROFILE__H +#define _K_PPP_PROFILE__H + +#include + +class KPPPInterface; + + +class KPPPProfile { + friend class KPPPInterface; + + private: + KPPPProfile(KPPPInterface& interface); + ~KPPPProfile(); + void LoadSettings(const driver_settings *profile, + driver_settings *interfaceSettings); + + public: + //! Returns interface that owns this profile. + KPPPInterface& Interface() const + { return fInterface; } + //! Returns the loaded profile settings. + const driver_settings *Settings() const + { return fSettings; } + const driver_parameter *SettingsFor(const char *type, const char *name) const; + // name may be NULL + +// size_t Request(void *out, size_t outSize, void *in, size_t inSize) const; + + private: + KPPPInterface& fInterface; + driver_settings *fSettings; +}; + + +#endif diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProtocol.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProtocol.h index 47a994d9f1..cc1c1ce0b0 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProtocol.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProtocol.h @@ -11,23 +11,23 @@ #include #include -class PPPInterface; -class PPPOptionHandler; +class KPPPInterface; +class KPPPOptionHandler; -class PPPProtocol : public PPPLayer { +class KPPPProtocol : public KPPPLayer { protected: - // PPPProtocol must be subclassed - PPPProtocol(const char *name, ppp_phase activationPhase, + // KPPPProtocol must be subclassed + KPPPProtocol(const char *name, ppp_phase activationPhase, uint16 protocolNumber, ppp_level level, int32 addressFamily, - uint32 overhead, PPPInterface& interface, + uint32 overhead, KPPPInterface& interface, driver_parameter *settings, int32 flags = PPP_NO_FLAGS, - const char *type = NULL, PPPOptionHandler *optionHandler = NULL); + const char *type = NULL, KPPPOptionHandler *optionHandler = NULL); public: - virtual ~PPPProtocol(); + virtual ~KPPPProtocol(); - PPPInterface& Interface() const + KPPPInterface& Interface() const { return fInterface; } driver_parameter *Settings() const { return fSettings; } @@ -48,12 +48,12 @@ class PPPProtocol : public PPPLayer { const char *Type() const { return fType; } - PPPOptionHandler *OptionHandler() const + KPPPOptionHandler *OptionHandler() const { return fOptionHandler; } - void SetNextProtocol(PPPProtocol *protocol) + void SetNextProtocol(KPPPProtocol *protocol) { fNextProtocol = protocol; SetNext(protocol); } - PPPProtocol *NextProtocol() const + KPPPProtocol *NextProtocol() const { return fNextProtocol; } void SetEnabled(bool enabled = true); @@ -65,7 +65,7 @@ class PPPProtocol : public PPPLayer { virtual status_t Control(uint32 op, void *data, size_t length); virtual status_t StackControl(uint32 op, void *data); - // called by netstack (forwarded by PPPInterface) + // called by netstack (forwarded by KPPPInterface) virtual bool Up() = 0; virtual bool Down() = 0; @@ -105,13 +105,13 @@ class PPPProtocol : public PPPLayer { ppp_phase fActivationPhase; uint16 fProtocolNumber; int32 fAddressFamily; - PPPInterface& fInterface; + KPPPInterface& fInterface; driver_parameter *fSettings; int32 fFlags; char *fType; - PPPOptionHandler *fOptionHandler; + KPPPOptionHandler *fOptionHandler; - PPPProtocol *fNextProtocol; + KPPPProtocol *fNextProtocol; bool fEnabled; bool fUpRequested; ppp_phase fConnectionPhase; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPReportManager.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPReportManager.h index c60ef4d702..b9ca4603a4 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPReportManager.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPReportManager.h @@ -16,12 +16,13 @@ #include -#define PPP_REPLY(sender, value) send_data_with_timeout((sender), (value), NULL, 0, PPP_REPORT_TIMEOUT) +#define PPP_REPLY(sender, value) \ + send_data_with_timeout((sender), (value), NULL, 0, PPP_REPORT_TIMEOUT) -class PPPReportManager { +class KPPPReportManager { public: - PPPReportManager(BLocker& lock); - ~PPPReportManager(); + KPPPReportManager(BLocker& lock); + ~KPPPReportManager(); void EnableReports(ppp_report_type type, thread_id thread, int32 flags = PPP_NO_FLAGS); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPStateMachine.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPStateMachine.h index 0dbede1309..99881a48e5 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPStateMachine.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPStateMachine.h @@ -10,7 +10,7 @@ #include -class PPPProtocol; +class KPPPProtocol; #ifndef _K_PPP_INTERFACE__H #include @@ -19,24 +19,24 @@ class PPPProtocol; #include -class PPPStateMachine { - friend class PPPInterface; - friend class PPPLCP; +class KPPPStateMachine { friend class PPPManager; + friend class KPPPInterface; + friend class KPPPLCP; private: - // may only be constructed/destructed by PPPInterface - PPPStateMachine(PPPInterface& interface); - ~PPPStateMachine(); + // may only be constructed/destructed by KPPPInterface + KPPPStateMachine(KPPPInterface& interface); + ~KPPPStateMachine(); // copies are not allowed! - PPPStateMachine(const PPPStateMachine& copy); - PPPStateMachine& operator= (const PPPStateMachine& copy); + KPPPStateMachine(const KPPPStateMachine& copy); + KPPPStateMachine& operator= (const KPPPStateMachine& copy); public: - PPPInterface& Interface() const + KPPPInterface& Interface() const { return fInterface; } - PPPLCP& LCP() const + KPPPLCP& LCP() const { return fLCP; } ppp_state State() const @@ -78,14 +78,14 @@ class PPPStateMachine { { return fPeerAuthenticationStatus; } // sub-interface events - void UpFailedEvent(PPPInterface& interface); - void UpEvent(PPPInterface& interface); - void DownEvent(PPPInterface& interface); + void UpFailedEvent(KPPPInterface& interface); + void UpEvent(KPPPInterface& interface); + void DownEvent(KPPPInterface& interface); // protocol events - void UpFailedEvent(PPPProtocol *protocol); - void UpEvent(PPPProtocol *protocol); - void DownEvent(PPPProtocol *protocol); + void UpFailedEvent(KPPPProtocol *protocol); + void UpEvent(KPPPProtocol *protocol); + void DownEvent(KPPPProtocol *protocol); // device events bool TLSNotify(); @@ -144,8 +144,8 @@ class PPPStateMachine { void ResetLCPHandlers(); private: - PPPInterface& fInterface; - PPPLCP& fLCP; + KPPPInterface& fInterface; + KPPPLCP& fLCP; ppp_state fState; ppp_phase fPhase; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPUtils.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPUtils.h index bc0a747867..dc47fc5985 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPUtils.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPUtils.h @@ -14,11 +14,11 @@ #include -class PPPProtocol; +class KPPPProtocol; // helper functions -bool IsProtocolAllowed(const PPPProtocol& protocol); +bool IsProtocolAllowed(const KPPPProtocol& protocol); // the list template does not support iterating over each item :( // this template iterates over each item in an indexed list diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPControl.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPControl.h index e09d3cb228..fac67344d5 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPControl.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPControl.h @@ -29,24 +29,28 @@ #define PPP_USER_OPS_START PPP_OPS_START + 32 * PPP_RESERVE_OPS_COUNT +//! These values should be used for ppp_control_info::op. enum ppp_control_ops { // ----------------------------------------------------- - // PPPManager + // PPPManager (the PPP interface module) PPPC_CREATE_INTERFACE = PPP_OPS_START, + PPPC_CREATE_INTERFACE_WITH_NAME, PPPC_DELETE_INTERFACE, PPPC_BRING_INTERFACE_UP, PPPC_BRING_INTERFACE_DOWN, PPPC_CONTROL_INTERFACE, PPPC_GET_INTERFACES, PPPC_COUNT_INTERFACES, + PPPC_FIND_INTERFACE_WITH_SETTINGS, // ----------------------------------------------------- // ----------------------------------------------------- - // PPPInterface + // KPPPInterface PPPC_GET_INTERFACE_INFO = PPP_INTERFACE_OPS_START, PPPC_SET_MRU, PPPC_SET_DIAL_ON_DEMAND, PPPC_SET_AUTO_REDIAL, + PPPC_HAS_INTERFACE_SETTINGS, // handler access PPPC_CONTROL_DEVICE, @@ -57,12 +61,12 @@ enum ppp_control_ops { // ----------------------------------------------------- // ----------------------------------------------------- - // PPPDevice + // KPPPDevice PPPC_GET_DEVICE_INFO = PPP_DEVICE_OPS_START, // ----------------------------------------------------- // ----------------------------------------------------- - // PPPProtocol + // KPPPProtocol PPPC_GET_PROTOCOL_INFO = PPP_PROTOCOL_OPS_START, // ----------------------------------------------------- @@ -70,7 +74,7 @@ enum ppp_control_ops { // Common/mixed ops PPPC_ENABLE, PPPC_GET_SIMPLE_HANDLER_INFO, - // PPPOptionHandler and PPPLCPExtension + // KPPPOptionHandler and KPPPLCPExtension // these two control ops use the ppp_report_request structure PPPC_ENABLE_REPORTS, @@ -82,29 +86,45 @@ enum ppp_control_ops { }; -typedef struct ppp_interface_settings_info { - const driver_settings *settings; +//! Basic structure used for creating and searching PPP interfaces. +typedef struct ppp_interface_description_info { + union { + const driver_settings *settings; + //!< Interface settings. + const char *name; + //!< Name of interface description file. + } u; + //!< Different values for describing an interface. + const driver_settings *profile; + //!< ppp_interface_id interface; - // only when creating: this is the id of the created interface -} ppp_interface_settings_info; + //!< the found/created interface +} ppp_interface_description_info; +//! Used to get all interface ids from the PPP interface manager. typedef struct ppp_get_interfaces_info { ppp_interface_id *interfaces; + //!< The interface ids will be written to this pointer's target. int32 count; + //!< \a Interface has \a count entries. ppp_interface_filter filter; + //!< Only interfaces that match this filter will be returned int32 resultCount; + //!< The number of saved interfaces. } ppp_get_interfaces_info; +//! With this structure you can refer to some handler/interface. typedef struct ppp_control_info { uint32 index; - // index/id of interface/protocol/etc. + //!< Index/id of interface/protocol/etc. uint32 op; - // the Control()/ioctl() opcode + //!< The Control()/ioctl() opcode. This can be any value from ppp_control_ops. void *data; + //!< Additional data may be specified. size_t length; - // should always be set + //!< The length should always be set. } ppp_control_info; @@ -116,8 +136,7 @@ typedef struct ppp_control_info { #define _PPP_INFO_T_SIZE_ 256 typedef struct ppp_interface_info { - const driver_settings *settings; - + char name[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; int32 if_unit; // negative if not registered @@ -147,7 +166,6 @@ typedef struct ppp_interface_info_t { typedef struct ppp_device_info { char name[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; - const driver_parameter *settings; uint32 MTU; uint32 inputTransferRate, outputTransferRate, outputBytesCount; bool isUp; @@ -162,7 +180,6 @@ typedef struct ppp_protocol_info { char name[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; char type[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; - const driver_parameter *settings; ppp_phase activationPhase; int32 addressFamily, flags; ppp_side side; @@ -189,11 +206,10 @@ typedef struct ppp_protocol_info_t { typedef struct ppp_simple_handler_info { char name[PPP_HANDLER_NAME_LENGTH_LIMIT + 1]; - const driver_parameter *settings; bool isEnabled; uint8 code; - // only PPPLCPExtension + // only KPPPLCPExtension } ppp_simple_handler_info; typedef struct ppp_simple_handler_info_t { ppp_simple_handler_info info; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h index 10073a705e..21d73dc8b6 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h @@ -17,10 +17,15 @@ typedef uint32 ppp_interface_id; // settings keys +#define PPP_DIALING_NOTIFICATION_KEY "DialingNotification" + // userland ppp_server handles this key #define PPP_DISONNECT_AFTER_IDLE_SINCE_KEY "DisonnectAfterIdleSince" #define PPP_MODE_KEY "Mode" +#define PPP_DIAL_RETRIES_LIMIT_KEY "DialRetriesLimit" +#define PPP_DIAL_RETRY_DELAY_KEY "DialRetryDelay" #define PPP_DIAL_ON_DEMAND_KEY "DialOnDemand" #define PPP_AUTO_REDIAL_KEY "AutoRedial" +#define PPP_REDIAL_DELAY_KEY "RedialDelay" #define PPP_LOAD_MODULE_KEY "LoadModule" #define PPP_PROTOCOL_KEY "Protocol" #define PPP_DEVICE_KEY "Device" @@ -33,6 +38,8 @@ typedef uint32 ppp_interface_id; // path defines #define PPP_MODULES_PATH NETWORK_MODULES_ROOT "ppp" +#define PPP_INTERFACE_SETTINGS_PATH "/boot/home/config/settings/kernel/drivers/pppidf" + // should be: /etc/ppp // built-in protocols #define PPP_LCP_PROTOCOL 0xC021 @@ -49,17 +56,17 @@ enum ppp_interface_filter { }; // return values for Send()/Receive() methods in addition to B_ERROR and B_OK -// PPP_UNHANDLED is also used by PPPOptionHandler +// PPP_UNHANDLED is also used by KPPPOptionHandler enum { // B_ERROR means that the packet is corrupted // B_OK means the packet was handled correctly - // return values for PPPProtocol + // return values for KPPPProtocol PPP_UNHANDLED = PPP_ERROR_BASE, // The packet does not belong to this protocol. // Do not delete the packet when you return this! - // return values of PPPInterface::Receive() + // return values of KPPPInterface::Receive() PPP_DISCARDED, // packet was silently discarded PPP_REJECTED, @@ -78,7 +85,7 @@ enum { PPP_FORCE_PFC_REQUEST = 0x04, // if PFC request fails the connection attempt will terminate PPP_FREEZE_PFC_OPTIONS = 0x80 - // the options cannot be changed if this flag is set (mainly used by PPPDevice) + // the options cannot be changed if this flag is set (mainly used by KPPPDevice) }; enum ppp_pfc_state { @@ -124,7 +131,7 @@ enum ppp_phase { enum ppp_level { PPP_DEVICE_LEVEL = 0, PPP_INTERFACE_LEVEL = 1, - // only used by PPPInterface + // only used by KPPPInterface PPP_MULTILINK_LEVEL = 2, PPP_ENCRYPTION_LEVEL = 5, PPP_COMPRESSION_LEVEL = 10, diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.cpp index 75e043720e..73d226252d 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.cpp @@ -14,6 +14,17 @@ #include +static char *sSkipInterfaceParameters[] = { + PPP_DIALING_NOTIFICATION_KEY, + PPP_DISONNECT_AFTER_IDLE_SINCE_KEY, + PPP_DIAL_RETRIES_LIMIT_KEY, + PPP_DIAL_RETRY_DELAY_KEY, + PPP_DIAL_ON_DEMAND_KEY, + PPP_AUTO_REDIAL_KEY, + PPP_REDIAL_DELAY_KEY, + NULL +}; + static void copy_parameter(const driver_parameter *from, driver_parameter *to); static void free_driver_parameter(driver_parameter *parameter); @@ -153,6 +164,53 @@ equal_driver_parameters(const driver_parameter *lhs, const driver_parameter *rhs } +bool +skip_interface_parameter(const driver_parameter *parameter) +{ + if(!parameter || !parameter->name) + return false; + + for(int32 index = 0; sSkipInterfaceParameters[index]; index++) + if(!strcasecmp(parameter->name, sSkipInterfaceParameters[index])) + return true; + + return false; +} + + +bool +equal_interface_settings(const driver_settings *lhs, const driver_settings *rhs) +{ + if(!lhs && !rhs) + return true; + else if(!lhs || !rhs) + return false; + + int32 lhsIndex = 0, rhsIndex = 0; + for(; lhsIndex < lhs->parameter_count; lhsIndex++) { + if(skip_interface_parameter(&lhs->parameters[lhsIndex])) + continue; + + for(; rhsIndex < rhs->parameter_count; rhsIndex++) + if(!skip_interface_parameter(&rhs->parameters[rhsIndex])) + break; + + if(rhsIndex >= rhs->parameter_count) + return false; + + if(!equal_driver_parameters(&lhs->parameters[lhsIndex], + &rhs->parameters[rhsIndex])) + return false; + } + + for(; rhsIndex < rhs->parameter_count; rhsIndex++) + if(!skip_interface_parameter(&rhs->parameters[rhsIndex])) + return false; + + return true; +} + + ppp_side get_side_string_value(const char *sideString, ppp_side unknownValue) { @@ -201,17 +259,27 @@ get_boolean_value(const char *string, bool unknownValue) } -const char* -get_settings_value(const char *name, const driver_settings *settings) +const driver_parameter* +get_parameter_with_name(const char *name, const driver_settings *settings) { if(!name || !settings) return NULL; for(int32 index = 0; index < settings->parameter_count; index++) - if(!strcasecmp(settings->parameters[index].name, name) - && settings->parameters[index].value_count > 0 - && settings->parameters[index].values) - return settings->parameters[index].values[0]; + if(!strcasecmp(settings->parameters[index].name, name)) + return &settings->parameters[index]; + + return NULL; +} + + +const char* +get_settings_value(const char *name, const driver_settings *settings) +{ + const driver_parameter *parameter = get_parameter_with_name(name, settings); + + if(parameter && parameter->value_count > 0 && parameter->values) + return parameter->values[0]; return NULL; } diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.h index e3a5130cb2..028e4a6385 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.h @@ -12,18 +12,30 @@ // TODO: remove this as soon as we get the extended driver_settings API - driver_settings *dup_driver_settings(const driver_settings *settings); void free_driver_settings(driver_settings *settings); bool equal_driver_settings(const driver_settings *lhs, const driver_settings *rhs); bool equal_driver_parameters(const driver_parameter *lhs, const driver_parameter *rhs); +bool equal_interface_settings(const driver_settings *lhs, const driver_settings *rhs); + // this compares only the relevant parts of the interface settings ppp_side get_side_string_value(const char *sideString, ppp_side unknownValue); bool get_boolean_value(const char *string, bool unknownValue); +const driver_parameter *get_parameter_with_name(const char *name, + const driver_settings *settings); const char *get_settings_value(const char *name, const driver_settings *settings); +inline +const driver_parameter* +get_parameter_with_name(const char *name, const driver_parameter *parameters) +{ + return get_parameter_with_name(name, + parameters ? (driver_settings*) ¶meters->parameter_count : NULL); +} + + inline const char* get_parameter_value(const char *name, const driver_parameter *parameters)