1 //----------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 // 5 // Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de 6 //----------------------------------------------------------------------- 7 8 #ifdef _KERNEL_MODE 9 #include <kernel_cpp.h> 10 #endif 11 12 #include <KPPPLayer.h> 13 14 #include <cstdlib> 15 #include <cstring> 16 #include <core_funcs.h> 17 18 19 KPPPLayer::KPPPLayer(const char *name, ppp_level level, uint32 overhead) 20 : fInitStatus(B_OK), 21 fOverhead(overhead), 22 fLevel(level), 23 fNext(NULL) 24 { 25 SetName(name); 26 } 27 28 29 KPPPLayer::~KPPPLayer() 30 { 31 free(fName); 32 } 33 34 35 status_t 36 KPPPLayer::InitCheck() const 37 { 38 return fInitStatus; 39 } 40 41 42 status_t 43 KPPPLayer::SendToNext(struct mbuf *packet, uint16 protocolNumber) const 44 { 45 if(!packet) 46 return B_ERROR; 47 48 // Find the next possible handler for this packet. 49 // Normal protocols (Level() >= PPP_PROTOCOL_LEVEL) do not encapsulate anything. 50 if(Next()) { 51 if(Next()->IsAllowedToSend() && Next()->Level() < PPP_PROTOCOL_LEVEL) 52 return Next()->Send(packet, protocolNumber); 53 else 54 return Next()->SendToNext(packet, protocolNumber); 55 } else { 56 dprintf("KPPPLayer: SendToNext() failed because there is no next handler!\n"); 57 m_freem(packet); 58 return B_ERROR; 59 } 60 } 61 62 63 void 64 KPPPLayer::Pulse() 65 { 66 // do nothing by default 67 } 68 69 70 void 71 KPPPLayer::SetName(const char *name) 72 { 73 free(fName); 74 75 if(name) 76 fName = strdup(name); 77 else 78 fName = strdup("Unknown"); 79 } 80