X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=misc%2Fnetwork_servers%2Fvtl%2Fraw_ethernet_packet.h;fp=misc%2Fnetwork_servers%2Fvtl%2Fraw_ethernet_packet.h;h=2775571f2d8b67fa9965be1d50bd3d108363e46a;hp=0000000000000000000000000000000000000000;hb=ac93f0773f4c6cef2f2f542240695a8706037d41;hpb=c016bb46bd68474161e275a5ace086c3fb810d9f diff --git a/misc/network_servers/vtl/raw_ethernet_packet.h b/misc/network_servers/vtl/raw_ethernet_packet.h new file mode 100644 index 0000000..2775571 --- /dev/null +++ b/misc/network_servers/vtl/raw_ethernet_packet.h @@ -0,0 +1,90 @@ +#ifndef _raw_ethernet_packet +#define _raw_ethernet_packet +#include +#include + +#include "socks.h" + +#ifdef linux +#include +#include +#elif defined(WIN32) + + +#endif + + + +#ifdef USE_SSL +extern "C" { +#define OPENSSL_NO_KRB5 +#include +} +#endif + +class Packet; + +using namespace std; + + +#define ETHERNET_HEADER_LEN 14 +#define ETHERNET_DATA_MIN 46 +#define ETHERNET_DATA_MAX 1500 + +#define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN+ETHERNET_DATA_MAX) + + +#define SERIALIZATION_CLOSED -1 +#define SERIALIZATION_ERROR -2 + +struct RawEthernetPacket { + + char pkt[2 + 4 + ETHERNET_PACKET_LEN]; + char * type; + size_t * size; + char * data; + + size_t get_size() const; + void set_size(size_t new_size); + + char * get_type(); + void set_type(const char * new_type); + + char * get_data(); + + int length() const { return sizeof(pkt);} + + + RawEthernetPacket(); + RawEthernetPacket(const RawEthernetPacket &rhs); + RawEthernetPacket(const char *data, const size_t size); + const RawEthernetPacket & operator= (const RawEthernetPacket &rhs); + virtual ~RawEthernetPacket(); + + int SerializeToBuf(char ** buf) const; + void UnserializeFromBuf(char * buf); + +#ifdef USE_SSL + int Serialize(const SOCK fd, SSL *ssl) const; + int Unserialize(const SOCK fd, SSL *ssl); +#endif + int Serialize(const SOCK fd) const; + int Unserialize(const SOCK fd); + + int UdpSerialize(const SOCK fd,struct sockaddr *serveraddr) const; + int UdpUnserialize(const SOCK fd); + + int VtpSerialize(const SOCK fd, struct in_addr * serveraddr) const; + int VtpUnserialize(const SOCK fd, struct in_addr * serveraddr); + + + + + void Print(unsigned size=ETHERNET_PACKET_LEN, FILE *out=stdout) const; + ostream & Print(ostream &os) const; +}; + +inline ostream & operator<<(ostream &os, const RawEthernetPacket &p) { + return p.Print(os); +} +#endif