--- gvpe/src/device.h 2003/10/16 02:41:21 1.11 +++ gvpe/src/device.h 2007/12/02 00:09:36 1.21 @@ -1,8 +1,10 @@ /* device.h -- generic header for device.c - Copyright (C) 2003 Marc Lehmann + Copyright (C) 2003-2005 Marc Lehmann - This program is free software; you can redistribute it and/or modify + This file is part of GVPE. + + GVPE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -13,23 +15,26 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + along with gvpe; if not, write to the Free Software + Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef VPE_DEVICE_H__ -#define VPE_DEVICE_H__ +#ifndef GVPE_DEVICE_H__ +#define GVPE_DEVICE_H__ -#define IFNAMESIZE 256 // be conservative +#include "config.h" -#include "gettext.h" +#define IFNAMESIZE 256 // be conservative #include "global.h" +#include "util.h" -struct net_packet { +struct net_packet +{ u32 len; // actually u16, but padding... u8 &operator[] (u16 offset) const; + u8 *at (u16 offset) const; void unshift_hdr (u16 hdrsize) { @@ -77,7 +82,8 @@ void operator delete (void *p); }; -struct data_packet : net_packet { +struct data_packet : net_packet +{ u8 data_[MAXSIZE]; }; @@ -87,15 +93,21 @@ return ((data_packet *)this)->data_[offset]; } -typedef u8 mac[6]; +inline +u8 *net_packet::at (u16 offset) const +{ + return &((*this)[offset]); +} -struct tap_packet : net_packet { +struct tap_packet : net_packet +{ mac dst; mac src; u8 data[MAXSIZE - 12]; }; -struct tap_device { +struct tap_device +{ int fd; // network interface name or identifier @@ -111,6 +123,7 @@ const char *interface () { return ifrname; } const char *info (); + const char *if_up (); tap_packet *recv (); void send (tap_packet *pkt);