The DEBUG version dumps all packets to /boot/home/ipcpdebug.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7208 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5,6 +5,10 @@
|
|||||||
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
// Copyright (c) 2003-2004 Waldemar Kornewald, [email protected]
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
#include <cstdio>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Protocol.h"
|
#include "Protocol.h"
|
||||||
#include "IPCP.h"
|
#include "IPCP.h"
|
||||||
#include <KPPPConfigurePacket.h>
|
#include <KPPPConfigurePacket.h>
|
||||||
@@ -19,6 +23,40 @@
|
|||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
static int sFD;
|
||||||
|
// the file descriptor for debug output
|
||||||
|
static char sDigits[] = "0123456789ABCDEF";
|
||||||
|
void
|
||||||
|
dump_packet(struct mbuf *packet, const char *direction)
|
||||||
|
{
|
||||||
|
if(!packet)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8 *data = mtod(packet, uint8*);
|
||||||
|
uint8 buffer[128];
|
||||||
|
uint8 bufferIndex = 0;
|
||||||
|
|
||||||
|
sprintf((char*) buffer, "Dumping %s packet;len=%ld;pkthdr.len=%d\n", direction,
|
||||||
|
packet->m_len, packet->m_flags & M_PKTHDR ? packet->m_pkthdr.len : -1);
|
||||||
|
write(sFD, buffer, strlen((char*) buffer));
|
||||||
|
|
||||||
|
for(uint32 index = 0; index < packet->m_len; index++) {
|
||||||
|
buffer[bufferIndex++] = sDigits[data[index] >> 4];
|
||||||
|
buffer[bufferIndex++] = sDigits[data[index] & 0x0F];
|
||||||
|
if(bufferIndex == 32 || index == packet->m_len - 1) {
|
||||||
|
buffer[bufferIndex++] = '\n';
|
||||||
|
buffer[bufferIndex] = 0;
|
||||||
|
write(sFD, buffer, strlen((char*) buffer));
|
||||||
|
bufferIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const bigtime_t kIPCPStateMachineTimeout = 3000000;
|
static const bigtime_t kIPCPStateMachineTimeout = 3000000;
|
||||||
// 3 seconds
|
// 3 seconds
|
||||||
|
|
||||||
@@ -39,11 +77,18 @@ IPCP::IPCP(KPPPInterface& interface, driver_parameter *settings)
|
|||||||
fNextTimeout(0)
|
fNextTimeout(0)
|
||||||
{
|
{
|
||||||
ProfileChanged();
|
ProfileChanged();
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
sFD = open("/boot/home/ipcpdebug", O_WRONLY | O_CREAT | O_TRUNC);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IPCP::~IPCP()
|
IPCP::~IPCP()
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
close(sFD);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -193,8 +238,13 @@ IPCP::Send(struct mbuf *packet, uint16 protocolNumber = IPCP_PROTOCOL)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if((protocolNumber == IP_PROTOCOL && State() == PPP_OPENED_STATE)
|
if((protocolNumber == IP_PROTOCOL && State() == PPP_OPENED_STATE)
|
||||||
|| protocolNumber == IPCP_PROTOCOL)
|
|| protocolNumber == IPCP_PROTOCOL) {
|
||||||
|
#if DEBUG
|
||||||
|
dump_packet(packet, "outgoing");
|
||||||
|
#endif
|
||||||
|
Interface().UpdateIdleSince();
|
||||||
return SendToNext(packet, protocolNumber);
|
return SendToNext(packet, protocolNumber);
|
||||||
|
}
|
||||||
|
|
||||||
dprintf("IPCP: Send() failed because of wrong state or protocol number!\n");
|
dprintf("IPCP: Send() failed because of wrong state or protocol number!\n");
|
||||||
|
|
||||||
@@ -278,6 +328,10 @@ IPCP::ReceiveIPPacket(struct mbuf *packet, uint16 protocolNumber)
|
|||||||
// TODO: add VJC support (the packet would be decoded here)
|
// TODO: add VJC support (the packet would be decoded here)
|
||||||
|
|
||||||
if (gProto[IPPROTO_IP] && gProto[IPPROTO_IP]->pr_input) {
|
if (gProto[IPPROTO_IP] && gProto[IPPROTO_IP]->pr_input) {
|
||||||
|
#if DEBUG
|
||||||
|
dump_packet(packet, "incoming");
|
||||||
|
#endif
|
||||||
|
Interface().UpdateIdleSince();
|
||||||
gProto[IPPROTO_IP]->pr_input(packet, 0);
|
gProto[IPPROTO_IP]->pr_input(packet, 0);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user