๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problemas con ether_arp (SOlucionado)

#8280
From: nyenyus
Date: Mon, 09 Dec 2002 00:37
149 lines
3446 bytes
solucionado.
La direccion IP se guarda tal cual, 4 unsigned chars, sin mas :-)
"nyenyus" <nyenyus@smoke.com> escribi๏ฟฝ en el mensaje
news:asnqtn$smnm8$1@ID-165466.news.dfncis.de...
> 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: <at0ojg$vc2an$1@ID-165466.news.dfncis.de>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!162.red-80-36-231.pooles.rima-tde.NET!not-for-mail
References: <asnqtn$smnm8$1@ID-165466.news.dfncis.de>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,aab617d61dc10498
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-12-08 16:37:09 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.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: Re: Problemas con ether_arp (SOlucionado)
Date: Mon, 9 Dec 2002 01:37:01 +0100
Lines: 151
Message-ID: <at0ojg$vc2an$1@ID-165466.news.dfncis.de>
References: <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 1039394228 32901463 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