From 49c2f6870f654194c36d2562ffde3b35903c79f4 Mon Sep 17 00:00:00 2001 From: Waldemar Kornewald Date: Tue, 30 Dec 2003 17:11:09 +0000 Subject: [PATCH] Renamed List.h to TemplateList.h (and the class names accordingly). The name conflicted with List.h from the SupportKit and prevented the DialUpPreflet from building (currently not commited). PPPInterface adds its ID to all reports. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5835 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../network/interfaces/ppp/PPPManager.h | 2 +- .../network/ppp/pppoe/DiscoveryPacket.h | 4 +- .../kernel/network/ppp/pppoe/pppoe.cpp | 4 +- .../ppp/shared/libkernelppp/KPPPInterface.cpp | 6 +- .../shared/libkernelppp/KPPPStateMachine.cpp | 31 ++++---- .../headers/KPPPConfigurePacket.h | 4 +- .../libkernelppp/headers/KPPPInterface.h | 6 +- .../ppp/shared/libkernelppp/headers/KPPPLCP.h | 6 +- .../libkernelppp/headers/KPPPReportManager.h | 4 +- .../libkernelppp/headers/PPPReportDefs.h | 1 + .../headers/{List.h => TemplateList.h} | 74 +++++++++---------- 11 files changed, 73 insertions(+), 69 deletions(-) rename src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/{List.h => TemplateList.h} (78%) diff --git a/src/add-ons/kernel/network/interfaces/ppp/PPPManager.h b/src/add-ons/kernel/network/interfaces/ppp/PPPManager.h index 19c9c32e9f..d83e517dcf 100644 --- a/src/add-ons/kernel/network/interfaces/ppp/PPPManager.h +++ b/src/add-ons/kernel/network/interfaces/ppp/PPPManager.h @@ -67,7 +67,7 @@ class PPPManager { private: BLocker fLock, fReportLock; PPPReportManager fReportManager; - List fEntries; + TemplateList fEntries; interface_id fNextID; thread_id fDeleterThread, fPulseTimer; }; diff --git a/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.h b/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.h index be62de8099..f2b7e4e5bf 100644 --- a/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.h +++ b/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.h @@ -10,7 +10,7 @@ #include "PPPoE.h" -#include +#include enum PPPoE_TAG_TYPE { @@ -74,7 +74,7 @@ class DiscoveryPacket { private: uint8 fCode; uint16 fSessionID; - List fTags; + TemplateList fTags; status_t fInitStatus; }; diff --git a/src/add-ons/kernel/network/ppp/pppoe/pppoe.cpp b/src/add-ons/kernel/network/ppp/pppoe/pppoe.cpp index cd42df6d8e..cd08ca8619 100644 --- a/src/add-ons/kernel/network/ppp/pppoe/pppoe.cpp +++ b/src/add-ons/kernel/network/ppp/pppoe/pppoe.cpp @@ -35,7 +35,7 @@ static int32 sHostUniq = 0; status_t std_ops(int32 op, ...); static BLocker sLock; -static List *sDevices; +static TemplateList *sDevices; uint32 @@ -174,7 +174,7 @@ std_ops(int32 op, ...) return B_ERROR; } - sDevices = new List; + sDevices = new TemplateList; sEthernet->set_pppoe_receiver(pppoe_input); 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 532508f1f5..474bd7a7d5 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp @@ -216,7 +216,7 @@ PPPInterface::~PPPInterface() fLock.Unlock(); } - Report(PPP_DESTRUCTION_REPORT, 0, NULL, 0); + Report(PPP_DESTRUCTION_REPORT, 0, &fID, sizeof(interface_id)); // tell all listeners that we are being destroyed int32 tmp; @@ -1564,7 +1564,9 @@ redial_thread(void *data) // we try to receive data instead of snooze, so we can quit on destruction if(receive_data_with_timeout(&sender, &code, NULL, 0, info.delay) == B_OK) { *info.thread = -1; - info.interface->Report(PPP_CONNECTION_REPORT, PPP_REPORT_UP_ABORTED, NULL, 0); + interface_id id = info.interface->ID(); + info.interface->Report(PPP_CONNECTION_REPORT, PPP_REPORT_UP_ABORTED, + &id, sizeof(interface_id)); return B_OK; } 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 0088036005..94fbe4e14f 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp @@ -119,7 +119,8 @@ PPPStateMachine::NewPhase(ppp_phase next) if(Interface().Ifnet()) Interface().Ifnet()->if_flags |= IFF_UP | IFF_RUNNING; - Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_UP_SUCCESSFUL, NULL, 0); + Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_UP_SUCCESSFUL, + &fInterface.fID, sizeof(interface_id)); } } @@ -245,7 +246,8 @@ PPPStateMachine::LocalAuthenticationAccepted(const char *name) fLocalAuthenticationName = NULL; Interface().Report(PPP_CONNECTION_REPORT, - PPP_REPORT_LOCAL_AUTHENTICATION_SUCCESSFUL, NULL, 0); + PPP_REPORT_LOCAL_AUTHENTICATION_SUCCESSFUL, &fInterface.fID, + sizeof(interface_id)); } @@ -302,7 +304,8 @@ PPPStateMachine::PeerAuthenticationAccepted(const char *name) fPeerAuthenticationName = NULL; Interface().Report(PPP_CONNECTION_REPORT, - PPP_REPORT_PEER_AUTHENTICATION_SUCCESSFUL, NULL, 0); + PPP_REPORT_PEER_AUTHENTICATION_SUCCESSFUL, &fInterface.fID, + sizeof(interface_id)); } @@ -525,19 +528,13 @@ PPPStateMachine::UpFailedEvent() switch(State()) { case PPP_STARTING_STATE: -#if DEBUG - printf("PPPSM::UpFailedEvent(): Reporting...\n"); -#endif Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_DEVICE_UP_FAILED, - NULL, 0); + &fInterface.fID, sizeof(interface_id)); if(Interface().Parent()) Interface().Parent()->StateMachine().UpFailedEvent(Interface()); NewPhase(PPP_DOWN_PHASE); // tell DownEvent() that it should not create a connection-lost-report -#if DEBUG - printf("PPPSM::UpFailedEvent(): Calling DownEvent()\n"); -#endif DownEvent(); break; @@ -676,11 +673,13 @@ PPPStateMachine::DownEvent() if(fLocalAuthenticationStatus == PPP_AUTHENTICATION_FAILED || fLocalAuthenticationStatus == PPP_AUTHENTICATING) Interface().Report(PPP_CONNECTION_REPORT, - PPP_REPORT_LOCAL_AUTHENTICATION_FAILED, NULL, 0); + PPP_REPORT_LOCAL_AUTHENTICATION_FAILED, &fInterface.fID, + sizeof(interface_id)); else if(fPeerAuthenticationStatus == PPP_AUTHENTICATION_FAILED || fPeerAuthenticationStatus == PPP_AUTHENTICATING) Interface().Report(PPP_CONNECTION_REPORT, - PPP_REPORT_PEER_AUTHENTICATION_FAILED, NULL, 0); + PPP_REPORT_PEER_AUTHENTICATION_FAILED, &fInterface.fID, + sizeof(interface_id)); else { // if we are going up and lost connection the redial attempt becomes // a dial retry which is managed by the main thread in Interface::Up() @@ -690,7 +689,7 @@ PPPStateMachine::DownEvent() // test if UpFailedEvent() was not called if(oldPhase != PPP_DOWN_PHASE) Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_CONNECTION_LOST, - NULL, 0); + &fInterface.fID, sizeof(interface_id)); } if(Interface().Parent()) @@ -704,7 +703,8 @@ PPPStateMachine::DownEvent() } else if(!Interface().DoesDialOnDemand()) Interface().Delete(); } else { - Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_DOWN_SUCCESSFUL, NULL, 0); + Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_DOWN_SUCCESSFUL, + &fInterface.fID, sizeof(interface_id)); if(!Interface().DoesDialOnDemand()) Interface().Delete(); @@ -731,7 +731,8 @@ PPPStateMachine::OpenEvent() switch(State()) { case PPP_INITIAL_STATE: - if(!Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_GOING_UP, NULL, 0)) + if(!Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_GOING_UP, + &fInterface.fID, sizeof(interface_id))) return; if(Interface().Mode() == PPP_SERVER_MODE) { 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 935139ce8e..0dddbcfc2c 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 @@ -8,7 +8,7 @@ #ifndef _K_PPP_CONFIGURE_PACKET__H #define _K_PPP_CONFIGURE_PACKET__H -#include +#include struct mbuf; @@ -53,7 +53,7 @@ class PPPConfigurePacket { private: uint8 fCode, fID; - List fItems; + TemplateList fItems; }; 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 5613998d86..864a77612d 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 @@ -22,7 +22,7 @@ #include #endif -#include +#include #include class PPPDevice; @@ -221,7 +221,7 @@ class PPPInterface : public PPPLayer { uint32 fMRU, fInterfaceMTU, fHeaderLength; PPPInterface *fParent; - List fChildren; + TemplateList fChildren; bool fIsMultilink; bool fAutoRedial, fDialOnDemand; @@ -232,7 +232,7 @@ class PPPInterface : public PPPLayer { PPPDevice *fDevice; PPPProtocol *fFirstProtocol; - List fModules; + TemplateList fModules; PPPStateMachine fStateMachine; PPPLCP fLCP; 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 f19322d68a..c74da83ae0 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 @@ -8,7 +8,7 @@ #ifndef _K_PPP_LCP__H #define _K_PPP_LCP__H -#include +#include #ifndef _K_PPP_PROTOCOL__H #include @@ -86,8 +86,8 @@ class PPPLCP : public PPPProtocol { private: PPPStateMachine& fStateMachine; - List fOptionHandlers; - List fLCPExtensions; + TemplateList fOptionHandlers; + TemplateList fLCPExtensions; PPPProtocol *fTarget; }; 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 660c61540a..e336c148cd 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 @@ -13,7 +13,7 @@ #include #include -#include +#include #define PPP_REPLY(sender, value) send_data_with_timeout((sender), (value), NULL, 0, PPP_REPORT_TIMEOUT) @@ -32,7 +32,7 @@ class PPPReportManager { private: BLocker& fLock; - List fReportRequests; + TemplateList fReportRequests; }; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPReportDefs.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPReportDefs.h index 08e9507e21..7fa8e66507 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPReportDefs.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPReportDefs.h @@ -46,6 +46,7 @@ enum ppp_manager_report_codes { enum ppp_connection_report_codes { + // the interface id is added to the following reports PPP_REPORT_GOING_UP = 0, PPP_REPORT_UP_SUCCESSFUL = 1, PPP_REPORT_DOWN_SUCCESSFUL = 2, diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/List.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/TemplateList.h similarity index 78% rename from src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/List.h rename to src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/TemplateList.h index 1bed99e70e..3cfa54c50f 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/List.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/TemplateList.h @@ -1,4 +1,4 @@ -// List.h +// TemplateList.h // // Copyright (c) 2003, Ingo Weinhold (bonefish@cs.tu-berlin.de) // @@ -25,8 +25,8 @@ // dealings in this Software without prior written authorization of the // copyright holder. -#ifndef LIST_H -#define LIST_H +#ifndef TEMPLATE_LIST_H +#define TEMPLATE_LIST_H #ifdef _KERNEL_MODE #include @@ -46,15 +46,15 @@ public: }; /*! - \class List + \class TemplateList \brief A generic list implementation. */ template > -class List { +class TemplateList { public: typedef ITEM item_t; - typedef List list_t; + typedef TemplateList list_t; private: static item_t sDefaultItem; @@ -62,8 +62,8 @@ private: static const size_t kMaximalChunkSize = 1024 * 1024; public: - List(size_t chunkSize = kDefaultChunkSize); - ~List(); + TemplateList(size_t chunkSize = kDefaultChunkSize); + ~TemplateList(); inline const item_t &GetDefaultItem() const; inline item_t &GetDefaultItem(); @@ -106,13 +106,13 @@ private: // sDefaultItem template -List::item_t - List::sDefaultItem( +TemplateList::item_t + TemplateList::sDefaultItem( DEFAULT_ITEM_SUPPLIER::GetItem()); // constructor template -List::List(size_t chunkSize) +TemplateList::TemplateList(size_t chunkSize) : fCapacity(0), fChunkSize(chunkSize), fItemCount(0), @@ -125,7 +125,7 @@ List::List(size_t chunkSize) // destructor template -List::~List() +TemplateList::~TemplateList() { MakeEmpty(); free(fItems); @@ -134,8 +134,8 @@ List::~List() // GetDefaultItem template inline -const List::item_t & -List::GetDefaultItem() const +const TemplateList::item_t & +TemplateList::GetDefaultItem() const { return sDefaultItem; } @@ -143,8 +143,8 @@ List::GetDefaultItem() const // GetDefaultItem template inline -List::item_t & -List::GetDefaultItem() +TemplateList::item_t & +TemplateList::GetDefaultItem() { return sDefaultItem; } @@ -153,7 +153,7 @@ List::GetDefaultItem() template inline void -List::_MoveItems(item_t* items, int32 offset, int32 count) +TemplateList::_MoveItems(item_t* items, int32 offset, int32 count) { if (count > 0 && offset != 0) memmove(items + offset, items, count * sizeof(item_t)); @@ -162,7 +162,7 @@ List::_MoveItems(item_t* items, int32 offset, int32 // AddItem template bool -List::AddItem(const item_t &item, int32 index) +TemplateList::AddItem(const item_t &item, int32 index) { bool result = (index >= 0 && index <= fItemCount && _Resize(fItemCount + 1)); @@ -176,7 +176,7 @@ List::AddItem(const item_t &item, int32 index) // AddItem template bool -List::AddItem(const item_t &item) +TemplateList::AddItem(const item_t &item) { bool result = true; if ((int32)fCapacity > fItemCount) { @@ -194,7 +194,7 @@ List::AddItem(const item_t &item) // AddList template bool -List::AddList(list_t *list, int32 index) +TemplateList::AddList(list_t *list, int32 index) { bool result = (list && index >= 0 && index <= fItemCount); if (result && list->fItemCount > 0) { @@ -212,7 +212,7 @@ List::AddList(list_t *list, int32 index) // AddList template bool -List::AddList(list_t *list) +TemplateList::AddList(list_t *list) { bool result = (list); if (result && list->fItemCount > 0) { @@ -231,7 +231,7 @@ List::AddList(list_t *list) // RemoveItem template bool -List::RemoveItem(const item_t &item) +TemplateList::RemoveItem(const item_t &item) { int32 index = IndexOf(item); bool result = (index >= 0); @@ -243,7 +243,7 @@ List::RemoveItem(const item_t &item) // RemoveItem template bool -List::RemoveItem(int32 index) +TemplateList::RemoveItem(int32 index) { if (index >= 0 && index < fItemCount) { fItems[index].~item_t(); @@ -257,7 +257,7 @@ List::RemoveItem(int32 index) // ReplaceItem template bool -List::ReplaceItem(int32 index, const item_t &item) +TemplateList::ReplaceItem(int32 index, const item_t &item) { if (index >= 0 && index < fItemCount) { fItems[index] = item; @@ -269,7 +269,7 @@ List::ReplaceItem(int32 index, const item_t &item) // MoveItem template bool -List::MoveItem(int32 oldIndex, int32 newIndex) +TemplateList::MoveItem(int32 oldIndex, int32 newIndex) { if (oldIndex >= 0 && oldIndex < fItemCount && newIndex >= 0 && newIndex <= fItemCount) { @@ -290,7 +290,7 @@ List::MoveItem(int32 oldIndex, int32 newIndex) // MakeEmpty template void -List::MakeEmpty() +TemplateList::MakeEmpty() { for (int32 i = 0; i < fItemCount; i++) fItems[i].~item_t(); @@ -300,7 +300,7 @@ List::MakeEmpty() // CountItems template int32 -List::CountItems() const +TemplateList::CountItems() const { return fItemCount; } @@ -308,15 +308,15 @@ List::CountItems() const // IsEmpty template bool -List::IsEmpty() const +TemplateList::IsEmpty() const { return (fItemCount == 0); } // ItemAt template -const List::item_t & -List::ItemAt(int32 index) const +const TemplateList::item_t & +TemplateList::ItemAt(int32 index) const { if (index >= 0 && index < fItemCount) return fItems[index]; @@ -325,8 +325,8 @@ List::ItemAt(int32 index) const // ItemAt template -List::item_t & -List::ItemAt(int32 index) +TemplateList::item_t & +TemplateList::ItemAt(int32 index) { if (index >= 0 && index < fItemCount) return fItems[index]; @@ -335,8 +335,8 @@ List::ItemAt(int32 index) // Items template -const List::item_t * -List::Items() const +const TemplateList::item_t * +TemplateList::Items() const { return fItems; } @@ -344,7 +344,7 @@ List::Items() const // IndexOf template int32 -List::IndexOf(const item_t &item) const +TemplateList::IndexOf(const item_t &item) const { for (int32 i = 0; i < fItemCount; i++) { if (fItems[i] == item) @@ -356,7 +356,7 @@ List::IndexOf(const item_t &item) const // HasItem template bool -List::HasItem(const item_t &item) const +TemplateList::HasItem(const item_t &item) const { return (IndexOf(item) >= 0); } @@ -364,7 +364,7 @@ List::HasItem(const item_t &item) const // _Resize template bool -List::_Resize(size_t count) +TemplateList::_Resize(size_t count) { bool result = true; // calculate the new capacity