2 * Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
3 * Distributed under the terms of the MIT License.
6 #ifndef DISCOVERY_PACKET__H
7 #define DISCOVERY_PACKET__H
11 #include <TemplateList.h>
13 #define ETHER_HDR_LEN 14
17 SERVICE_NAME
= 0x0101,
21 VENDOR_SPECIFIC
= 0x0105,
22 RELAY_SESSION_ID
= 0x0110,
23 SERVICE_NAME_ERROR
= 0x0201,
24 AC_SYSTEM_ERROR
= 0x0202,
25 GENERIC_ERROR
= 0x0203
37 typedef struct pppoe_tag
{
44 class DiscoveryPacket
{
46 DiscoveryPacket(uint8 code
, uint16 sessionID
= 0x0000);
47 DiscoveryPacket(net_buffer
*packet
, uint32 start
= 0);
50 status_t
InitCheck() const
51 { return fInitStatus
; }
53 void SetCode(uint8 code
)
58 void SetSessionID(uint16 sessionID
)
59 { fSessionID
= sessionID
; }
60 uint16
SessionID() const
61 { return fSessionID
; }
63 bool AddTag(uint16 type
, const void *data
, uint16 length
, int32 index
= -1);
64 bool RemoveTag(pppoe_tag
*tag
);
65 int32
CountTags() const
66 { return fTags
.CountItems(); }
67 pppoe_tag
*TagAt(int32 index
) const;
68 pppoe_tag
*TagWithType(uint16 type
) const;
70 net_buffer
*ToNetBuffer(uint32 MTU
);
71 // the user is responsible for freeing the net_buffer
76 TemplateList
<pppoe_tag
*> fTags
;