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
This commit is contained in:
Waldemar Kornewald 2003-12-30 17:11:09 +00:00
parent f6d062bb86
commit 49c2f6870f
11 changed files with 73 additions and 69 deletions

View File

@ -67,7 +67,7 @@ class PPPManager {
private:
BLocker fLock, fReportLock;
PPPReportManager fReportManager;
List<ppp_interface_entry*> fEntries;
TemplateList<ppp_interface_entry*> fEntries;
interface_id fNextID;
thread_id fDeleterThread, fPulseTimer;
};

View File

@ -10,7 +10,7 @@
#include "PPPoE.h"
#include <List.h>
#include <TemplateList.h>
enum PPPoE_TAG_TYPE {
@ -74,7 +74,7 @@ class DiscoveryPacket {
private:
uint8 fCode;
uint16 fSessionID;
List<pppoe_tag*> fTags;
TemplateList<pppoe_tag*> fTags;
status_t fInitStatus;
};

View File

@ -35,7 +35,7 @@ static int32 sHostUniq = 0;
status_t std_ops(int32 op, ...);
static BLocker sLock;
static List<PPPoEDevice*> *sDevices;
static TemplateList<PPPoEDevice*> *sDevices;
uint32
@ -174,7 +174,7 @@ std_ops(int32 op, ...)
return B_ERROR;
}
sDevices = new List<PPPoEDevice*>;
sDevices = new TemplateList<PPPoEDevice*>;
sEthernet->set_pppoe_receiver(pppoe_input);

View File

@ -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;
}

View File

@ -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) {

View File

@ -8,7 +8,7 @@
#ifndef _K_PPP_CONFIGURE_PACKET__H
#define _K_PPP_CONFIGURE_PACKET__H
#include <List.h>
#include <TemplateList.h>
struct mbuf;
@ -53,7 +53,7 @@ class PPPConfigurePacket {
private:
uint8 fCode, fID;
List<ppp_configure_item*> fItems;
TemplateList<ppp_configure_item*> fItems;
};

View File

@ -22,7 +22,7 @@
#include <KPPPStateMachine.h>
#endif
#include <List.h>
#include <TemplateList.h>
#include <LockerHelper.h>
class PPPDevice;
@ -221,7 +221,7 @@ class PPPInterface : public PPPLayer {
uint32 fMRU, fInterfaceMTU, fHeaderLength;
PPPInterface *fParent;
List<PPPInterface*> fChildren;
TemplateList<PPPInterface*> fChildren;
bool fIsMultilink;
bool fAutoRedial, fDialOnDemand;
@ -232,7 +232,7 @@ class PPPInterface : public PPPLayer {
PPPDevice *fDevice;
PPPProtocol *fFirstProtocol;
List<char*> fModules;
TemplateList<char*> fModules;
PPPStateMachine fStateMachine;
PPPLCP fLCP;

View File

@ -8,7 +8,7 @@
#ifndef _K_PPP_LCP__H
#define _K_PPP_LCP__H
#include <List.h>
#include <TemplateList.h>
#ifndef _K_PPP_PROTOCOL__H
#include <KPPPProtocol.h>
@ -86,8 +86,8 @@ class PPPLCP : public PPPProtocol {
private:
PPPStateMachine& fStateMachine;
List<PPPOptionHandler*> fOptionHandlers;
List<PPPLCPExtension*> fLCPExtensions;
TemplateList<PPPOptionHandler*> fOptionHandlers;
TemplateList<PPPLCPExtension*> fLCPExtensions;
PPPProtocol *fTarget;
};

View File

@ -13,7 +13,7 @@
#include <KPPPDefs.h>
#include <PPPReportDefs.h>
#include <List.h>
#include <TemplateList.h>
#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<ppp_report_request*> fReportRequests;
TemplateList<ppp_report_request*> fReportRequests;
};

View File

@ -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,

View File

@ -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 <kernel_cpp.h>
@ -46,15 +46,15 @@ public:
};
/*!
\class List
\class TemplateList
\brief A generic list implementation.
*/
template<typename ITEM,
typename DEFAULT_ITEM_SUPPLIER = DefaultDefaultItemCreator<ITEM> >
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<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
List<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t
List<ITEM, DEFAULT_ITEM_SUPPLIER>::sDefaultItem(
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::sDefaultItem(
DEFAULT_ITEM_SUPPLIER::GetItem());
// constructor
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
List<ITEM, DEFAULT_ITEM_SUPPLIER>::List(size_t chunkSize)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::TemplateList(size_t chunkSize)
: fCapacity(0),
fChunkSize(chunkSize),
fItemCount(0),
@ -125,7 +125,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::List(size_t chunkSize)
// destructor
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
List<ITEM, DEFAULT_ITEM_SUPPLIER>::~List()
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::~TemplateList()
{
MakeEmpty();
free(fItems);
@ -134,8 +134,8 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::~List()
// GetDefaultItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
inline
const List<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t &
List<ITEM, DEFAULT_ITEM_SUPPLIER>::GetDefaultItem() const
const TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t &
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::GetDefaultItem() const
{
return sDefaultItem;
}
@ -143,8 +143,8 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::GetDefaultItem() const
// GetDefaultItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
inline
List<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t &
List<ITEM, DEFAULT_ITEM_SUPPLIER>::GetDefaultItem()
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t &
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::GetDefaultItem()
{
return sDefaultItem;
}
@ -153,7 +153,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::GetDefaultItem()
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
inline
void
List<ITEM, DEFAULT_ITEM_SUPPLIER>::_MoveItems(item_t* items, int32 offset, int32 count)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::_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<ITEM, DEFAULT_ITEM_SUPPLIER>::_MoveItems(item_t* items, int32 offset, int32
// AddItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::AddItem(const item_t &item, int32 index)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::AddItem(const item_t &item, int32 index)
{
bool result = (index >= 0 && index <= fItemCount
&& _Resize(fItemCount + 1));
@ -176,7 +176,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::AddItem(const item_t &item, int32 index)
// AddItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::AddItem(const item_t &item)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::AddItem(const item_t &item)
{
bool result = true;
if ((int32)fCapacity > fItemCount) {
@ -194,7 +194,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::AddItem(const item_t &item)
// AddList
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::AddList(list_t *list, int32 index)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::AddList(list_t *list, int32 index)
{
bool result = (list && index >= 0 && index <= fItemCount);
if (result && list->fItemCount > 0) {
@ -212,7 +212,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::AddList(list_t *list, int32 index)
// AddList
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::AddList(list_t *list)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::AddList(list_t *list)
{
bool result = (list);
if (result && list->fItemCount > 0) {
@ -231,7 +231,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::AddList(list_t *list)
// RemoveItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::RemoveItem(const item_t &item)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::RemoveItem(const item_t &item)
{
int32 index = IndexOf(item);
bool result = (index >= 0);
@ -243,7 +243,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::RemoveItem(const item_t &item)
// RemoveItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::RemoveItem(int32 index)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::RemoveItem(int32 index)
{
if (index >= 0 && index < fItemCount) {
fItems[index].~item_t();
@ -257,7 +257,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::RemoveItem(int32 index)
// ReplaceItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::ReplaceItem(int32 index, const item_t &item)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::ReplaceItem(int32 index, const item_t &item)
{
if (index >= 0 && index < fItemCount) {
fItems[index] = item;
@ -269,7 +269,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::ReplaceItem(int32 index, const item_t &item)
// MoveItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::MoveItem(int32 oldIndex, int32 newIndex)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::MoveItem(int32 oldIndex, int32 newIndex)
{
if (oldIndex >= 0 && oldIndex < fItemCount
&& newIndex >= 0 && newIndex <= fItemCount) {
@ -290,7 +290,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::MoveItem(int32 oldIndex, int32 newIndex)
// MakeEmpty
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
void
List<ITEM, DEFAULT_ITEM_SUPPLIER>::MakeEmpty()
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::MakeEmpty()
{
for (int32 i = 0; i < fItemCount; i++)
fItems[i].~item_t();
@ -300,7 +300,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::MakeEmpty()
// CountItems
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
int32
List<ITEM, DEFAULT_ITEM_SUPPLIER>::CountItems() const
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::CountItems() const
{
return fItemCount;
}
@ -308,15 +308,15 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::CountItems() const
// IsEmpty
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::IsEmpty() const
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::IsEmpty() const
{
return (fItemCount == 0);
}
// ItemAt
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
const List<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t &
List<ITEM, DEFAULT_ITEM_SUPPLIER>::ItemAt(int32 index) const
const TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t &
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::ItemAt(int32 index) const
{
if (index >= 0 && index < fItemCount)
return fItems[index];
@ -325,8 +325,8 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::ItemAt(int32 index) const
// ItemAt
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
List<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t &
List<ITEM, DEFAULT_ITEM_SUPPLIER>::ItemAt(int32 index)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t &
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::ItemAt(int32 index)
{
if (index >= 0 && index < fItemCount)
return fItems[index];
@ -335,8 +335,8 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::ItemAt(int32 index)
// Items
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
const List<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t *
List<ITEM, DEFAULT_ITEM_SUPPLIER>::Items() const
const TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::item_t *
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::Items() const
{
return fItems;
}
@ -344,7 +344,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::Items() const
// IndexOf
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
int32
List<ITEM, DEFAULT_ITEM_SUPPLIER>::IndexOf(const item_t &item) const
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::IndexOf(const item_t &item) const
{
for (int32 i = 0; i < fItemCount; i++) {
if (fItems[i] == item)
@ -356,7 +356,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::IndexOf(const item_t &item) const
// HasItem
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::HasItem(const item_t &item) const
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::HasItem(const item_t &item) const
{
return (IndexOf(item) >= 0);
}
@ -364,7 +364,7 @@ List<ITEM, DEFAULT_ITEM_SUPPLIER>::HasItem(const item_t &item) const
// _Resize
template<typename ITEM, typename DEFAULT_ITEM_SUPPLIER>
bool
List<ITEM, DEFAULT_ITEM_SUPPLIER>::_Resize(size_t count)
TemplateList<ITEM, DEFAULT_ITEM_SUPPLIER>::_Resize(size_t count)
{
bool result = true;
// calculate the new capacity