From owner-freebsd-net@FreeBSD.ORG Sat May 21 03:16:27 2005 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0493D16A4CF for ; Sat, 21 May 2005 03:16:27 +0000 (GMT) Received: from web53907.mail.yahoo.com (web53907.mail.yahoo.com [206.190.36.217]) by mx1.FreeBSD.org (Postfix) with SMTP id 7C78143D82 for ; Sat, 21 May 2005 03:16:26 +0000 (GMT) (envelope-from fetrovsky@yahoo.com) Received: (qmail 77342 invoked by uid 60001); 21 May 2005 03:16:25 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=3ch4ozXj1GXSC/Jf1AWixK8y1MQquySzFe1pBqy1FPqtumuHCzPt7vfHJcm1mi8K7+ipIEXjUPl9uDVnp/FwTTsW60JEChvY9TTm8eS4NesMvtCLa4LTLXvA0F1rVhGVo/MQ2JLOk98SssIiRVr+kyn39b7AY7snjAMy4SJNyqY= ; Message-ID: <20050521031625.77340.qmail@web53907.mail.yahoo.com> Received: from [128.195.64.98] by web53907.mail.yahoo.com via HTTP; Fri, 20 May 2005 20:16:25 PDT Date: Fri, 20 May 2005 20:16:25 -0700 (PDT) From: Daniel Valencia To: freebsd-net@freebsd.org In-Reply-To: 6667 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: sending MAC packets --- again, and again X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 03:16:27 -0000 Hello all, I know this may sound funny, but I'm still wrestling with libpcap because I send packets and I cannot read them. I tried also some example code of a toy sniffer from a tutorial to pcap, and it behaves just like my code. As my code is pretty compact, I'm posting it here. I'm sending from another machine (i'm using a hub this time) an Ethernet message with the payload " la lara la la la la " using broadcast to/from addresses. tcpdump in the sniffing machine tells me that the message is in the wire, but my sniffer just stalls and eventually will report a totally unrelated message. Same thing happens with the other pcap example I borrowed. Sending machine is 4.11-RELEASE, listening machine is 5.4-RELEASE. Any help will be grately appreciated! Thanks - Daniel #include #include void printhexdigit( int val, int pos ) { int dig = (val & (0xf << pos)) >> pos; std::cout << (dig>9)? 'a'+dig-0xa: '0'+dig; } int main() { pcap_t *handle; pcap_pkthdr header; char errbuf[PCAP_ERRBUF_SIZE]; errbuf[0] = 0; handle = pcap_open_live( "xl0", BUFSIZ, 1, 0, errbuf ); if( errbuf[0] ) std::cout << errbuf << std::endl; const u_char *q = pcap_next( handle, &header ); std::cout << "sniffed a packet of length " << header.len << std::endl; for( int i = 0; i < header.len; i++ ) { std::cout << ((i % 0x10)? ((i % 8)? " ": " - "): "\n"); printhexdigit( q[i], 1 ); printhexdigit( q[i], 0 ); } std::cout << std::endl; return 0; } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com