🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #8260

Problemas con ether_arp

#8260
From: nyenyus
Date: Thu, 05 Dec 2002 15:21
140 lines
2997 bytes
Hola,

llevo unso dias programando una aplicacion que me analice la cabecera MAC y

ARP de un paquete capturado con pcap.


La cabecera MAC es analizada correctamente, pero cuando empiezo con la

cabecera ARP, no consiguo que me retorne correctamente las direcciones de

protocolo (las de hard -o MAC- si me las da bien), sino que la direccion

que me da es una 255.255.255.255 tanto para origen como destino.


Posteo el .H de la clase, asi como el codigo de la funcion problematica.

Si alguien quiere todo el fuente, que lo pida, y se lo envio.


Cabecera_ARP.h

---------------

#ifndef _CABECERA_ARP_

#define _CABECERA_ARP_

#include <string>

//#include <net/if_arp.h>

#include <netinet/if_ether.h>

#include <arpa/inet.h>

#include <netinet/ether.h>

#include "Excepciones.h"

#define HARD_ADDR 0

#define PROT_ADDR 1

#define SRC_ADDR 0

#define DST_ADDR 1

class Cabecera_ARP

{

public:

Cabecera_ARP(struct ether_arp * arp);

~Cabecera_ARP(){};

std::string TipoHard (void);

std::string Protocolo (void);

int Longitud (int quien);

std::string Operacion (void);

std::string Direccion (int quien, int cual); /*la que me da

problemas*/

private:

struct ether_arp * arp_ptr;

};

#endif


Funcion correspondiente en Cabecera_ARP.cpp

-------------------------------------------


/**

* direcciones origen y destino ARP

* quien -->ORIGEN O DESTINO cual --> HARD o PROTOCOLO

*/

std::string Cabecera_ARP::Direccion (int quien, int cual)

{

in_addr aux;

std::string str = "";

if (quien==SRC_ADDR)

{

if (cual==HARD_ADDR)

str = ::ether_ntoa((struct ether_addr *)arp_ptr -> arp_sha);

else { /* Direccion del protocolo */

aux.s_addr = inet_addr((const char *)arp_ptr->arp_spa);

str = ::inet_ntoa(aux);

}

}else{

if (cual==HARD_ADDR)

str = ::ether_ntoa((struct ether_addr *)arp_ptr -> arp_tha);

else{

aux.s_addr = inet_addr((const char *)arp_ptr->arp_tpa);

str = ::inet_ntoa(aux);

}

}

return str;

}



A ver si alguien sabe de k va el tema. Gracias
Technical Details
Message-ID: <asnqtn$smnm8$1@ID-165466.news.dfncis.de>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!162.red-80-36-231.pooles.rima-tde.NET!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII-7-bit
X-Google-Thread: f86c8,aab617d61dc10498,start
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-12-05 07:21:31 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!162.red-80-36-231.pooles.rima-tde.NET!not-for-mail
From: "nyenyus" <nyenyus@smoke.com>
Newsgroups: es.comp.os.linux.programacion
Subject: Problemas con ether_arp
Date: Thu, 5 Dec 2002 16:21:20 +0100
Lines: 144
Message-ID: <asnqtn$smnm8$1@ID-165466.news.dfncis.de>
NNTP-Posting-Host: 162.red-80-36-231.pooles.rima-tde.net (80.36.231.162)
X-Trace: fu-berlin.de 1039101690 30105288 80.36.231.162 (16 [165466])
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106