ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/device.h
(Generate patch)

Comparing gvpe/src/device.h (file contents):
Revision 1.11 by pcg, Thu Oct 16 02:41:21 2003 UTC vs.
Revision 1.16 by pcg, Thu Mar 3 07:24:57 2005 UTC

1/* 1/*
2 device.h -- generic header for device.c 2 device.h -- generic header for device.c
3 Copyright (C) 2003 Marc Lehmann <pcg@goof.com> 3 Copyright (C) 2003-2004 Marc Lehmann <pcg@goof.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
23#define IFNAMESIZE 256 // be conservative 23#define IFNAMESIZE 256 // be conservative
24 24
25#include "gettext.h" 25#include "gettext.h"
26 26
27#include "global.h" 27#include "global.h"
28#include "util.h"
28 29
29struct net_packet { 30struct net_packet {
30 u32 len; // actually u16, but padding... 31 u32 len; // actually u16, but padding...
31 32
32 u8 &operator[] (u16 offset) const; 33 u8 &operator[] (u16 offset) const;
34 u8 *at (u16 offset) const;
33 35
34 void unshift_hdr (u16 hdrsize) 36 void unshift_hdr (u16 hdrsize)
35 { 37 {
36 memmove ((void *)&(*this)[hdrsize], (void *)&(*this)[0], len); 38 memmove ((void *)&(*this)[hdrsize], (void *)&(*this)[0], len);
37 len += hdrsize; 39 len += hdrsize;
85u8 &net_packet::operator[] (u16 offset) const 87u8 &net_packet::operator[] (u16 offset) const
86{ 88{
87 return ((data_packet *)this)->data_[offset]; 89 return ((data_packet *)this)->data_[offset];
88} 90}
89 91
90typedef u8 mac[6]; 92inline
93u8 *net_packet::at (u16 offset) const
94{
95 return &((*this)[offset]);
96}
91 97
92struct tap_packet : net_packet { 98struct tap_packet : net_packet {
93 mac dst; 99 mac dst;
94 mac src; 100 mac src;
95 u8 data[MAXSIZE - 12]; 101 u8 data[MAXSIZE - 12];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines