11 #include <sys/socket.h>
14 #include <netinet/in.h>
15 #include <arpa/inet.h>
16 #include <netinet/in.h>
24 #define EWOULDBLOCK WSAEWOULDBLOCK
26 typedef int socklen_t;
33 #define ETHERNET_HEADER_LEN 14
34 #define ETHERNET_DATA_MIN 46
35 #define ETHERNET_DATA_MAX 1500
37 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN+ETHERNET_DATA_MAX)
42 #define OPENSSL_NO_KRB5
43 #include <openssl/ssl.h>
50 int readall(const int fd, SSL * ssl, char * buf, const int len, const int oneshot = 0, const int awaitblock = 1);
51 int writeall(const int fd, SSL * ssl, const char * buf, const int len, const int oneshot = 0, const int awaitblock = 1);
53 int readall(const int fd, char * buf, const int len, const int oneshot = 0, const int awaitblock = 1);
54 int writeall(const int fd, const char * buf, const int len, const int oneshot = 0, const int awaitblock = 1);
59 #define snprintf _snprintf
63 int compare_nocase(const string &s1, const string &s2);
65 struct SerializationException {};
67 void printhexnybble(FILE * out,const char lower);
68 void printhexbyte(FILE * out,const char h);
69 void printhexshort(FILE * out,const short h);
70 void printhexint(FILE * out,const int h);
71 void printhexbuffer(FILE * out, const char * buf, const int len);
73 void hexbytetobyte(const char hexbyte[2], char * byte);
74 void bytetohexbyte(const char byte, char hexbyte[2]);
76 void ConvertHexEthernetAddressToBinary(const char * string, char address[6]);
77 void ConvertBinaryEthernetAddressToHex(char address[6], char * string);
79 // How about a function that you might actually use...
80 void mac_to_string(char address[6], char * buf);
81 void mac_to_string(char address[6], string * str);
82 void string_to_mac(string str, char mac[6]);
83 void string_to_mac(const char * str, char mac[6]);
85 void ip_to_string(unsigned long addr, string * str);
86 void ip_to_string(unsigned long addr, char * buf);
87 const char * ip_to_string(unsigned long addr);
89 typedef char EthernetAddrString[(2 * 6) + 6];
96 EthernetAddr(const EthernetAddr &rhs);
97 EthernetAddr(const EthernetAddrString rhs);
98 const EthernetAddr & operator=(const EthernetAddr &rhs);
100 bool operator==(const EthernetAddr &rhs) const;
102 void SetToString(const EthernetAddrString s);
103 void GetAsString(EthernetAddrString s) const;
106 void Serialize(const int fd, SSL * ssl) const;
107 void Unserialize(const int fd,SSL * ssl);
109 void Serialize(const int fd) const;
110 void Unserialize(const int fd);
113 ostream & Print(ostream &os) const;
116 inline ostream & operator<<(ostream &os, const EthernetAddr &e)