diff --git a/src/add-ons/kernel/network/interfaces/ppp/PPPManager.cpp b/src/add-ons/kernel/network/interfaces/ppp/PPPManager.cpp index c5fc4da088..035df5c8ff 100644 --- a/src/add-ons/kernel/network/interfaces/ppp/PPPManager.cpp +++ b/src/add-ons/kernel/network/interfaces/ppp/PPPManager.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include @@ -110,12 +108,12 @@ pulse_timer(void *data) PPPManager::PPPManager() - : fReportManager(fReportLock), + : fLock("PPPManager"), + fReportLock("PPPManagerReportLock"), + fReportManager(fReportLock), fNextID(1) { -#if DEBUG - dprintf("PPPManager: Constructor\n"); -#endif + TRACE("PPPManager: Constructor\n"); fDeleterThread = spawn_kernel_thread(deleter_thread, "PPPManager: deleter_thread", B_NORMAL_PRIORITY, this); @@ -126,9 +124,7 @@ PPPManager::PPPManager() PPPManager::~PPPManager() { -#if DEBUG - dprintf("PPPManager: Destructor\n"); -#endif + TRACE("PPPManager: Destructor\n"); int32 tmp; send_data(fDeleterThread, 0, NULL, 0); @@ -140,9 +136,11 @@ PPPManager::~PPPManager() ppp_interface_entry *entry; for(int32 index = 0; index < fEntries.CountItems(); index++) { entry = fEntries.ItemAt(index); - if(entry) + if(entry) { + free(entry->name); delete entry->interface; - delete entry; + delete entry; + } } } @@ -150,15 +148,13 @@ PPPManager::~PPPManager() int32 PPPManager::Stop(ifnet *ifp) { -#if DEBUG - dprintf("PPPManager: Stop(%s)\n", ifp ? ifp->if_name : "Unknown"); -#endif + TRACE("PPPManager: Stop(%s)\n", ifp ? ifp->if_name : "Unknown"); LockerHelper locker(fLock); ppp_interface_entry *entry = EntryFor(ifp); if(!entry) { - dprintf("PPPManager: Stop(): Could not find interface!\n"); + ERROR("PPPManager: Stop(): Could not find interface!\n"); return B_ERROR; } @@ -172,9 +168,7 @@ int32 PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst, struct rtentry *rt0) { -#if DEBUG - dprintf("PPPManager: Output(%s)\n", ifp ? ifp->if_name : "Unknown"); -#endif + TRACE("PPPManager: Output(%s)\n", ifp ? ifp->if_name : "Unknown"); if(dst->sa_family == AF_UNSPEC) return B_ERROR; @@ -182,7 +176,7 @@ PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst, LockerHelper locker(fLock); ppp_interface_entry *entry = EntryFor(ifp); if(!entry) { - dprintf("PPPManager: Output(): Could not find interface!\n"); + ERROR("PPPManager: Output(): Could not find interface!\n"); return B_ERROR; } @@ -222,14 +216,12 @@ PPPManager::Output(ifnet *ifp, struct mbuf *buf, struct sockaddr *dst, int32 PPPManager::Control(ifnet *ifp, ulong cmd, caddr_t data) { -#if DEBUG - dprintf("PPPManager: Control(%s)\n", ifp ? ifp->if_name : "Unknown"); -#endif + TRACE("PPPManager: Control(%s)\n", ifp ? ifp->if_name : "Unknown"); LockerHelper locker(fLock); ppp_interface_entry *entry = EntryFor(ifp); if(!entry || entry->deleting) { - dprintf("PPPManager: Control(): Could not find interface!\n"); + ERROR("PPPManager: Control(): Could not find interface!\n"); return B_ERROR; } @@ -284,9 +276,7 @@ PPPManager::CreateInterfaceWithName(const char *name, bool PPPManager::DeleteInterface(ppp_interface_id ID) { -#if DEBUG - dprintf("PPPManager: DeleteInterface(%ld)\n", ID); -#endif + TRACE("PPPManager: DeleteInterface(%ld)\n", ID); // This only marks the interface for deletion. // Our deleter_thread does the real work. @@ -318,9 +308,7 @@ PPPManager::DeleteInterface(ppp_interface_id ID) bool PPPManager::RemoveInterface(ppp_interface_id ID) { -#if DEBUG - dprintf("PPPManager: RemoveInterface(%ld)\n", ID); -#endif + TRACE("PPPManager: RemoveInterface(%ld)\n", ID); LockerHelper locker(fLock); @@ -341,9 +329,7 @@ PPPManager::RemoveInterface(ppp_interface_id ID) ifnet* PPPManager::RegisterInterface(ppp_interface_id ID) { -#if DEBUG - dprintf("PPPManager: RegisterInterface(%ld)\n", ID); -#endif + TRACE("PPPManager: RegisterInterface(%ld)\n", ID); LockerHelper locker(fLock); @@ -355,6 +341,8 @@ PPPManager::RegisterInterface(ppp_interface_id ID) if(entry->interface->Ifnet()) return entry->interface->Ifnet(); + // TODO: allocate struct around ifnet with pointer to entry so we can optimize + // ifnet->ppp_interface_entry translation (speeds-up Output()/Input()) ifnet *ifp = (ifnet*) malloc(sizeof(ifnet)); memset(ifp, 0, sizeof(ifnet)); ifp->devid = -1; @@ -368,10 +356,8 @@ PPPManager::RegisterInterface(ppp_interface_id ID) ifp->output = ppp_ifnet_output; ifp->ioctl = ppp_ifnet_ioctl; -#if DEBUG - dprintf("PPPManager::RegisterInterface(): Created new ifnet: %s%d\n", + TRACE("PPPManager::RegisterInterface(): Created new ifnet: %s%d\n", ifp->name, ifp->if_unit); -#endif if_attach(ifp); return ifp; @@ -381,9 +367,7 @@ PPPManager::RegisterInterface(ppp_interface_id ID) bool PPPManager::UnregisterInterface(ppp_interface_id ID) { -#if DEBUG - dprintf("PPPManager: UnregisterInterface(%ld)\n", ID); -#endif + TRACE("PPPManager: UnregisterInterface(%ld)\n", ID); LockerHelper locker(fLock); @@ -403,9 +387,7 @@ PPPManager::UnregisterInterface(ppp_interface_id ID) status_t PPPManager::Control(uint32 op, void *data, size_t length) { -#if DEBUG - dprintf("PPPManager: Control(%ld)\n", op); -#endif + TRACE("PPPManager: Control(%ld)\n", op); // this method is intended for use by userland applications @@ -574,9 +556,7 @@ PPPManager::Control(uint32 op, void *data, size_t length) status_t PPPManager::ControlInterface(ppp_interface_id ID, uint32 op, void *data, size_t length) { -#if DEBUG - dprintf("PPPManager: ControlInterface(%ld)\n", ID); -#endif + TRACE("PPPManager: ControlInterface(%ld)\n", ID); LockerHelper locker(fLock); @@ -597,9 +577,7 @@ int32 PPPManager::GetInterfaces(ppp_interface_id *interfaces, int32 count, ppp_interface_filter filter = PPP_REGISTERED_INTERFACES) { -#if DEBUG - dprintf("PPPManager: GetInterfaces()\n"); -#endif + TRACE("PPPManager: GetInterfaces()\n"); LockerHelper locker(fLock); @@ -640,9 +618,7 @@ PPPManager::GetInterfaces(ppp_interface_id *interfaces, int32 count, int32 PPPManager::CountInterfaces(ppp_interface_filter filter = PPP_REGISTERED_INTERFACES) { -#if DEBUG - dprintf("PPPManager: CountInterfaces()\n"); -#endif + TRACE("PPPManager: CountInterfaces()\n"); LockerHelper locker(fLock); @@ -681,9 +657,7 @@ PPPManager::CountInterfaces(ppp_interface_filter filter = PPP_REGISTERED_INTERFA ppp_interface_entry* PPPManager::EntryFor(ppp_interface_id ID, int32 *saveIndex = NULL) const { -#if DEBUG - dprintf("PPPManager: EntryFor(%ld)\n", ID); -#endif + TRACE("PPPManager: EntryFor(%ld)\n", ID); if(ID == PPP_UNDEFINED_INTERFACE_ID) return NULL; @@ -691,7 +665,7 @@ PPPManager::EntryFor(ppp_interface_id ID, int32 *saveIndex = NULL) const ppp_interface_entry *entry; for(int32 index = 0; index < fEntries.CountItems(); index++) { entry = fEntries.ItemAt(index); - if(entry && entry->interface->ID() == ID) { + if(entry && entry->interface && entry->interface->ID() == ID) { if(saveIndex) *saveIndex = index; return entry; @@ -708,14 +682,34 @@ PPPManager::EntryFor(ifnet *ifp, int32 *saveIndex = NULL) const if(!ifp) return NULL; -#if DEBUG - dprintf("PPPManager: EntryFor(%s%d)\n", ifp->name, ifp->if_unit); -#endif + TRACE("PPPManager: EntryFor(%s%d)\n", ifp->name, ifp->if_unit); ppp_interface_entry *entry; for(int32 index = 0; index < fEntries.CountItems(); index++) { entry = fEntries.ItemAt(index); - if(entry && entry->interface->Ifnet() == ifp) { + if(entry && entry->interface && entry->interface->Ifnet() == ifp) { + if(saveIndex) + *saveIndex = index; + return entry; + } + } + + return NULL; +} + + +ppp_interface_entry* +PPPManager::EntryFor(const char *name, int32 *saveIndex = NULL) const +{ + if(!name) + return NULL; + + TRACE("PPPManager: EntryFor(%s)\n", name); + + ppp_interface_entry *entry; + for(int32 index = 0; index < fEntries.CountItems(); index++) { + entry = fEntries.ItemAt(index); + if(entry && entry->name && !strcmp(entry->name, name)) { if(saveIndex) *saveIndex = index; return entry; @@ -732,14 +726,13 @@ PPPManager::EntryFor(const driver_settings *settings) const if(!settings) return NULL; -#if DEBUG - dprintf("PPPManager: EntryFor(settings)\n"); -#endif + TRACE("PPPManager: EntryFor(settings)\n"); ppp_interface_entry *entry; for(int32 index = 0; index < fEntries.CountItems(); index++) { entry = fEntries.ItemAt(index); - if(entry && equal_interface_settings(entry->interface->Settings(), settings)) + if(entry && entry->interface + && equal_interface_settings(entry->interface->Settings(), settings)) return entry; } @@ -760,9 +753,7 @@ ppp_interface_id PPPManager::_CreateInterface(const char *name, const driver_settings *settings, const driver_settings *profile, ppp_interface_id parentID) { -#if DEBUG - dprintf("PPPManager: CreateInterface(%s)\n", name ? name : "Unnamed"); -#endif + TRACE("PPPManager: CreateInterface(%s)\n", name ? name : "Unnamed"); LockerHelper locker(fLock); @@ -775,21 +766,81 @@ PPPManager::_CreateInterface(const char *name, const driver_settings *settings, if(id == PPP_UNDEFINED_INTERFACE_ID) id = NextID(); - ppp_interface_entry *entry = new ppp_interface_entry; - entry->accessing = 1; + // check if we already have an entry for the named interface + ppp_interface_entry *entry = EntryFor(name); + if(entry) { + if(entry->interface) + return entry->interface->ID(); + // already existing interfaces do not need a PPP team + + ++entry->accessing; + + thread_info info; + if(get_thread_info(entry->requestThread, &info) != B_OK) + entry->requestThread = -1; + else { + // test if app is responsive (i.e.: it reacts in at most 0.5secs) + thread_id sender; + int32 code; + if(send_data_with_timeout(entry->requestThread, PPP_RESPONSE_TEST_CODE, + NULL, 0, PPP_REPORT_TIMEOUT) != B_OK + || receive_data_with_timeout(&sender, &code, NULL, 0, 500) + != B_OK || code != B_OK) { + entry->requestThread = -1; + kill_team(info.team); + } + } + } else { + entry = new ppp_interface_entry; + entry->name = name ? strdup(name) : NULL; + entry->accessing = 1; + entry->requestThread = -1; + fEntries.AddItem(entry); + // nothing bad can happen because we are in a locked section + } + entry->deleting = false; - fEntries.AddItem(entry); - // nothing bad can happen because we are in a locked section new KPPPInterface(name, entry, id, settings, profile, parentEntry ? parentEntry->interface : NULL); // KPPPInterface will add itself to the entry (no need to do it here) if(entry->interface->InitCheck() != B_OK) { + // use safe code because entry might have existed before this method call + --entry->accessing; + entry->deleting = true; + if(entry->accessing > 0) + return PPP_UNDEFINED_INTERFACE_ID; + + free(entry->name); delete entry->interface; + fEntries.RemoveItem(entry); delete entry; return PPP_UNDEFINED_INTERFACE_ID; } + // run ppp_up and enable reports for the request window (DONE?) + if(entry->requestThread < 0 && name) { + const char *argv[] = { "/boot/beos/bin/ppp_up", name, NULL }; + const char *env[] = { NULL }; + thread_id app = load_image(2, argv, env); + if(app < 0) + ERROR("KPPPInterface::Up(): Error: could not load ppp_up!\n"); + resume_thread(app); + + // XXX: What? BeOS' kernel is so &$$ยง$%! I cannot send anything to the + // team's main thread before the kernel sent something to it. So, we wait... + snooze(150000); + + if(send_data(app, 0, &id, sizeof(id)) < B_OK) + ERROR("KPPPInterface::Up(): Error: could not send to ppp_up!\n"); + + // register the request thread as a report receiver + receive_data(&entry->requestThread, NULL, 0); + } + if(entry->requestThread >= 0) + entry->interface->ReportManager().EnableReports(PPP_CONNECTION_REPORT, + entry->requestThread, PPP_WAIT_FOR_REPLY | PPP_NO_REPLY_TIMEOUT); + locker.UnlockNow(); // it is safe to access the manager from userland now @@ -819,7 +870,7 @@ PPPManager::FindUnit() const ppp_interface_entry *entry; for(int32 index = 0; index < fEntries.CountItems(); index++) { entry = fEntries.ItemAt(index); - if(entry && entry->interface->Ifnet()) + if(entry && entry->interface && entry->interface->Ifnet()) units[index] = entry->interface->Ifnet()->if_unit; else units[index] = -1; @@ -855,6 +906,14 @@ PPPManager::DeleterThreadEvent() } if(entry->deleting && entry->accessing <= 0) { + // only remove entries that do not have ppp_up associated with them + if(entry->requestThread >= 0) { + thread_info info; + if(get_thread_info(entry->requestThread, &info) == B_OK) + continue; + } + + free(entry->name); delete entry->interface; delete entry; fEntries.RemoveItem(index); @@ -872,7 +931,7 @@ PPPManager::Pulse() ppp_interface_entry *entry; for(int32 index = 0; index < fEntries.CountItems(); index++) { entry = fEntries.ItemAt(index); - if(entry) + if(entry && entry->interface) entry->interface->Pulse(); } } diff --git a/src/add-ons/kernel/network/interfaces/ppp/PPPManager.h b/src/add-ons/kernel/network/interfaces/ppp/PPPManager.h index 4cfdb25b8b..5874192697 100644 --- a/src/add-ons/kernel/network/interfaces/ppp/PPPManager.h +++ b/src/add-ons/kernel/network/interfaces/ppp/PPPManager.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef _PPP_MANAGER__H #define _PPP_MANAGER__H @@ -59,6 +57,7 @@ class PPPManager { ppp_interface_entry *EntryFor(ppp_interface_id ID, int32 *saveIndex = NULL) const; ppp_interface_entry *EntryFor(ifnet *ifp, int32 *saveIndex = NULL) const; + ppp_interface_entry *EntryFor(const char *name, int32 *saveIndex = NULL) const; ppp_interface_entry *EntryFor(const driver_settings *settings) const; ppp_interface_id NextID() diff --git a/src/add-ons/kernel/network/interfaces/ppp/ppp.cpp b/src/add-ons/kernel/network/interfaces/ppp/ppp.cpp index 851806885c..83f7f9c363 100644 --- a/src/add-ons/kernel/network/interfaces/ppp/ppp.cpp +++ b/src/add-ons/kernel/network/interfaces/ppp/ppp.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include #include diff --git a/src/add-ons/kernel/network/ppp/TODO b/src/add-ons/kernel/network/ppp/TODO index 6692dde934..9d4ddd39ea 100644 --- a/src/add-ons/kernel/network/ppp/TODO +++ b/src/add-ons/kernel/network/ppp/TODO @@ -1,3 +1,4 @@ - add CHAP - add ISDN (CAPI) - add PPTP (this is a virtual device that uses TCP/IP to connect to some other PPP server on the net) +- add L2TP (this is a virtual device that uses TCP/IP to connect to some other PPP server on the net) diff --git a/src/add-ons/kernel/network/ppp/ipcp/IPCP.h b/src/add-ons/kernel/network/ppp/ipcp/IPCP.h index 71685db80d..71a59379b0 100644 --- a/src/add-ons/kernel/network/ppp/ipcp/IPCP.h +++ b/src/add-ons/kernel/network/ppp/ipcp/IPCP.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef IPCP__H #define IPCP__H diff --git a/src/add-ons/kernel/network/ppp/ipcp/Protocol.cpp b/src/add-ons/kernel/network/ppp/ipcp/Protocol.cpp index b8b0073be5..fab2b9870b 100644 --- a/src/add-ons/kernel/network/ppp/ipcp/Protocol.cpp +++ b/src/add-ons/kernel/network/ppp/ipcp/Protocol.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #if DEBUG #include @@ -74,7 +72,8 @@ IPCP::IPCP(KPPPInterface& interface, driver_parameter *settings) fMaxNak(5), fRequestID(0), fTerminateID(0), - fNextTimeout(0) + fNextTimeout(0), + fLock("IPCP") { ProfileChanged(); @@ -102,9 +101,7 @@ IPCP::Uninit() status_t IPCP::StackControl(uint32 op, void *data) { -#if DEBUG - dprintf("IPCP: StackControl(op=%ld)\n", op); -#endif + TRACE("IPCP: StackControl(op=%ld)\n", op); // TODO: // check values @@ -123,7 +120,7 @@ IPCP::StackControl(uint32 op, void *data) break; default: - dprintf("IPCP: Unknown ioctl: %ld\n", op); + ERROR("IPCP: Unknown ioctl: %ld\n", op); return KPPPProtocol::StackControl(op, data); } @@ -156,9 +153,7 @@ IPCP::ProfileChanged() bool IPCP::Up() { -#if DEBUG - dprintf("IPCP: Up() state=%d\n", State()); -#endif + TRACE("IPCP: Up() state=%d\n", State()); // Servers do not send a configure-request when Up() is called. They wait until // the client requests this protocol. @@ -186,9 +181,7 @@ IPCP::Up() bool IPCP::Down() { -#if DEBUG - dprintf("IPCP: Down() state=%d\n", State()); -#endif + TRACE("IPCP: Down() state=%d\n", State()); LockerHelper locker(fLock); @@ -233,9 +226,7 @@ IPCP::Down() status_t IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL) { -#if DEBUG - dprintf("IPCP: Send(0x%X)\n", protocolNumber); -#endif + TRACE("IPCP: Send(0x%X)\n", protocolNumber); if((protocolNumber == IP_PROTOCOL && State() == PPP_OPENED_STATE) || protocolNumber == IPCP_PROTOCOL) { @@ -246,7 +237,7 @@ IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL) return SendToNext(packet, protocolNumber); } - dprintf("IPCP: Send() failed because of wrong state or protocol number!\n"); + ERROR("IPCP: Send() failed because of wrong state or protocol number!\n"); m_freem(packet); return B_ERROR; @@ -256,9 +247,7 @@ IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL) status_t IPCP::Receive(struct mbuf *packet, uint16 protocolNumber) { -#if DEBUG - dprintf("IPCP: Receive(0x%X)\n", protocolNumber); -#endif + TRACE("IPCP: Receive(0x%X)\n", protocolNumber); if(!packet) return B_ERROR; @@ -335,7 +324,7 @@ IPCP::ReceiveIPPacket(struct mbuf *packet, uint16 protocolNumber) gProto[IPPROTO_IP]->pr_input(packet, 0); return B_OK; } else { - dprintf("IPCP: Error: Could not find input function for IP!\n"); + ERROR("IPCP: Error: Could not find input function for IP!\n"); m_freem(packet); return B_ERROR; } @@ -450,7 +439,7 @@ IPCP::UpdateAddresses() if(fLocalRequests.address != INADDR_ANY) inreq.ifra_addr.sin_addr.s_addr = fLocalRequests.address; else if(fLocalConfiguration.address == INADDR_ANY) - inreq.ifra_addr.sin_addr.s_addr = INADDR_BROADCAST; + inreq.ifra_addr.sin_addr.s_addr = 0x010F0F0F; // was: INADDR_BROADCAST else inreq.ifra_addr.sin_addr.s_addr = fLocalConfiguration.address; inreq.ifra_addr.sin_len = sizeof(struct sockaddr_in); @@ -461,7 +450,7 @@ IPCP::UpdateAddresses() if(fPeerRequests.address != INADDR_ANY) fGateway.sin_addr.s_addr = fPeerRequests.address; else if(fPeerConfiguration.address == INADDR_ANY) - fGateway.sin_addr.s_addr = INADDR_BROADCAST; + fGateway.sin_addr.s_addr = 0x020F0F0F; // was: INADDR_BROADCAST else fGateway.sin_addr.s_addr = fPeerConfiguration.address; fGateway.sin_len = sizeof(struct sockaddr_in); @@ -478,25 +467,25 @@ IPCP::UpdateAddresses() // tell stack to use these values if(in_control(NULL, SIOCAIFADDR, (caddr_t) &inreq, Interface().Ifnet()) != B_OK) - dprintf("IPCP: UpdateAddress(): SIOCAIFADDR returned error!\n"); + ERROR("IPCP: UpdateAddress(): SIOCAIFADDR returned error!\n"); if(in_control(NULL, SIOCSIFADDR, (caddr_t) &ifreqAddress, Interface().Ifnet()) != B_OK) - dprintf("IPCP: UpdateAddress(): SIOCSIFADDR returned error!\n"); + ERROR("IPCP: UpdateAddress(): SIOCSIFADDR returned error!\n"); if(in_control(NULL, SIOCSIFDSTADDR, (caddr_t) &ifreqDestination, Interface().Ifnet()) != B_OK) - dprintf("IPCP: UpdateAddress(): SIOCSIFDSTADDR returned error!\n"); + ERROR("IPCP: UpdateAddress(): SIOCSIFDSTADDR returned error!\n"); memcpy(&inreq.ifra_addr, &inreq.ifra_mask, sizeof(struct sockaddr_in)); // SIOCISFNETMASK wants the netmask to be in ifra_addr if(in_control(NULL, SIOCSIFNETMASK, (caddr_t) &inreq, Interface().Ifnet()) != B_OK) - dprintf("IPCP: UpdateAddress(): SIOCSIFNETMASK returned error!\n"); + ERROR("IPCP: UpdateAddress(): SIOCSIFNETMASK returned error!\n"); // add default/subnet route if(Side() == PPP_LOCAL_SIDE) { if(rtrequest(RTM_ADD, (struct sockaddr*) &inreq.ifra_mask, (struct sockaddr*) &fGateway, (struct sockaddr*) &inreq.ifra_mask, RTF_UP | RTF_GATEWAY, &fDefaultRoute) != B_OK) - dprintf("IPCP: UpdateAddress(): could not add default/subnet route!\n"); + ERROR("IPCP: UpdateAddress(): could not add default/subnet route!\n"); --fDefaultRoute->rt_refcnt; } @@ -519,7 +508,7 @@ IPCP::RemoveRoutes() if(rtrequest(RTM_DELETE, (struct sockaddr*) &netmask, (struct sockaddr*) &fGateway, (struct sockaddr*) &netmask, RTF_UP | RTF_GATEWAY, &fDefaultRoute) != B_OK) - dprintf("IPCP: RemoveRoutes(): could not remove default/subnet route!\n"); + ERROR("IPCP: RemoveRoutes(): could not remove default/subnet route!\n"); fDefaultRoute = NULL; } @@ -536,9 +525,7 @@ IPCP::NextID() void IPCP::NewState(ppp_state next) { -#if DEBUG - dprintf("IPCP: NewState(%d) state=%d\n", next, State()); -#endif + TRACE("IPCP: NewState(%d) state=%d\n", next, State()); // report state changes if(State() == PPP_INITIAL_STATE && next != State()) @@ -558,7 +545,7 @@ void IPCP::TOGoodEvent() { #if DEBUG - dprintf("IPCP: TOGoodEvent() state=%d\n", State()); +printf("IPCP: TOGoodEvent() state=%d\n", State()); #endif LockerHelper locker(fLock); @@ -587,9 +574,7 @@ IPCP::TOGoodEvent() void IPCP::TOBadEvent() { -#if DEBUG - dprintf("IPCP: TOBadEvent() state=%d\n", State()); -#endif + TRACE("IPCP: TOBadEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -617,9 +602,7 @@ IPCP::TOBadEvent() void IPCP::RCREvent(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: RCREvent() state=%d\n", State()); -#endif + TRACE("IPCP: RCREvent() state=%d\n", State()); KPPPConfigurePacket request(packet); KPPPConfigurePacket nak(PPP_CONFIGURE_NAK); @@ -725,9 +708,7 @@ IPCP::RCREvent(struct mbuf *packet) void IPCP::RCRGoodEvent(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: RCRGoodEvent() state=%d\n", State()); -#endif + TRACE("IPCP: RCRGoodEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -771,9 +752,7 @@ IPCP::RCRGoodEvent(struct mbuf *packet) void IPCP::RCRBadEvent(struct mbuf *nak, struct mbuf *reject) { -#if DEBUG - dprintf("IPCP: RCRBadEvent() state=%d\n", State()); -#endif + TRACE("IPCP: RCRBadEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -813,9 +792,7 @@ IPCP::RCRBadEvent(struct mbuf *nak, struct mbuf *reject) void IPCP::RCAEvent(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: RCAEvent() state=%d\n", State()); -#endif + TRACE("IPCP: RCAEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -923,9 +900,7 @@ IPCP::RCAEvent(struct mbuf *packet) void IPCP::RCNEvent(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: RCNEvent() state=%d\n", State()); -#endif + TRACE("IPCP: RCNEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -1041,9 +1016,7 @@ IPCP::RCNEvent(struct mbuf *packet) void IPCP::RTREvent(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: RTREvent() state=%d\n", State()); -#endif + TRACE("IPCP: RTREvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -1086,9 +1059,7 @@ IPCP::RTREvent(struct mbuf *packet) void IPCP::RTAEvent(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: RTAEvent() state=%d\n", State()); -#endif + TRACE("IPCP: RTAEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -1132,9 +1103,7 @@ IPCP::RTAEvent(struct mbuf *packet) void IPCP::RUCEvent(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: RUCEvent() state=%d\n", State()); -#endif + TRACE("IPCP: RUCEvent() state=%d\n", State()); SendCodeReject(packet); } @@ -1143,9 +1112,7 @@ IPCP::RUCEvent(struct mbuf *packet) void IPCP::RXJBadEvent(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: RXJBadEvent() state=%d\n", State()); -#endif + TRACE("IPCP: RXJBadEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -1188,7 +1155,7 @@ void IPCP::IllegalEvent(ppp_event event) { // TODO: update error statistics - dprintf("IPCP: IllegalEvent(event=%d) state=%d\n", event, State()); + ERROR("IPCP: IllegalEvent(event=%d) state=%d\n", event, State()); } @@ -1248,9 +1215,7 @@ IPCP::ZeroRestartCount() bool IPCP::SendConfigureRequest() { -#if DEBUG - dprintf("IPCP: SendConfigureRequest() state=%d\n", State()); -#endif + TRACE("IPCP: SendConfigureRequest() state=%d\n", State()); LockerHelper locker(fLock); --fRequestCounter; @@ -1271,11 +1236,9 @@ IPCP::SendConfigureRequest() ipItem.address = fLocalRequests.address; request.AddItem((ppp_configure_item*) &ipItem); -#if DEBUG - dprintf("IPCP: SCR: confaddr=%lX; reqaddr=%lX; addr=%lX\n", + TRACE("IPCP: SCR: confaddr=%lX; reqaddr=%lX; addr=%lX\n", fLocalConfiguration.address, fLocalRequests.address, ((ip_item*)request.ItemAt(0))->address); -#endif // add primary DNS (if needed) if(fRequestPrimaryDNS && fLocalRequests.primaryDNS == INADDR_ANY) { @@ -1303,9 +1266,7 @@ IPCP::SendConfigureRequest() bool IPCP::SendConfigureAck(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: SendConfigureAck() state=%d\n", State()); -#endif + TRACE("IPCP: SendConfigureAck() state=%d\n", State()); if(!packet) return false; @@ -1374,9 +1335,7 @@ IPCP::SendConfigureAck(struct mbuf *packet) bool IPCP::SendConfigureNak(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: SendConfigureNak() state=%d\n", State()); -#endif + TRACE("IPCP: SendConfigureNak() state=%d\n", State()); if(!packet) return false; @@ -1397,9 +1356,7 @@ IPCP::SendConfigureNak(struct mbuf *packet) bool IPCP::SendTerminateRequest() { -#if DEBUG - dprintf("IPCP: SendTerminateRequest() state=%d\n", State()); -#endif + TRACE("IPCP: SendTerminateRequest() state=%d\n", State()); LockerHelper locker(fLock); --fTerminateCounter; @@ -1427,9 +1384,7 @@ IPCP::SendTerminateRequest() bool IPCP::SendTerminateAck(struct mbuf *request = NULL) { -#if DEBUG - dprintf("IPCP: SendTerminateAck() state=%d\n", State()); -#endif + TRACE("IPCP: SendTerminateAck() state=%d\n", State()); struct mbuf *reply = request; @@ -1458,9 +1413,7 @@ IPCP::SendTerminateAck(struct mbuf *request = NULL) bool IPCP::SendCodeReject(struct mbuf *packet) { -#if DEBUG - dprintf("IPCP: SendCodeReject() state=%d\n", State()); -#endif + TRACE("IPCP: SendCodeReject() state=%d\n", State()); if(!packet) return false; diff --git a/src/add-ons/kernel/network/ppp/ipcp/Protocol.h b/src/add-ons/kernel/network/ppp/ipcp/Protocol.h index 678ce7ecf5..d25e530a53 100644 --- a/src/add-ons/kernel/network/ppp/ipcp/Protocol.h +++ b/src/add-ons/kernel/network/ppp/ipcp/Protocol.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef PROTOCOL__H #define PROTOCOL__H diff --git a/src/add-ons/kernel/network/ppp/ipcp/ipcp.cpp b/src/add-ons/kernel/network/ppp/ipcp/ipcp.cpp index ec84d24053..fff51ee3cb 100644 --- a/src/add-ons/kernel/network/ppp/ipcp/ipcp.cpp +++ b/src/add-ons/kernel/network/ppp/ipcp/ipcp.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include #include @@ -12,7 +10,6 @@ #include #include -#include #include "Protocol.h" @@ -54,10 +51,8 @@ add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface, success = mainInterface.AddProtocol(ipcp); } -#if DEBUG - dprintf("IPCP: add_to(): %s\n", + TRACE("IPCP: add_to(): %s\n", success && ipcp && ipcp->InitCheck() == B_OK ? "OK" : "ERROR"); -#endif return success && ipcp && ipcp->InitCheck() == B_OK; } diff --git a/src/add-ons/kernel/network/ppp/modem/ACFCHandler.cpp b/src/add-ons/kernel/network/ppp/modem/ACFCHandler.cpp index 34fac066be..c5fdb6c6ad 100644 --- a/src/add-ons/kernel/network/ppp/modem/ACFCHandler.cpp +++ b/src/add-ons/kernel/network/ppp/modem/ACFCHandler.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include "ACFCHandler.h" diff --git a/src/add-ons/kernel/network/ppp/modem/ACFCHandler.h b/src/add-ons/kernel/network/ppp/modem/ACFCHandler.h index 4be267ac12..4a5156ecbb 100644 --- a/src/add-ons/kernel/network/ppp/modem/ACFCHandler.h +++ b/src/add-ons/kernel/network/ppp/modem/ACFCHandler.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef ACFC_HANDLER__H #define ACFC_HANDLER__H diff --git a/src/add-ons/kernel/network/ppp/modem/Modem.h b/src/add-ons/kernel/network/ppp/modem/Modem.h index 1a637db22d..2a2906fbdc 100644 --- a/src/add-ons/kernel/network/ppp/modem/Modem.h +++ b/src/add-ons/kernel/network/ppp/modem/Modem.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef MODEM__H #define MODEM__H diff --git a/src/add-ons/kernel/network/ppp/modem/ModemDevice.cpp b/src/add-ons/kernel/network/ppp/modem/ModemDevice.cpp index 7d948e6bb3..5666d02989 100644 --- a/src/add-ons/kernel/network/ppp/modem/ModemDevice.cpp +++ b/src/add-ons/kernel/network/ppp/modem/ModemDevice.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include @@ -33,7 +31,7 @@ dump_packet(struct mbuf *packet) uint8 buffer[33]; uint8 bufferIndex = 0; - dprintf("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len, + TRACE("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len, packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1); for(uint32 index = 0; index < packet->m_len; index++) { @@ -41,7 +39,7 @@ dump_packet(struct mbuf *packet) buffer[bufferIndex++] = sDigits[data[index] & 0x0F]; if(bufferIndex == 32 || index == packet->m_len - 1) { buffer[bufferIndex] = 0; - dprintf("%s\n", buffer); + TRACE("%s\n", buffer); bufferIndex = 0; } } @@ -187,12 +185,13 @@ ModemDevice::ModemDevice(KPPPInterface& interface, driver_parameter *settings) fHandle(-1), fWorkerThread(-1), fOutputBytes(0), - fState(INITIAL) + fState(INITIAL), + fLock("ModemDevice") { #if DEBUG - dprintf("ModemDevice: Constructor\n"); + TRACE("ModemDevice: Constructor\n"); if(!settings || !settings->parameters) - dprintf("ModemDevice::ctor: No settings!\n"); + TRACE("ModemDevice::ctor: No settings!\n"); #endif fACFC = new ACFCHandler(REQUEST_ACFC | ALLOW_ACFC, interface); @@ -211,17 +210,13 @@ ModemDevice::ModemDevice(KPPPInterface& interface, driver_parameter *settings) fInitString = get_parameter_value(MODEM_INIT_KEY, settings); fDialString = get_parameter_value(MODEM_DIAL_KEY, settings); -#if DEBUG - dprintf("ModemDevice::ctor: interfaceName: %s\n", fPortName); -#endif + TRACE("ModemDevice::ctor: interfaceName: %s\n", fPortName); } ModemDevice::~ModemDevice() { -#if DEBUG - dprintf("ModemDevice: Destructor\n"); -#endif + TRACE("ModemDevice: Destructor\n"); } @@ -239,9 +234,7 @@ ModemDevice::InitCheck() const bool ModemDevice::Up() { -#if DEBUG - dprintf("ModemDevice: Up()\n"); -#endif + TRACE("ModemDevice: Up()\n"); if(InitCheck() != B_OK) return false; @@ -279,9 +272,7 @@ ModemDevice::Up() bool ModemDevice::Down() { -#if DEBUG - dprintf("ModemDevice: Down()\n"); -#endif + TRACE("ModemDevice: Down()\n"); if(InitCheck() != B_OK) return false; @@ -355,7 +346,7 @@ ModemDevice::OpenModem() // init port struct termios options; if(ioctl(fHandle, TCGETA, &options) != B_OK) { - dprintf("ModemDevice: Could not retrieve port options!\n"); + ERROR("ModemDevice: Could not retrieve port options!\n"); return; } @@ -370,7 +361,7 @@ ModemDevice::OpenModem() // set new options if(ioctl(fHandle, TCSETA, &options) != B_OK) { - dprintf("ModemDevice: Could not init port!\n"); + ERROR("ModemDevice: Could not init port!\n"); return; } } @@ -433,7 +424,7 @@ status_t ModemDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0) { #if DEBUG - dprintf("ModemDevice: Send()\n"); + TRACE("ModemDevice: Send()\n"); dump_packet(packet); #endif diff --git a/src/add-ons/kernel/network/ppp/modem/ModemDevice.h b/src/add-ons/kernel/network/ppp/modem/ModemDevice.h index 6518e554e2..180078833a 100644 --- a/src/add-ons/kernel/network/ppp/modem/ModemDevice.h +++ b/src/add-ons/kernel/network/ppp/modem/ModemDevice.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef MODEM_DEVICE__H #define MODEM_DEVICE__H diff --git a/src/add-ons/kernel/network/ppp/modem/modem.cpp b/src/add-ons/kernel/network/ppp/modem/modem.cpp index f7a6404830..bda3db6f0a 100644 --- a/src/add-ons/kernel/network/ppp/modem/modem.cpp +++ b/src/add-ons/kernel/network/ppp/modem/modem.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include #include @@ -12,7 +10,6 @@ #include #include -#include #include "ModemDevice.h" @@ -41,10 +38,8 @@ add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface, success = mainInterface.SetDevice(device); } -#if DEBUG - dprintf("Modem: add_to(): %s\n", + TRACE("Modem: add_to(): %s\n", success && device && device->InitCheck() == B_OK ? "OK" : "ERROR"); -#endif return success && device && device->InitCheck() == B_OK; } diff --git a/src/add-ons/kernel/network/ppp/pap/Protocol.cpp b/src/add-ons/kernel/network/ppp/pap/Protocol.cpp index 7bebc028fa..31e7eaa3d1 100644 --- a/src/add-ons/kernel/network/ppp/pap/Protocol.cpp +++ b/src/add-ons/kernel/network/ppp/pap/Protocol.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include "Protocol.h" #include @@ -83,7 +81,8 @@ PAP::PAP(KPPPInterface& interface, driver_parameter *settings) fID(system_time() & 0xFF), fMaxRequest(3), fRequestID(0), - fNextTimeout(0) + fNextTimeout(0), + fLock("PAP") { ProfileChanged(); } @@ -114,9 +113,7 @@ PAP::ProfileChanged() bool PAP::Up() { -#if DEBUG - dprintf("PAP: Up() state=%d\n", State()); -#endif + TRACE("PAP: Up() state=%d\n", State()); LockerHelper locker(fLock); @@ -148,9 +145,7 @@ PAP::Up() bool PAP::Down() { -#if DEBUG - dprintf("PAP: Down() state=%d\n", State()); -#endif + TRACE("PAP: Down() state=%d\n", State()); LockerHelper locker(fLock); @@ -307,9 +302,7 @@ PAP::NextID() void PAP::NewState(pap_state next) { -#if DEBUG - dprintf("PAP: NewState(%d) state=%d\n", next, State()); -#endif + TRACE("PAP: NewState(%d) state=%d\n", next, State()); // state changes if(State() == INITIAL && next != State()) { @@ -333,9 +326,7 @@ PAP::NewState(pap_state next) void PAP::TOGoodEvent() { -#if DEBUG - dprintf("PAP: TOGoodEvent() state=%d\n", State()); -#endif + TRACE("PAP: TOGoodEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -358,9 +349,7 @@ PAP::TOGoodEvent() void PAP::TOBadEvent() { -#if DEBUG - dprintf("PAP: TOBadEvent() state=%d\n", State()); -#endif + TRACE("PAP: TOBadEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -386,9 +375,7 @@ PAP::TOBadEvent() void PAP::RREvent(struct mbuf *packet) { -#if DEBUG - dprintf("PAP: RREvent() state=%d\n", State()); -#endif + TRACE("PAP: RREvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -427,9 +414,7 @@ PAP::RREvent(struct mbuf *packet) void PAP::RAEvent(struct mbuf *packet) { -#if DEBUG - dprintf("PAP: RAEvent() state=%d\n", State()); -#endif + TRACE("PAP: RAEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -460,9 +445,7 @@ PAP::RAEvent(struct mbuf *packet) void PAP::RNEvent(struct mbuf *packet) { -#if DEBUG - dprintf("PAP: RNEvent() state=%d\n", State()); -#endif + TRACE("PAP: RNEvent() state=%d\n", State()); LockerHelper locker(fLock); @@ -500,9 +483,7 @@ PAP::InitializeRestartCount() bool PAP::SendRequest() { -#if DEBUG - dprintf("PAP: SendRequest() state=%d\n", State()); -#endif + TRACE("PAP: SendRequest() state=%d\n", State()); LockerHelper locker(fLock); --fRequestCounter; @@ -535,9 +516,7 @@ PAP::SendRequest() bool PAP::SendAck(struct mbuf *packet) { -#if DEBUG - dprintf("PAP: SendAck() state=%d\n", State()); -#endif + TRACE("PAP: SendAck() state=%d\n", State()); if(!packet) return false; @@ -558,9 +537,7 @@ PAP::SendAck(struct mbuf *packet) bool PAP::SendNak(struct mbuf *packet) { -#if DEBUG - dprintf("PAP: SendNak() state=%d\n", State()); -#endif + TRACE("PAP: SendNak() state=%d\n", State()); if(!packet) return false; diff --git a/src/add-ons/kernel/network/ppp/pap/Protocol.h b/src/add-ons/kernel/network/ppp/pap/Protocol.h index 5fee22b1db..17c6c90d00 100644 --- a/src/add-ons/kernel/network/ppp/pap/Protocol.h +++ b/src/add-ons/kernel/network/ppp/pap/Protocol.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef PROTOCOL__H #define PROTOCOL__H diff --git a/src/add-ons/kernel/network/ppp/pap/pap.cpp b/src/add-ons/kernel/network/ppp/pap/pap.cpp index a4e9a772a4..b3cb529864 100644 --- a/src/add-ons/kernel/network/ppp/pap/pap.cpp +++ b/src/add-ons/kernel/network/ppp/pap/pap.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include #include @@ -12,7 +10,6 @@ #include #include -#include #include "Protocol.h" @@ -41,10 +38,8 @@ add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface, success = mainInterface.AddProtocol(pap); } -#if DEBUG - dprintf("PAP: add_to(): %s\n", + TRACE("PAP: add_to(): %s\n", success && pap && pap->InitCheck() == B_OK ? "OK" : "ERROR"); -#endif return success && pap && pap->InitCheck() == B_OK; } diff --git a/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.cpp b/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.cpp index a15cb04c74..44ef7cf906 100644 --- a/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.cpp +++ b/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include "DiscoveryPacket.h" diff --git a/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.h b/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.h index 07427a15d2..2e35337797 100644 --- a/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.h +++ b/src/add-ons/kernel/network/ppp/pppoe/DiscoveryPacket.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef DISCOVERY_PACKET__H #define DISCOVERY_PACKET__H diff --git a/src/add-ons/kernel/network/ppp/pppoe/PPPoE.h b/src/add-ons/kernel/network/ppp/pppoe/PPPoE.h index ef1095add0..928b462c34 100644 --- a/src/add-ons/kernel/network/ppp/pppoe/PPPoE.h +++ b/src/add-ons/kernel/network/ppp/pppoe/PPPoE.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef PPPoE__H #define PPPoE__H diff --git a/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.cpp b/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.cpp index 2f7fa44775..51bd1b4d23 100644 --- a/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.cpp +++ b/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include "PPPoEDevice.h" #include "DiscoveryPacket.h" @@ -28,7 +26,7 @@ dump_packet(struct mbuf *packet) uint8 buffer[33]; uint8 bufferIndex = 0; - dprintf("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len, + TRACE("Dumping packet;len=%ld;pkthdr.len=%d\n", packet->m_len, packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1); for(uint32 index = 0; index < packet->m_len; index++) { @@ -36,7 +34,7 @@ dump_packet(struct mbuf *packet) buffer[bufferIndex++] = sDigits[data[index] & 0x0F]; if(bufferIndex == 32 || index == packet->m_len - 1) { buffer[bufferIndex] = 0; - dprintf("%s\n", buffer); + TRACE("%s\n", buffer); bufferIndex = 0; } } @@ -53,12 +51,13 @@ PPPoEDevice::PPPoEDevice(KPPPInterface& interface, driver_parameter *settings) fServiceName(NULL), fAttempts(0), fNextTimeout(0), - fState(INITIAL) + fState(INITIAL), + fLock("PPPoEDevice") { #if DEBUG - dprintf("PPPoEDevice: Constructor\n"); + TRACE("PPPoEDevice: Constructor\n"); if(!settings || !settings->parameters) - dprintf("PPPoEDevice::ctor: No settings!\n"); + TRACE("PPPoEDevice::ctor: No settings!\n"); #endif interface.SetPFCOptions(PPP_ALLOW_PFC); @@ -80,7 +79,7 @@ PPPoEDevice::PPPoEDevice(KPPPInterface& interface, driver_parameter *settings) #if DEBUG if(!fEthernetIfnet) - dprintf("PPPoEDevice::ctor: could not find ethernet interface\n"); + TRACE("PPPoEDevice::ctor: could not find ethernet interface\n"); #endif add_device(this); @@ -89,9 +88,7 @@ PPPoEDevice::PPPoEDevice(KPPPInterface& interface, driver_parameter *settings) PPPoEDevice::~PPPoEDevice() { -#if DEBUG - dprintf("PPPoEDevice: Destructor\n"); -#endif + TRACE("PPPoEDevice: Destructor\n"); remove_device(this); } @@ -108,9 +105,7 @@ PPPoEDevice::InitCheck() const bool PPPoEDevice::Up() { -#if DEBUG - dprintf("PPPoEDevice: Up()\n"); -#endif + TRACE("PPPoEDevice: Up()\n"); if(InitCheck() != B_OK) return false; @@ -170,7 +165,7 @@ PPPoEDevice::Up() if(EthernetIfnet()->output(EthernetIfnet(), packet, &destination, NULL) != B_OK) { fState = INITIAL; fAttempts = 0; - dprintf("PPPoEDevice::Up(): EthernetIfnet()->output() failed!\n"); + ERROR("PPPoEDevice::Up(): EthernetIfnet()->output() failed!\n"); return false; } @@ -183,9 +178,7 @@ PPPoEDevice::Up() bool PPPoEDevice::Down() { -#if DEBUG - dprintf("PPPoEDevice: Down()\n"); -#endif + TRACE("PPPoEDevice: Down()\n"); if(InitCheck() != B_OK) return false; @@ -211,7 +204,7 @@ PPPoEDevice::Down() struct mbuf *packet = discovery.ToMbuf(MTU()); if(!packet) { - dprintf("PPPoEDevice::Down(): ToMbuf() failed; MTU=%ld\n", MTU()); + ERROR("PPPoEDevice::Down(): ToMbuf() failed; MTU=%ld\n", MTU()); DownEvent(); return false; } @@ -264,14 +257,12 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0) { // Send() is only for PPP packets. PPPoE packets are sent directly to ethernet. -#if DEBUG - dprintf("PPPoEDevice: Send()\n"); -#endif + TRACE("PPPoEDevice: Send()\n"); if(!packet) return B_ERROR; else if(InitCheck() != B_OK || protocolNumber != 0) { - dprintf("PPPoEDevice::Send(): InitCheck() != B_OK!\n"); + ERROR("PPPoEDevice::Send(): InitCheck() != B_OK!\n"); m_freem(packet); return B_ERROR; } @@ -279,7 +270,7 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0) LockerHelper locker(fLock); if(!IsUp()) { - dprintf("PPPoEDevice::Send(): no connection!\n"); + ERROR("PPPoEDevice::Send(): no connection!\n"); m_freem(packet); return PPP_NO_CONNECTION; } @@ -307,11 +298,11 @@ PPPoEDevice::Send(struct mbuf *packet, uint16 protocolNumber = 0) locker.UnlockNow(); - if(!packet) - dprintf("PPPoEDevice::Send(): packet is NULL!\n"); + if(!packet || !mtod(packet, pppoe_header*)) + ERROR("PPPoEDevice::Send(): packet is NULL!\n"); if(EthernetIfnet()->output(EthernetIfnet(), packet, &destination, NULL) != B_OK) { - dprintf("PPPoEDevice::Send(): EthernetIfnet()->output() failed!\n"); + ERROR("PPPoEDevice::Send(): EthernetIfnet()->output() failed!\n"); DownEvent(); // DownEvent() without DownStarted() indicates connection lost return PPP_NO_CONNECTION; diff --git a/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.h b/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.h index f7d1c78a68..86b4b040af 100644 --- a/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.h +++ b/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef PPPoE_DEVICE__H #define PPPoE_DEVICE__H diff --git a/src/add-ons/kernel/network/ppp/pppoe/pppoe.cpp b/src/add-ons/kernel/network/ppp/pppoe/pppoe.cpp index 0484908026..7286be8231 100644 --- a/src/add-ons/kernel/network/ppp/pppoe/pppoe.cpp +++ b/src/add-ons/kernel/network/ppp/pppoe/pppoe.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include #include @@ -34,7 +32,7 @@ static struct ethernet_module_info *sEthernet; static int32 sHostUniq = 0; status_t std_ops(int32 op, ...); -static BLocker sLock; +static BLocker sLock("PPPoEList"); static TemplateList *sDevices; static TemplateList *sQueries; @@ -94,6 +92,7 @@ FindPPPoEInterface(const char *name) return NULL; } + uint32 NewHostUniq() { @@ -104,9 +103,7 @@ NewHostUniq() void add_device(PPPoEDevice *device) { -#if DEBUG - dprintf("PPPoE: add_device()\n"); -#endif + TRACE("PPPoE: add_device()\n"); LockerHelper locker(sLock); sDevices->AddItem(device); @@ -116,9 +113,7 @@ add_device(PPPoEDevice *device) void remove_device(PPPoEDevice *device) { -#if DEBUG - dprintf("PPPoE: remove_device()\n"); -#endif + TRACE("PPPoE: remove_device()\n"); LockerHelper locker(sLock); sDevices->RemoveItem(device); @@ -148,7 +143,7 @@ pppoe_input(struct mbuf *packet) if(header->pppoeHeader.code == PADO) { DiscoveryPacket discovery(packet, ETHER_HDR_LEN); if(discovery.InitCheck() != B_OK) { - dprintf("PPPoE: received corrupted discovery packet!\n"); + ERROR("PPPoE: received corrupted discovery packet!\n"); m_freem(packet); return; } @@ -171,21 +166,17 @@ pppoe_input(struct mbuf *packet) if(device && device->EthernetIfnet() == sourceIfnet) { if(header->ethernetHeader.ether_type == ETHERTYPE_PPPOE && header->pppoeHeader.sessionID == device->SessionID()) { -#if DEBUG - dprintf("PPPoE: session packet\n"); -#endif + TRACE("PPPoE: session packet\n"); device->Receive(packet); return; } else if(header->ethernetHeader.ether_type == ETHERTYPE_PPPOEDISC && header->pppoeHeader.code != PADI && header->pppoeHeader.code != PADR && !device->IsDown()) { -#if DEBUG - dprintf("PPPoE: discovery packet\n"); -#endif + TRACE("PPPoE: discovery packet\n"); DiscoveryPacket discovery(packet, ETHER_HDR_LEN); if(discovery.InitCheck() != B_OK) { - dprintf("PPPoE: received corrupted discovery packet!\n"); + ERROR("PPPoE: received corrupted discovery packet!\n"); m_freem(packet); return; } @@ -200,7 +191,7 @@ pppoe_input(struct mbuf *packet) } } - dprintf("PPPoE: No device found for packet from: %s\n", sourceIfnet->if_name); + ERROR("PPPoE: No device found for packet from: %s\n", sourceIfnet->if_name); m_freem(packet); } @@ -223,10 +214,8 @@ add_to(KPPPInterface& mainInterface, KPPPInterface *subInterface, success = mainInterface.SetDevice(device); } -#if DEBUG - dprintf("PPPoE: add_to(): %s\n", + TRACE("PPPoE: add_to(): %s\n", success && device && device->InitCheck() == B_OK ? "OK" : "ERROR"); -#endif return success && device && device->InitCheck() == B_OK; } @@ -319,22 +308,19 @@ std_ops(int32 op, ...) return B_ERROR; } - set_max_linkhdr(PPPoE_HEADER_SIZE + ETHER_HDR_LEN); + set_max_linkhdr(2 + PPPoE_HEADER_SIZE + ETHER_HDR_LEN); + // 2 bytes for PPP header sDevices = new TemplateList; sQueries = new TemplateList; sEthernet->set_pppoe_receiver(pppoe_input); -#if DEBUG - dprintf("PPPoE: Registered PPPoE receiver.\n"); -#endif + TRACE("PPPoE: Registered PPPoE receiver.\n"); return B_OK; case B_MODULE_UNINIT: delete sDevices; sEthernet->unset_pppoe_receiver(); -#if DEBUG - dprintf("PPPoE: Unregistered PPPoE receiver.\n"); -#endif + TRACE("PPPoE: Unregistered PPPoE receiver.\n"); put_module(NET_CORE_MODULE_NAME); put_module(NET_ETHERNET_MODULE_NAME); break; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPConfigurePacket.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPConfigurePacket.cpp index 6f42cfebf6..223eda4485 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPConfigurePacket.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPConfigurePacket.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPConfigurePacket \brief Helper class for LCP configure packets. diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPDevice.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPDevice.cpp index 7d8914bc26..137b65f00a 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPDevice.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPDevice.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPDevice \brief Represents a device at the lowest level of the communcation stack. diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp index 75fdfc044b..94a08c9933 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPInterface.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPInterface \brief The kernel representation of a PPP interface. @@ -21,7 +19,7 @@ */ // cstdio must be included before KPPPModule.h/KPPPManager.h because -// ddprintf is defined twice with different return values, once with +// dprintf is defined twice with different return values, once with // void (KernelExport.h) and once with int (stdio.h). #include #include @@ -52,7 +50,7 @@ // TODO: -// - implement timers with support for settings next time instead of receiving timer +// - implement timers with support for setting next event instead of receiving timer // events periodically // - add missing settings support (DialRetryDelay, etc.) @@ -154,7 +152,7 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry, _KPPPMRUHandler *mruHandler = new _KPPPMRUHandler(*this); if(!LCP().AddOptionHandler(mruHandler) || mruHandler->InitCheck() != B_OK) { - dprintf("KPPPInterface: Could not add MRU handler!\n"); + ERROR("KPPPInterface: Could not add MRU handler!\n"); delete mruHandler; } // authentication @@ -162,14 +160,14 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry, new _KPPPAuthenticationHandler(*this); if(!LCP().AddOptionHandler(authenticationHandler) || authenticationHandler->InitCheck() != B_OK) { - dprintf("KPPPInterface: Could not add authentication handler!\n"); + ERROR("KPPPInterface: Could not add authentication handler!\n"); delete authenticationHandler; } // PFC _KPPPPFCHandler *pfcHandler = new _KPPPPFCHandler(fLocalPFCState, fPeerPFCState, *this); if(!LCP().AddOptionHandler(pfcHandler) || pfcHandler->InitCheck() != B_OK) { - dprintf("KPPPInterface: Could not add PFC handler!\n"); + ERROR("KPPPInterface: Could not add PFC handler!\n"); delete pfcHandler; } @@ -180,7 +178,7 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry, // 1s delay between lost connection and redial if(get_module(PPP_INTERFACE_MODULE_NAME, (module_info**) &fManager) != B_OK) - dprintf("KPPPInterface: Manager module not found!\n"); + ERROR("KPPPInterface: Manager module not found!\n"); // are we a multilink subinterface? if(parent && parent->IsMultilink()) { @@ -225,7 +223,7 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry, // load all protocols and the device if(!LoadModules(fSettings, 0, fSettings->parameter_count)) { - dprintf("KPPPInterface: Error loading modules!\n"); + ERROR("KPPPInterface: Error loading modules!\n"); fInitStatus = B_ERROR; } } @@ -234,9 +232,7 @@ KPPPInterface::KPPPInterface(const char *name, ppp_interface_entry *entry, //! Destructor: Disconnects and marks interface for deletion. KPPPInterface::~KPPPInterface() { -#if DEBUG - dprintf("KPPPInterface: Destructor\n"); -#endif + TRACE("KPPPInterface: Destructor\n"); ++fDeleteCounter; @@ -347,9 +343,7 @@ KPPPInterface::InitCheck() const bool KPPPInterface::SetMRU(uint32 MRU) { -#if DEBUG - dprintf("KPPPInterface: SetMRU(%ld)\n", MRU); -#endif + TRACE("KPPPInterface: SetMRU(%ld)\n", MRU); if(Device() && MRU > Device()->MTU() - 2) return false; @@ -579,9 +573,7 @@ KPPPInterface::Control(uint32 op, void *data, size_t length) bool KPPPInterface::SetDevice(KPPPDevice *device) { -#if DEBUG - dprintf("KPPPInterface: SetDevice(%p)\n", device); -#endif + TRACE("KPPPInterface: SetDevice(%p)\n", device); if(device && &device->Interface() != this) return false; @@ -628,13 +620,11 @@ KPPPInterface::SetDevice(KPPPDevice *device) bool KPPPInterface::AddProtocol(KPPPProtocol *protocol) { - // Find instert position after the last protocol + // Find insert position after the last protocol // with the same level. -#if DEBUG - dprintf("KPPPInterface: AddProtocol(%X)\n", + TRACE("KPPPInterface: AddProtocol(%X)\n", protocol ? protocol->ProtocolNumber() : 0); -#endif if(!protocol || &protocol->Interface() != this || protocol->Level() == PPP_INTERFACE_LEVEL) @@ -701,10 +691,8 @@ KPPPInterface::AddProtocol(KPPPProtocol *protocol) bool KPPPInterface::RemoveProtocol(KPPPProtocol *protocol) { -#if DEBUG - dprintf("KPPPInterface: RemoveProtocol(%X)\n", + TRACE("KPPPInterface: RemoveProtocol(%X)\n", protocol ? protocol->ProtocolNumber() : 0); -#endif LockerHelper locker(fLock); @@ -781,9 +769,7 @@ KPPPInterface::ProtocolAt(int32 index) const KPPPProtocol* KPPPInterface::ProtocolFor(uint16 protocolNumber, KPPPProtocol *start = NULL) const { -#if DEBUG - dprintf("KPPPInterface: ProtocolFor(%X)\n", protocolNumber); -#endif + TRACE("KPPPInterface: ProtocolFor(%X)\n", protocolNumber); KPPPProtocol *current = start ? start : FirstProtocol(); @@ -803,10 +789,7 @@ KPPPInterface::ProtocolFor(uint16 protocolNumber, KPPPProtocol *start = NULL) co bool KPPPInterface::AddChild(KPPPInterface *child) { -#if DEBUG - dprintf("KPPPInterface: AddChild(%lX)\n", - child ? child->ID() : 0); -#endif + TRACE("KPPPInterface: AddChild(%lX)\n", child ? child->ID() : 0); if(!child) return false; @@ -826,10 +809,7 @@ KPPPInterface::AddChild(KPPPInterface *child) bool KPPPInterface::RemoveChild(KPPPInterface *child) { -#if DEBUG - dprintf("KPPPInterface: RemoveChild(%lX)\n", - child ? child->ID() : 0); -#endif + TRACE("KPPPInterface: RemoveChild(%lX)\n", child ? child->ID() : 0); LockerHelper locker(fLock); @@ -850,9 +830,7 @@ KPPPInterface::RemoveChild(KPPPInterface *child) KPPPInterface* KPPPInterface::ChildAt(int32 index) const { -#if DEBUG - dprintf("KPPPInterface: ChildAt(%ld)\n", index); -#endif + TRACE("KPPPInterface: ChildAt(%ld)\n", index); KPPPInterface *child = fChildren.ItemAt(index); @@ -867,9 +845,7 @@ KPPPInterface::ChildAt(int32 index) const void KPPPInterface::SetAutoRedial(bool autoRedial = true) { -#if DEBUG - dprintf("KPPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false"); -#endif + TRACE("KPPPInterface: SetAutoRedial(%s)\n", autoRedial ? "true" : "false"); if(Mode() != PPP_CLIENT_MODE) return; @@ -887,15 +863,11 @@ KPPPInterface::SetDialOnDemand(bool dialOnDemand = true) // All protocols must check if DialOnDemand was enabled/disabled after this // interface went down. This is the only situation where a change is relevant. -#if DEBUG - dprintf("KPPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false"); -#endif + TRACE("KPPPInterface: SetDialOnDemand(%s)\n", dialOnDemand ? "true" : "false"); // Only clients support DialOnDemand. if(Mode() != PPP_CLIENT_MODE) { -#if DEBUG - dprintf("KPPPInterface::SetDialOnDemand(): Wrong mode!\n"); -#endif + TRACE("KPPPInterface::SetDialOnDemand(): Wrong mode!\n"); fDialOnDemand = false; return; } else if(DoesDialOnDemand() == dialOnDemand) @@ -933,9 +905,7 @@ KPPPInterface::SetDialOnDemand(bool dialOnDemand = true) bool KPPPInterface::SetPFCOptions(uint8 pfcOptions) { -#if DEBUG - dprintf("KPPPInterface: SetPFCOptions(0x%X)\n", pfcOptions); -#endif + TRACE("KPPPInterface: SetPFCOptions(0x%X)\n", pfcOptions); if(PFCOptions() & PPP_FREEZE_PFC_OPTIONS) return false; @@ -955,9 +925,7 @@ KPPPInterface::SetPFCOptions(uint8 pfcOptions) bool KPPPInterface::Up() { -#if DEBUG - dprintf("KPPPInterface: Up()\n"); -#endif + TRACE("KPPPInterface: Up()\n"); if(InitCheck() != B_OK || Phase() == PPP_TERMINATION_PHASE) return false; @@ -973,6 +941,7 @@ KPPPInterface::Up() while(fLock.LockWithTimeout(100000) != B_NO_ERROR) if(fDeleteCounter > 0) return false; + if(fUpThread == -1) fUpThread = me; @@ -1003,10 +972,8 @@ KPPPInterface::Up() if(receive_data(&sender, &report, sizeof(report)) != PPP_REPORT_CODE) continue; -//#if DEBUG -// dprintf("KPPPInterface::Up(): Report: Type = %ld Code = %ld\n", report.type, +// TRACE("KPPPInterface::Up(): Report: Type = %ld Code = %ld\n", report.type, // report.code); -//#endif if(IsUp()) { if(me == fUpThread) { @@ -1014,8 +981,7 @@ KPPPInterface::Up() fUpThread = -1; } - PPP_REPLY(sender, B_OK); - ReportManager().DisableReports(PPP_CONNECTION_REPORT, me); + PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); return true; } @@ -1025,8 +991,7 @@ KPPPInterface::Up() fUpThread = -1; } - PPP_REPLY(sender, B_OK); - ReportManager().DisableReports(PPP_CONNECTION_REPORT, me); + PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); return false; } else if(report.type != PPP_CONNECTION_REPORT) { PPP_REPLY(sender, B_OK); @@ -1044,8 +1009,7 @@ KPPPInterface::Up() // notify redial thread that we do not need it anymore } - PPP_REPLY(sender, B_OK); - ReportManager().DisableReports(PPP_CONNECTION_REPORT, me); + PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); return true; } else if(report.code == PPP_REPORT_DOWN_SUCCESSFUL || report.code == PPP_REPORT_UP_ABORTED @@ -1055,12 +1019,11 @@ KPPPInterface::Up() fDialRetry = 0; fUpThread = -1; - if(!DoesDialOnDemand() && report.code != PPP_REPORT_DOWN_SUCCESSFUL) + if(report.code != PPP_REPORT_DOWN_SUCCESSFUL) Delete(); } - PPP_REPLY(sender, B_OK); - ReportManager().DisableReports(PPP_CONNECTION_REPORT, me); + PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); return false; } @@ -1068,8 +1031,7 @@ KPPPInterface::Up() // I am an observer if(report.code == PPP_REPORT_DEVICE_UP_FAILED) { if(fDialRetry >= fDialRetriesLimit || fUpThread == -1) { - PPP_REPLY(sender, B_OK); - ReportManager().DisableReports(PPP_CONNECTION_REPORT, me); + PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); return false; } else { PPP_REPLY(sender, B_OK); @@ -1080,8 +1042,7 @@ KPPPInterface::Up() PPP_REPLY(sender, B_OK); continue; } else { - PPP_REPLY(sender, B_OK); - ReportManager().DisableReports(PPP_CONNECTION_REPORT, me); + PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); return false; } } @@ -1089,27 +1050,20 @@ KPPPInterface::Up() // I am the thread for the real task if(report.code == PPP_REPORT_DEVICE_UP_FAILED) { if(fDialRetry >= fDialRetriesLimit) { -#if DEBUG - dprintf("KPPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n"); -#endif + TRACE("KPPPInterface::Up(): DEVICE_UP_FAILED: >=maxretries!\n"); + fDialRetry = 0; fUpThread = -1; + Delete(); + PPP_REPLY(sender, PPP_OK_DISABLE_REPORTS); - if(!DoesDialOnDemand()) - Delete(); - - PPP_REPLY(sender, B_OK); - ReportManager().DisableReports(PPP_CONNECTION_REPORT, me); return false; } else { -#if DEBUG - dprintf("KPPPInterface::Up(): DEVICE_UP_FAILED: IsUp()) - dprintf("KPPPInterface::Send(): device is not up!\n"); + TRACE("KPPPInterface::Send(): device is not up!\n"); else if(!protocol->IsEnabled()) - dprintf("KPPPInterface::Send(): protocol not enabled!\n"); + TRACE("KPPPInterface::Send(): protocol not enabled!\n"); else if(!IsProtocolAllowed(*protocol)) - dprintf("KPPPInterface::Send(): protocol not allowed to send!\n"); + TRACE("KPPPInterface::Send(): protocol not allowed to send!\n"); else - dprintf("KPPPInterface::Send(): protocol allowed\n"); + TRACE("KPPPInterface::Send(): protocol allowed\n"); #endif // make sure that protocol is allowed to send and everything is up if(!Device()->IsUp() || !protocol || !protocol->IsEnabled() || !IsProtocolAllowed(*protocol)) { - dprintf("KPPPInterface::Send(): cannot send!\n"); + ERROR("KPPPInterface::Send(): cannot send!\n"); m_freem(packet); return B_ERROR; } @@ -1468,9 +1409,7 @@ KPPPInterface::Send(struct mbuf *packet, uint16 protocolNumber) status_t KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) { -#if DEBUG - dprintf("KPPPInterface: Receive(0x%X)\n", protocolNumber); -#endif + TRACE("KPPPInterface: Receive(0x%X)\n", protocolNumber); if(!packet) return B_ERROR; @@ -1494,9 +1433,7 @@ KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) for(; protocol; protocol = protocol->NextProtocol() ? ProtocolFor(protocolNumber, protocol->NextProtocol()) : NULL) { -#if DEBUG - dprintf("KPPPInterface::Receive(): trying protocol\n"); -#endif + TRACE("KPPPInterface::Receive(): trying protocol\n"); if(!protocol->IsEnabled() || !IsProtocolAllowed(*protocol)) continue; @@ -1509,9 +1446,7 @@ KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) return result; } -#if DEBUG - dprintf("KPPPInterface::Receive(): trying parent\n"); -#endif + TRACE("KPPPInterface::Receive(): trying parent\n"); // maybe the parent interface can handle the packet if(Parent()) @@ -1543,9 +1478,7 @@ KPPPInterface::Receive(struct mbuf *packet, uint16 protocolNumber) status_t KPPPInterface::ReceiveFromDevice(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPInterface: ReceiveFromDevice()\n"); -#endif + TRACE("KPPPInterface: ReceiveFromDevice()\n"); if(!packet) return B_ERROR; @@ -1596,9 +1529,7 @@ KPPPInterface::Pulse() bool KPPPInterface::RegisterInterface() { -#if DEBUG - dprintf("KPPPInterface: RegisterInterface()\n"); -#endif + TRACE("KPPPInterface: RegisterInterface()\n"); if(fIfnet) return true; @@ -1632,9 +1563,7 @@ KPPPInterface::RegisterInterface() bool KPPPInterface::UnregisterInterface() { -#if DEBUG - dprintf("KPPPInterface: UnregisterInterface()\n"); -#endif + TRACE("KPPPInterface: UnregisterInterface()\n"); if(!fIfnet) return true; @@ -1671,9 +1600,7 @@ KPPPInterface::UpdateProfile() status_t KPPPInterface::StackControl(uint32 op, void *data) { -#if DEBUG - dprintf("KPPPInterface: StackControl(0x%lX)\n", op); -#endif + TRACE("KPPPInterface: StackControl(0x%lX)\n", op); switch(op) { default: @@ -1716,9 +1643,7 @@ class CallStackControl { status_t KPPPInterface::StackControlEachHandler(uint32 op, void *data) { -#if DEBUG - dprintf("KPPPInterface: StackControlEachHandler(0x%lX)\n", op); -#endif + TRACE("KPPPInterface: StackControlEachHandler(0x%lX)\n", op); status_t result = B_BAD_VALUE, tmp; @@ -1744,9 +1669,7 @@ KPPPInterface::StackControlEachHandler(uint32 op, void *data) void KPPPInterface::CalculateInterfaceMTU() { -#if DEBUG - dprintf("KPPPInterface: CalculateInterfaceMTU()\n"); -#endif + TRACE("KPPPInterface: CalculateInterfaceMTU()\n"); fInterfaceMTU = fMRU; fHeaderLength = 2; @@ -1774,9 +1697,7 @@ KPPPInterface::CalculateInterfaceMTU() void KPPPInterface::CalculateBaudRate() { -#if DEBUG - dprintf("KPPPInterface: CalculateBaudRate()\n"); -#endif + TRACE("KPPPInterface: CalculateBaudRate()\n"); if(!Ifnet()) return; @@ -1797,9 +1718,7 @@ KPPPInterface::CalculateBaudRate() void KPPPInterface::Redial(uint32 delay) { -#if DEBUG - dprintf("KPPPInterface: Redial(%ld)\n", delay); -#endif + TRACE("KPPPInterface: Redial(%ld)\n", delay); if(fRedialThread != -1) return; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCP.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCP.cpp index f85fb93e4d..130ea47420 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCP.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCP.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPLCP \brief The LCP protocol. @@ -279,7 +277,7 @@ KPPPLCP::Receive(struct mbuf *packet, uint16 protocolNumber) return B_ERROR; if(protocolNumber != PPP_LCP_PROTOCOL) { - dprintf("KPPPLCP::Receive(): wrong protocol number!\n"); + ERROR("KPPPLCP::Receive(): wrong protocol number!\n"); return PPP_UNHANDLED; } diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp index 7d8e6c252b..6e05013f3c 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLCPExtension.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPLCPExtension \brief LCP protocol extension diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLayer.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLayer.cpp index e0e2c5fa83..f929804feb 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLayer.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPLayer.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPLayer \brief An abstract layer that can encapsulate/send and receive packets. @@ -84,7 +82,7 @@ KPPPLayer::SendToNext(struct mbuf *packet, uint16 protocolNumber) const else return Next()->SendToNext(packet, protocolNumber); } else { - dprintf("KPPPLayer: SendToNext() failed because there is no next handler!\n"); + ERROR("KPPPLayer: SendToNext() failed because there is no next handler!\n"); m_freem(packet); return B_ERROR; } diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPOptionHandler.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPOptionHandler.cpp index ad2955a685..d3d452e6e3 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPOptionHandler.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPOptionHandler.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPOptionHandler \brief Handler for LCP configure packets. diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProfile.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProfile.cpp index e025808600..e20b4af8eb 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProfile.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProfile.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPProfile \brief Manages profiles for KPPPInterface. diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProtocol.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProtocol.cpp index 6c649443a5..f7fc00d6db 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProtocol.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPProtocol.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPProtocol. \brief Represents a PPP protocol object. diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPReportManager.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPReportManager.cpp index ccd9d10374..9f0f31f3b9 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPReportManager.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPReportManager.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPReportManager \brief Manager for PPP reports and report requests. @@ -117,10 +115,8 @@ KPPPReportManager::DoesReport(ppp_report_type type, thread_id thread) bool KPPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 length) { -#if DEBUG - dprintf("KPPPReportManager: Report(type=%d code=%ld length=%ld) to %ld receivers\n", + TRACE("KPPPReportManager: Report(type=%d code=%ld length=%ld) to %ld receivers\n", type, code, length, fReportRequests.CountItems()); -#endif if(length > PPP_REPORT_DATA_LIMIT) return false; @@ -157,7 +153,7 @@ KPPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 le #if DEBUG if(result == B_TIMED_OUT) - dprintf("KPPPReportManager::Report(): timed out sending\n"); + TRACE("KPPPReportManager::Report(): timed out sending\n"); #endif thread_info info; @@ -194,31 +190,29 @@ KPPPReportManager::Report(ppp_report_type type, int32 code, void *data, int32 le } if(sender != request->thread) { -#if DEBUG - dprintf("KPPPReportManager::Report(): sender != requested\n"); -#endif + TRACE("KPPPReportManager::Report(): sender != requested\n"); continue; } - if(result == B_OK && code != B_OK) + if(result == B_OK && code != B_OK && code != PPP_OK_DISABLE_REPORTS) acceptable = false; + #if DEBUG if(result == B_TIMED_OUT) - dprintf("KPPPReportManager::Report(): reply timed out\n"); + TRACE("KPPPReportManager::Report(): reply timed out\n"); #endif } // remove thread if it is not existant or if remove-flag is set if(request->flags & PPP_REMOVE_AFTER_REPORT - || get_thread_info(request->thread, &info) != B_OK) { + || get_thread_info(request->thread, &info) != B_OK + || code == PPP_OK_DISABLE_REPORTS) { fReportRequests.RemoveItem(request); --index; } } -#if DEBUG - dprintf("KPPPReportManager::Report(): returning: %s\n", acceptable?"true":"false"); -#endif + TRACE("KPPPReportManager::Report(): returning: %s\n", acceptable?"true":"false"); return acceptable; } diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp index c89e50f0f0..6025a32600 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPStateMachine.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class KPPPStateMachine \brief PPP state machine belonging to the LCP protocol @@ -49,7 +47,8 @@ KPPPStateMachine::KPPPStateMachine(KPPPInterface& interface) fRequestID(0), fTerminateID(0), fEchoID(0), - fNextTimeout(0) + fNextTimeout(0), + fLock("KPPPStateMachine") { } @@ -78,9 +77,7 @@ KPPPStateMachine::NextID() void KPPPStateMachine::NewState(ppp_state next) { -#if DEBUG - dprintf("KPPPSM: NewState(%d) state=%d\n", next, State()); -#endif + TRACE("KPPPSM: NewState(%d) state=%d\n", next, State()); // maybe we do not need the timer anymore if(next < PPP_CLOSING_STATE || next == PPP_OPENED_STATE) @@ -103,7 +100,7 @@ KPPPStateMachine::NewPhase(ppp_phase next) { #if DEBUG if(next <= PPP_ESTABLISHMENT_PHASE || next == PPP_ESTABLISHED_PHASE) - dprintf("KPPPSM: NewPhase(%d) phase=%d\n", next, Phase()); + TRACE("KPPPSM: NewPhase(%d) phase=%d\n", next, Phase()); #endif // there is nothing after established phase and nothing before down phase @@ -117,9 +114,7 @@ KPPPStateMachine::NewPhase(ppp_phase next) if(Phase() == PPP_ESTABLISHED_PHASE && next != Phase()) { if(Interface().Ifnet()) { Interface().Ifnet()->if_flags &= ~IFF_RUNNING; - - if(!Interface().DoesDialOnDemand()) - Interface().Ifnet()->if_flags &= ~IFF_UP; + Interface().Ifnet()->if_flags &= ~IFF_UP; } if(Interface().Parent()) @@ -144,10 +139,7 @@ KPPPStateMachine::NewPhase(ppp_phase next) bool KPPPStateMachine::Reconfigure() { -#if DEBUG - dprintf("KPPPSM: Reconfigure() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: Reconfigure() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -171,10 +163,7 @@ KPPPStateMachine::Reconfigure() bool KPPPStateMachine::SendEchoRequest() { -#if DEBUG - dprintf("KPPPSM: SendEchoRequest() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: SendEchoRequest() state=%d phase=%d\n", State(), Phase()); if(State() != PPP_OPENED_STATE) return false; @@ -202,10 +191,7 @@ KPPPStateMachine::SendEchoRequest() bool KPPPStateMachine::SendDiscardRequest() { -#if DEBUG - dprintf("KPPPSM: SendDiscardRequest() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: SendDiscardRequest() state=%d phase=%d\n", State(), Phase()); if(State() != PPP_OPENED_STATE) return false; @@ -237,10 +223,8 @@ KPPPStateMachine::SendDiscardRequest() void KPPPStateMachine::LocalAuthenticationRequested() { -#if DEBUG - dprintf("KPPPSM: LocalAuthenticationRequested() state=%d phase=%d\n", + TRACE("KPPPSM: LocalAuthenticationRequested() state=%d phase=%d\n", State(), Phase()); -#endif LockerHelper locker(fLock); @@ -263,10 +247,8 @@ KPPPStateMachine::LocalAuthenticationRequested() void KPPPStateMachine::LocalAuthenticationAccepted(const char *name) { -#if DEBUG - dprintf("KPPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n", + TRACE("KPPPSM: LocalAuthenticationAccepted() state=%d phase=%d\n", State(), Phase()); -#endif LockerHelper locker(fLock); @@ -292,10 +274,7 @@ KPPPStateMachine::LocalAuthenticationAccepted(const char *name) void KPPPStateMachine::LocalAuthenticationDenied(const char *name) { -#if DEBUG - dprintf("KPPPSM: LocalAuthenticationDenied() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: LocalAuthenticationDenied() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -314,10 +293,8 @@ KPPPStateMachine::LocalAuthenticationDenied(const char *name) void KPPPStateMachine::PeerAuthenticationRequested() { -#if DEBUG - dprintf("KPPPSM: PeerAuthenticationRequested() state=%d phase=%d\n", + TRACE("KPPPSM: PeerAuthenticationRequested() state=%d phase=%d\n", State(), Phase()); -#endif LockerHelper locker(fLock); @@ -340,10 +317,8 @@ KPPPStateMachine::PeerAuthenticationRequested() void KPPPStateMachine::PeerAuthenticationAccepted(const char *name) { -#if DEBUG - dprintf("KPPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n", + TRACE("KPPPSM: PeerAuthenticationAccepted() state=%d phase=%d\n", State(), Phase()); -#endif LockerHelper locker(fLock); @@ -369,10 +344,7 @@ KPPPStateMachine::PeerAuthenticationAccepted(const char *name) void KPPPStateMachine::PeerAuthenticationDenied(const char *name) { -#if DEBUG - dprintf("KPPPSM: PeerAuthenticationDenied() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: PeerAuthenticationDenied() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -393,10 +365,7 @@ KPPPStateMachine::PeerAuthenticationDenied(const char *name) void KPPPStateMachine::UpFailedEvent(KPPPInterface& interface) { -#if DEBUG - dprintf("KPPPSM: UpFailedEvent(interface) state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: UpFailedEvent(interface) state=%d phase=%d\n", State(), Phase()); // TODO: // log that an interface did not go up @@ -407,10 +376,7 @@ KPPPStateMachine::UpFailedEvent(KPPPInterface& interface) void KPPPStateMachine::UpEvent(KPPPInterface& interface) { -#if DEBUG - dprintf("KPPPSM: UpEvent(interface) state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: UpEvent(interface) state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -438,10 +404,7 @@ KPPPStateMachine::UpEvent(KPPPInterface& interface) void KPPPStateMachine::DownEvent(KPPPInterface& interface) { -#if DEBUG - dprintf("KPPPSM: DownEvent(interface) state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: DownEvent(interface) state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -489,10 +452,7 @@ KPPPStateMachine::DownEvent(KPPPInterface& interface) void KPPPStateMachine::UpFailedEvent(KPPPProtocol *protocol) { -#if DEBUG - dprintf("KPPPSM: UpFailedEvent(protocol) state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: UpFailedEvent(protocol) state=%d phase=%d\n", State(), Phase()); if((protocol->Flags() & PPP_NOT_IMPORTANT) == 0) { if(Interface().Mode() == PPP_CLIENT_MODE) { @@ -519,10 +479,7 @@ KPPPStateMachine::UpFailedEvent(KPPPProtocol *protocol) void KPPPStateMachine::UpEvent(KPPPProtocol *protocol) { -#if DEBUG - dprintf("KPPPSM: UpEvent(protocol) state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: UpEvent(protocol) state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -539,10 +496,7 @@ KPPPStateMachine::UpEvent(KPPPProtocol *protocol) void KPPPStateMachine::DownEvent(KPPPProtocol *protocol) { -#if DEBUG - dprintf("KPPPSM: DownEvent(protocol) state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: DownEvent(protocol) state=%d phase=%d\n", State(), Phase()); } @@ -557,10 +511,7 @@ KPPPStateMachine::DownEvent(KPPPProtocol *protocol) bool KPPPStateMachine::TLSNotify() { -#if DEBUG - dprintf("KPPPSM: TLSNotify() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: TLSNotify() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -586,10 +537,7 @@ KPPPStateMachine::TLSNotify() bool KPPPStateMachine::TLFNotify() { -#if DEBUG - dprintf("KPPPSM: TLFNotify() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: TLFNotify() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -604,10 +552,7 @@ KPPPStateMachine::TLFNotify() void KPPPStateMachine::UpFailedEvent() { -#if DEBUG - dprintf("KPPPSM: UpFailedEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: UpFailedEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -633,10 +578,7 @@ KPPPStateMachine::UpFailedEvent() void KPPPStateMachine::UpEvent() { -#if DEBUG - dprintf("KPPPSM: UpEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: UpEvent() state=%d phase=%d\n", State(), Phase()); // This call is public, thus, it might not only be called by the device. // We must recognize these attempts to fool us and handle them correctly. @@ -703,10 +645,7 @@ KPPPStateMachine::UpEvent() void KPPPStateMachine::DownEvent() { -#if DEBUG - dprintf("KPPPSM: DownEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: DownEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -788,14 +727,13 @@ KPPPStateMachine::DownEvent() if(Interface().DoesAutoRedial()) { if(needsRedial) Interface().Redial(Interface().RedialDelay()); - } else if(!Interface().DoesDialOnDemand()) + } else Interface().Delete(); } else { Interface().Report(PPP_CONNECTION_REPORT, PPP_REPORT_DOWN_SUCCESSFUL, &fInterface.fID, sizeof(ppp_interface_id)); - if(!Interface().DoesDialOnDemand()) - Interface().Delete(); + Interface().Delete(); } fLocalAuthenticationStatus = PPP_NOT_AUTHENTICATED; @@ -807,10 +745,7 @@ KPPPStateMachine::DownEvent() void KPPPStateMachine::OpenEvent() { -#if DEBUG - dprintf("KPPPSM: OpenEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: OpenEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -873,10 +808,7 @@ KPPPStateMachine::OpenEvent() void KPPPStateMachine::CloseEvent() { -#if DEBUG - dprintf("KPPPSM: CloseEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: CloseEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -942,10 +874,7 @@ KPPPStateMachine::CloseEvent() void KPPPStateMachine::TOGoodEvent() { -#if DEBUG - dprintf("KPPPSM: TOGoodEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: TOGoodEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -975,10 +904,7 @@ KPPPStateMachine::TOGoodEvent() void KPPPStateMachine::TOBadEvent() { -#if DEBUG - dprintf("KPPPSM: TOBadEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: TOBadEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1010,10 +936,7 @@ KPPPStateMachine::TOBadEvent() void KPPPStateMachine::RCRGoodEvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RCRGoodEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RCRGoodEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1071,10 +994,7 @@ KPPPStateMachine::RCRGoodEvent(struct mbuf *packet) void KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject) { -#if DEBUG - dprintf("KPPPSM: RCRBadEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RCRBadEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1132,10 +1052,7 @@ KPPPStateMachine::RCRBadEvent(struct mbuf *nak, struct mbuf *reject) void KPPPStateMachine::RCAEvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RCAEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RCAEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1212,10 +1129,7 @@ KPPPStateMachine::RCAEvent(struct mbuf *packet) void KPPPStateMachine::RCNEvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RCNEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RCNEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1295,10 +1209,7 @@ KPPPStateMachine::RCNEvent(struct mbuf *packet) void KPPPStateMachine::RTREvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RTREvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RTREvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1348,10 +1259,7 @@ KPPPStateMachine::RTREvent(struct mbuf *packet) void KPPPStateMachine::RTAEvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RTAEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RTAEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1408,10 +1316,7 @@ void KPPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber, uint8 code = PPP_PROTOCOL_REJECT) { -#if DEBUG - dprintf("KPPPSM: RUCEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RUCEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1433,10 +1338,7 @@ KPPPStateMachine::RUCEvent(struct mbuf *packet, uint16 protocolNumber, void KPPPStateMachine::RXJGoodEvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RXJGoodEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RXJGoodEvent() state=%d phase=%d\n", State(), Phase()); // This method does not m_freem(packet) because the acceptable rejects are // also passed to the parent. RXJEvent() will m_freem(packet) when needed. @@ -1462,10 +1364,7 @@ KPPPStateMachine::RXJGoodEvent(struct mbuf *packet) void KPPPStateMachine::RXJBadEvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RXJBadEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RXJBadEvent() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1515,10 +1414,7 @@ KPPPStateMachine::RXJBadEvent(struct mbuf *packet) void KPPPStateMachine::RXREvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RXREvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RXREvent() state=%d phase=%d\n", State(), Phase()); ppp_lcp_packet *echo = mtod(packet, ppp_lcp_packet*); @@ -1553,7 +1449,7 @@ KPPPStateMachine::TimerEvent() { #if DEBUG if(fNextTimeout != 0) - dprintf("KPPPSM: TimerEvent()\n"); + TRACE("KPPPSM: TimerEvent()\n"); #endif // We might cause a dead-lock. Thus, abort if we cannot get the lock. @@ -1596,10 +1492,7 @@ KPPPStateMachine::TimerEvent() void KPPPStateMachine::RCREvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RCREvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RCREvent() state=%d phase=%d\n", State(), Phase()); KPPPConfigurePacket request(packet); KPPPConfigurePacket nak(PPP_CONFIGURE_NAK); @@ -1620,16 +1513,14 @@ KPPPStateMachine::RCREvent(struct mbuf *packet) optionHandler = LCP().OptionHandlerFor(request.ItemAt(index)->type); if(!optionHandler || !optionHandler->IsEnabled()) { - dprintf("KPPPSM::RCREvent(): unknown type:%d\n", request.ItemAt(index)->type); + ERROR("KPPPSM::RCREvent():unknown type:%d\n", request.ItemAt(index)->type); // unhandled items should be added to the reject reject.AddItem(request.ItemAt(index)); continue; } -#if DEBUG - dprintf("KPPPSM::RCREvent(): OH=%s\n", + TRACE("KPPPSM::RCREvent(): OH=%s\n", optionHandler->Name() ? optionHandler->Name() : "Unknown"); -#endif result = optionHandler->ParseRequest(request, index, nak, reject); if(result == PPP_UNHANDLED) { @@ -1639,7 +1530,7 @@ KPPPStateMachine::RCREvent(struct mbuf *packet) } else if(result != B_OK) { // the request contains a value that has been sent more than // once or the value is corrupted - dprintf("KPPPSM::RCREvent(): OptionHandler returned parse error!\n"); + ERROR("KPPPSM::RCREvent(): OptionHandler returned parse error!\n"); m_freem(packet); CloseEvent(); return; @@ -1658,7 +1549,7 @@ KPPPStateMachine::RCREvent(struct mbuf *packet) if(result != B_OK) { // the request contains a value that has been sent more than // once or the value is corrupted - dprintf("KPPPSM::RCREvent(): OptionHandler returned append error!\n"); + ERROR("KPPPSM::RCREvent():OptionHandler returned append error!\n"); m_freem(packet); CloseEvent(); return; @@ -1684,10 +1575,7 @@ KPPPStateMachine::RCREvent(struct mbuf *packet) void KPPPStateMachine::RXJEvent(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: RXJEvent() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: RXJEvent() state=%d phase=%d\n", State(), Phase()); ppp_lcp_packet *reject = mtod(packet, ppp_lcp_packet*); @@ -1754,7 +1642,7 @@ KPPPStateMachine::IllegalEvent(ppp_event event) { // TODO: // update error statistics - dprintf("KPPPSM: IllegalEvent(event=%d) state=%d phase=%d\n", + ERROR("KPPPSM: IllegalEvent(event=%d) state=%d phase=%d\n", event, State(), Phase()); } @@ -1762,10 +1650,7 @@ KPPPStateMachine::IllegalEvent(ppp_event event) void KPPPStateMachine::ThisLayerUp() { -#if DEBUG - dprintf("KPPPSM: ThisLayerUp() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: ThisLayerUp() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); @@ -1787,10 +1672,7 @@ KPPPStateMachine::ThisLayerUp() void KPPPStateMachine::ThisLayerDown() { -#if DEBUG - dprintf("KPPPSM: ThisLayerDown() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: ThisLayerDown() state=%d phase=%d\n", State(), Phase()); // KPPPProtocol::Down() should block if needed. DownProtocols(); @@ -1800,10 +1682,7 @@ KPPPStateMachine::ThisLayerDown() void KPPPStateMachine::ThisLayerStarted() { -#if DEBUG - dprintf("KPPPSM: ThisLayerStarted() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: ThisLayerStarted() state=%d phase=%d\n", State(), Phase()); if(Interface().Device() && !Interface().Device()->Up()) Interface().Device()->UpFailedEvent(); @@ -1813,10 +1692,7 @@ KPPPStateMachine::ThisLayerStarted() void KPPPStateMachine::ThisLayerFinished() { -#if DEBUG - dprintf("KPPPSM: ThisLayerFinished() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: ThisLayerFinished() state=%d phase=%d\n", State(), Phase()); if(Interface().Device()) Interface().Device()->Down(); @@ -1844,10 +1720,7 @@ KPPPStateMachine::ZeroRestartCount() bool KPPPStateMachine::SendConfigureRequest() { -#if DEBUG - dprintf("KPPPSM: SendConfigureRequest() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: SendConfigureRequest() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); --fRequestCounter; @@ -1874,10 +1747,7 @@ KPPPStateMachine::SendConfigureRequest() bool KPPPStateMachine::SendConfigureAck(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: SendConfigureAck() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: SendConfigureAck() state=%d phase=%d\n", State(), Phase()); if(!packet) return false; @@ -1901,10 +1771,7 @@ KPPPStateMachine::SendConfigureAck(struct mbuf *packet) bool KPPPStateMachine::SendConfigureNak(struct mbuf *packet) { -#if DEBUG - dprintf("KPPPSM: SendConfigureNak() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: SendConfigureNak() state=%d phase=%d\n", State(), Phase()); if(!packet) return false; @@ -1925,10 +1792,7 @@ KPPPStateMachine::SendConfigureNak(struct mbuf *packet) bool KPPPStateMachine::SendTerminateRequest() { -#if DEBUG - dprintf("KPPPSM: SendTerminateRequest() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: SendTerminateRequest() state=%d phase=%d\n", State(), Phase()); LockerHelper locker(fLock); --fTerminateCounter; @@ -1956,10 +1820,7 @@ KPPPStateMachine::SendTerminateRequest() bool KPPPStateMachine::SendTerminateAck(struct mbuf *request = NULL) { -#if DEBUG - dprintf("KPPPSM: SendTerminateAck() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: SendTerminateAck() state=%d phase=%d\n", State(), Phase()); struct mbuf *reply = request; @@ -1988,10 +1849,8 @@ KPPPStateMachine::SendTerminateAck(struct mbuf *request = NULL) bool KPPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uint8 code) { -#if DEBUG - dprintf("KPPPSM: SendCodeReject(protocolNumber=%X;code=%d) state=%d phase=%d\n", + TRACE("KPPPSM: SendCodeReject(protocolNumber=%X;code=%d) state=%d phase=%d\n", protocolNumber, code, State(), Phase()); -#endif if(!packet) return false; @@ -2035,10 +1894,7 @@ KPPPStateMachine::SendCodeReject(struct mbuf *packet, uint16 protocolNumber, uin bool KPPPStateMachine::SendEchoReply(struct mbuf *request) { -#if DEBUG - dprintf("KPPPSM: SendEchoReply() state=%d phase=%d\n", - State(), Phase()); -#endif + TRACE("KPPPSM: SendEchoReply() state=%d phase=%d\n", State(), Phase()); if(!request) return false; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPUtils.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPUtils.cpp index 41f4c2d71b..29f0779499 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPUtils.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/KPPPUtils.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.cpp index 7d13ef2f2f..4cdf0069c1 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include "_KPPPAuthenticationHandler.h" @@ -99,9 +97,7 @@ _KPPPAuthenticationHandler::AddToRequest(KPPPConfigurePacket& request) // this could omit some authenticators when we get a suggestion, but that is // no problem because the suggested authenticator will be accepted (hopefully) -#if DEBUG - dprintf("KPPPAuthHandler: AddToRequest(%X)\n", authenticator->ProtocolNumber()); -#endif + TRACE("KPPPAuthHandler: AddToRequest(%X)\n", authenticator->ProtocolNumber()); authenticator->SetEnabled(true); return authenticator->OptionHandler()->AddToRequest(request); @@ -193,9 +189,7 @@ _KPPPAuthenticationHandler::ParseRequest(const KPPPConfigurePacket& request, return B_OK; // no authentication requested by peer (index > request.CountItems()) -#if DEBUG - dprintf("KPPPAuthHandler: ParseRequest(%X)\n", ntohs(item->protocolNumber)); -#endif + TRACE("KPPPAuthHandler: ParseRequest(%X)\n", ntohs(item->protocolNumber)); // try to find the requested protocol fLocalAuthenticator = Interface().ProtocolFor(ntohs(item->protocolNumber)); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.h index ed26ca1185..d18332b017 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPAuthenticationHandler.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef __K_PPP_AUTHENTICATION_HANDLER__H #define __K_PPP_AUTHENTICATION_HANDLER__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.cpp index 5577db37d5..a5da705bf1 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include "_KPPPMRUHandler.h" diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.h index 3c31ab109c..21c81d49cb 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPMRUHandler.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef __K_PPP_MRU_HANDLER__H #define __K_PPP_MRU_HANDLER__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.cpp index 8e0238c86b..e430ef8972 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include "_KPPPPFCHandler.h" diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.h index 3971e9da5e..7176b45eab 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/_KPPPPFCHandler.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef __K_PPP_PFC_HANDLER__H #define __K_PPP_PFC_HANDLER__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPP.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPP.h index 78fbd4f382..de98c71d06 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPP.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPP.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP__H #define _K_PPP__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPConfigurePacket.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPConfigurePacket.h index 4d253928c6..408dabc15d 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPConfigurePacket.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPConfigurePacket.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_CONFIGURE_PACKET__H #define _K_PPP_CONFIGURE_PACKET__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDefs.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDefs.h index 79c977530f..93a36c1db7 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDefs.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDefs.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_DEFS__H #define _K_PPP_DEFS__H @@ -12,6 +10,15 @@ #include +// debugging macros +#define ERROR(format, args...) dprintf(format, ## args) +#ifdef DEBUG +#define TRACE(format, args...) dprintf(format, ## args) +#else +#define TRACE(format, args...) +#endif + + extern struct core_module_info *core; // needed by core quick-access function defines @@ -19,6 +26,8 @@ extern struct core_module_info *core; // various constants #define PPP_PULSE_RATE 500000 //!< Rate at which Pulse() is called (in microseconds). +#define PPP_RESPONSE_TEST_CODE '_3PT' + // private code used to test if ppp_up did not crash //! Module key types used when loading a module. diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDevice.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDevice.h index 9f2484fa77..e2cd97170e 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDevice.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPDevice.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_DEVICE__H #define _K_PPP_DEVICE__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPInterface.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPInterface.h index 6bd69c456b..dc65524eb3 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPInterface.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPInterface.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_INTERFACE__H #define _K_PPP_INTERFACE__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCP.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCP.h index cf30144766..c8f55b53af 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCP.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCP.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_LCP__H #define _K_PPP_LCP__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h index c9ae7d43a2..96a527ff6b 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef __K_PPP_LCP_EXTENSION__H #define __K_PPP_LCP_EXTENSION__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h index bfedf2174e..c91f4c38b5 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_LAYER__H #define _K_PPP_LAYER__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPManager.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPManager.h index c6f14dfbd3..a9e37feef5 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPManager.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPManager.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_MANAGER__H #define _K_PPP_MANAGER__H @@ -20,11 +18,15 @@ class KPPPInterface; -//! Private structure used by PPP interface manager. +//! Private structure shared by PPP manager and KPPPInterface. typedef struct ppp_interface_entry { + char *name; KPPPInterface *interface; vint32 accessing; bool deleting; + + // ppp_up communication + thread_id requestThread; } ppp_interface_entry; diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPModule.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPModule.h index a035513026..d45b6303c3 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPModule.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPModule.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_MODULE__H #define _K_PPP_MODULE__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h index 1481399a77..74128c64be 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_OPTION_HANDLER__H #define _K_PPP_OPTION_HANDLER__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProfile.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProfile.h index cea85ac9e4..2f4c3e7736 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProfile.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProfile.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_PROFILE__H #define _K_PPP_PROFILE__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProtocol.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProtocol.h index 98d4eb65d5..2d03ca874f 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProtocol.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPProtocol.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_PROTOCOL__H #define _K_PPP_PROTOCOL__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPReportManager.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPReportManager.h index e392cb393b..072fc6c0f8 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPReportManager.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPReportManager.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_REPORT_MANAGER__H #define _K_PPP_REPORT_MANAGER__H @@ -16,10 +14,6 @@ #include -//! Sends a reply to the report message sender. -#define PPP_REPLY(sender, value) \ - send_data_with_timeout((sender), (value), NULL, 0, PPP_REPORT_TIMEOUT) - class KPPPReportManager { public: KPPPReportManager(BLocker& lock); diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPStateMachine.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPStateMachine.h index d75aaa4163..4c3d3532bf 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPStateMachine.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPStateMachine.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_STATE_MACHINE__H #define _K_PPP_STATE_MACHINE__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPUtils.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPUtils.h index daf6bd41cb..99109ab539 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPUtils.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPUtils.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _K_PPP_UTILS__H #define _K_PPP_UTILS__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/LockerHelper.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/LockerHelper.h index 127033b2a4..e8ae588691 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/LockerHelper.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/LockerHelper.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class LockerHelper \brief Helper class for automatically releasing a lock. diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPControl.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPControl.h index 120b18c887..72eb24a410 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPControl.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPControl.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _PPP_CONTROL__H #define _PPP_CONTROL__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h index 6cf9bf9a43..58f031313b 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPDefs.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _PPP_DEFS__H #define _PPP_DEFS__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPReportDefs.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPReportDefs.h index 7472e9c88f..ffb84b05ca 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPReportDefs.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/PPPReportDefs.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _PPP_REPORT_DEFS__H #define _PPP_REPORT_DEFS__H @@ -18,6 +16,13 @@ #define PPP_REPORT_CODE '_3PR' // the code of receive_data() must have this value +//! Sends a reply to the report message sender. +#define PPP_REPLY(sender, value) \ + send_data_with_timeout((sender), (value), NULL, 0, PPP_REPORT_TIMEOUT) + +#define PPP_OK_DISABLE_REPORTS 'OKDR' + // additional reply code (B_OK should be used) + //! Report flags. enum ppp_report_flags { PPP_WAIT_FOR_REPLY = 0x01, diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/settings_tools.h b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/settings_tools.h index cff2a56417..a7ba50b928 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/settings_tools.h +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/settings_tools.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef _SETTINGS_TOOLS__H #define _SETTINGS_TOOLS__H diff --git a/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.cpp b/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.cpp index 3bc6376c9d..d59b2321f2 100644 --- a/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libkernelppp/settings_tools.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include #include diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/Jamfile b/src/add-ons/kernel/network/ppp/shared/libppp/Jamfile index ff0fa5939e..8b893c4e90 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/Jamfile +++ b/src/add-ons/kernel/network/ppp/shared/libppp/Jamfile @@ -10,6 +10,7 @@ StaticLibrary ppp : strlcat.c driver_settings.c settings_tools.cpp + KPPPUtils.cpp _libppputils.cpp PPPInterface.cpp @@ -20,3 +21,4 @@ StaticLibrary ppp : SEARCH on [ FGristFiles strlcat.c ] = [ FDirName $(OBOS_TOP) src kernel libroot posix string ] ; SEARCH on [ FGristFiles driver_settings.c ] = [ FDirName $(OBOS_TOP) src kernel libroot os ] ; SEARCH on [ FGristFiles settings_tools.cpp ] = [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkernelppp ] ; +SEARCH on [ FGristFiles KPPPUtils.cpp ] = [ FDirName $(OBOS_TOP) src add-ons kernel network ppp shared libkernelppp ] ; diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/PPPInterface.cpp b/src/add-ons/kernel/network/ppp/shared/libppp/PPPInterface.cpp index 6d367a85bb..e2733c885b 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/PPPInterface.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libppp/PPPInterface.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class PPPInterface \brief This class represents a PPP interface living in kernel space. diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/PPPInterfaceListener.cpp b/src/add-ons/kernel/network/ppp/shared/libppp/PPPInterfaceListener.cpp index d2a6bcd037..60ca0b538c 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/PPPInterfaceListener.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libppp/PPPInterfaceListener.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class PPPInterfaceListener \brief This class simplifies the process of monitoring PPP interfaces. @@ -29,6 +27,7 @@ #include #include #include +#include static const uint32 kReportFlags = PPP_WAIT_FOR_REPLY | PPP_NO_REPLY_TIMEOUT @@ -92,9 +91,9 @@ PPPInterfaceListenerThread::Run() BHandler *noHandler = NULL; // needed to tell compiler which version of SendMessage we want if(messenger.SendMessage(&message, noHandler, 100000) != B_OK) - send_data(sender, B_OK, NULL, 0); + PPP_REPLY(sender, B_OK); } else - send_data(sender, B_OK, NULL, 0); + PPP_REPLY(sender, B_OK); } return B_OK; diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/PPPManager.cpp b/src/add-ons/kernel/network/ppp/shared/libppp/PPPManager.cpp index a1a3035266..6f1610fb28 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/PPPManager.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libppp/PPPManager.cpp @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ /*! \class PPPManager \brief Allows controlling the PPP stack. @@ -134,12 +132,13 @@ PPPManager::CreateInterface(const driver_settings *settings, /*! \brief Creates an interface with the given name and profile. - Every PPP interface has a profile. By it looks if the pppidf/profile folder - contains a profile with the interface's name. Otherwise the interface's settings - become its profile. This has the advantage that you can put the profile and the - settings into the same file which simplifies your PPP configuration if you edit - your PPP interface definitions by hand. In this case PAP, for example, would - still find the username and password although you specify them in the same + If the interface already exists its ID will be returned. + Every PPP interface has a profile. By default it checks if the pppidf/profile + folder contains a profile with the interface's name. Otherwise the interface's + settings become its profile. This has the advantage that you can put the profile + and the settings into the same file which simplifies your PPP configuration if + you edit your PPP interface definitions by hand. In this case PAP, for example, + would still find the username and password although you specify them in the same parameter that loads the PAP module. \param name The PPP interface description file's name. diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/_libppputils.cpp b/src/add-ons/kernel/network/ppp/shared/libppp/_libppputils.cpp index 8baa5febb6..e503722910 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/_libppputils.cpp +++ b/src/add-ons/kernel/network/ppp/shared/libppp/_libppputils.cpp @@ -1,7 +1,7 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #include #include "_libppputils.h" diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/_libppputils.h b/src/add-ons/kernel/network/ppp/shared/libppp/_libppputils.h index cbfad10da2..3c938b24c1 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/_libppputils.h +++ b/src/add-ons/kernel/network/ppp/shared/libppp/_libppputils.h @@ -1,7 +1,7 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- +/* + * Copyright 2003-2004, Waldemar Kornewald + * Distributed under the terms of the MIT License. + */ #ifndef __libppputils__h #define __libppputils__h diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterface.h b/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterface.h index 32b5aea111..38625b82bf 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterface.h +++ b/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterface.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _PPP_INTERFACE__H #define _PPP_INTERFACE__H diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterfaceListener.h b/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterfaceListener.h index ffd27361ef..cb69567ab1 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterfaceListener.h +++ b/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterfaceListener.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _PPP_INTERFACE_LISTENER__H #define _PPP_INTERFACE_LISTENER__H diff --git a/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPManager.h b/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPManager.h index 99b58b36b6..1996eadee0 100644 --- a/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPManager.h +++ b/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPManager.h @@ -1,9 +1,7 @@ -//----------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de -//----------------------------------------------------------------------- +/* + * Copyright 2003-2004, Haiku Inc. + * Distributed under the terms of the MIT License. + */ #ifndef _PPP_MANAGER__H #define _PPP_MANAGER__H