BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / network / ppp / pppoe / DiscoveryPacket.h
blob6c0416ffe05468ccac474c2d8e582df9e0778718
1 /*
2 * Copyright 2003-2004, Waldemar Kornewald <wkornew@gmx.net>
3 * Distributed under the terms of the MIT License.
4 */
6 #ifndef DISCOVERY_PACKET__H
7 #define DISCOVERY_PACKET__H
9 #include "PPPoE.h"
11 #include <TemplateList.h>
14 enum PPPoE_TAG_TYPE {
15 END_OF_LIST = 0x0000,
16 SERVICE_NAME = 0x0101,
17 AC_NAME = 0x0102,
18 HOST_UNIQ = 0x0103,
19 AC_COOKIE = 0x0104,
20 VENDOR_SPECIFIC = 0x0105,
21 RELAY_SESSION_ID = 0x0110,
22 SERVICE_NAME_ERROR = 0x0201,
23 AC_SYSTEM_ERROR = 0x0202,
24 GENERIC_ERROR = 0x0203
27 enum PPPoE_CODE {
28 PADI = 0x09,
29 PADO = 0x07,
30 PADR = 0x19,
31 PADS = 0x65,
32 PADT = 0xA7
36 typedef struct pppoe_tag {
37 uint16 type;
38 uint16 length;
39 uint8 data[0];
43 class DiscoveryPacket {
44 public:
45 DiscoveryPacket(uint8 code, uint16 sessionID = 0x0000);
46 DiscoveryPacket(struct mbuf *packet, uint32 start = 0);
47 ~DiscoveryPacket();
49 status_t InitCheck() const
50 { return fInitStatus; }
52 void SetCode(uint8 code)
53 { fCode = code; }
54 uint8 Code() const
55 { return fCode; }
57 void SetSessionID(uint16 sessionID)
58 { fSessionID = sessionID; }
59 uint16 SessionID() const
60 { return fSessionID; }
62 bool AddTag(uint16 type, const void *data, uint16 length, int32 index = -1);
63 bool RemoveTag(pppoe_tag *tag);
64 int32 CountTags() const
65 { return fTags.CountItems(); }
66 pppoe_tag *TagAt(int32 index) const;
67 pppoe_tag *TagWithType(uint16 type) const;
69 struct mbuf *ToMbuf(uint32 MTU, uint32 reserve = ETHER_HDR_LEN);
70 // the user is responsible for freeing the mbuf
72 private:
73 uint8 fCode;
74 uint16 fSessionID;
75 TemplateList<pppoe_tag*> fTags;
76 status_t fInitStatus;
80 #endif