1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 // 5 // Copyright (c) 2003 Waldemar Kornewald, Waldemar.Kornewald@web.de 6 //--------------------------------------------------------------------- 7 8 #ifndef _K_PPP_CONFIGURE_PACKET__H 9 #define _K_PPP_CONFIGURE_PACKET__H 10 11 #include <List.h> 12 13 struct mbuf; 14 15 16 typedef struct ppp_configure_item { 17 uint8 type; 18 uint8 length; 19 uint8 data[0]; 20 // the data follows this structure 21 } ppp_configure_item; 22 23 24 class PPPConfigurePacket { 25 private: 26 // copies are not allowed! 27 PPPConfigurePacket(const PPPConfigurePacket& copy); 28 PPPConfigurePacket& operator= (const PPPConfigurePacket& copy); 29 30 public: 31 PPPConfigurePacket(uint8 code); 32 PPPConfigurePacket(struct mbuf *packet); 33 ~PPPConfigurePacket(); 34 35 bool SetCode(uint8 code); 36 uint8 Code() const 37 { return fCode; } 38 39 void SetID(uint8 id) 40 { fID = id; } 41 uint8 ID() const 42 { return fID; } 43 44 bool AddItem(const ppp_configure_item *item, int32 index = -1); 45 bool RemoveItem(ppp_configure_item *item); 46 int32 CountItems() const 47 { return fItems.CountItems(); } 48 ppp_configure_item *ItemAt(int32 index) const; 49 ppp_configure_item *ItemWithType(uint8 type) const; 50 51 struct mbuf *ToMbuf(uint32 MRU, uint32 reserve = 0); 52 // the user is responsible for freeing the mbuf 53 54 private: 55 uint8 fCode, fID; 56 List<ppp_configure_item*> fItems; 57 }; 58 59 60 #endif 61