[insert project logo here (125x200px max)]

Navigator

Mailinglists

Please report any errors or ommissions you find to our `Help' mailinglist, or post a message in the Forums.

Copyright and Licensing Information

Snap is (c) Jonathan T. Moore, 1999-2002 and licensed under the GNU General Public License (GPL).

All other parts of Splash are (c) Willem de Bruijn, 2002-2003 and licensed under the BSD Open Source License.

All sourcecode is made publicly available.

Acknowledgement

Splash and the Splash website are hosted by SourceForge.net

SourceForge.net Logo

osi-open source certified logo

Splash - Documentation

SNMP Plus a Lightweight API for SNAP Handling

Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

snap-1.1-wjdb/lib/snapnet.c

Go to the documentation of this file.
00001 /* $Id: snapnet.c,v 1.2 2002/12/08 17:08:41 wdebruij Exp $ */
00002 
00003 #include <netinet/ip.h>
00004 #include <sys/socket.h>
00005 #include <sys/types.h>
00006 #include "io.h"
00007 #include "packet.h"
00008 #include "snap.h"
00009 #include "d_printf.h"
00010 
00011 #define MAX_MTU 3924
00012 
00013 char pbuf[3 * MAX_MTU];
00014 
00015 int snap_recv_pkt(int sock, packet_t **p) {
00016 
00017   struct iphdr *iph;
00018   int len;
00019 
00020   if ((len = recvfrom(sock, pbuf, sizeof(pbuf), 0, NULL, NULL)) < 0) {
00021     perror("recvfrom");
00022     *p = NULL;
00023     return -1;
00024   }
00025 
00026   iph = (struct iphdr *)pbuf;
00027     /* verify it's a SNAP packet */
00028     if ((iph->protocol != IPPROTO_SNAP) || (iph->ihl < 6)) {
00029         return -1;
00030     }
00031 
00032   *p = unmarshal_packet(pbuf, len, sizeof(pbuf));
00033   if (*p == NULL) {
00034     return -1;
00035   } else {
00036     return 0;
00037   }
00038 }