2006-02-02 16:55:44 +01:00
|
|
|
#ifndef _NETPKT_H_
|
|
|
|
#define _NETPKT_H_
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2006-02-20 12:31:34 +01:00
|
|
|
#define PARSE_ACCEPT 1
|
|
|
|
#define PARSE_ACCEPT_FREED 2
|
|
|
|
#define PARSE_REJECT 4
|
2006-02-02 16:55:44 +01:00
|
|
|
|
2006-03-05 02:28:19 +01:00
|
|
|
/* avoid cyclic deps */
|
|
|
|
class Socket;
|
|
|
|
|
2006-02-02 16:55:44 +01:00
|
|
|
class NetPkt {
|
2006-03-05 02:28:19 +01:00
|
|
|
friend class Socket;
|
2006-02-02 16:55:44 +01:00
|
|
|
public:
|
2006-03-05 02:28:19 +01:00
|
|
|
NetPkt(const char* data, int size);
|
|
|
|
NetPkt(int size);
|
2006-02-02 16:55:44 +01:00
|
|
|
~NetPkt();
|
|
|
|
|
|
|
|
int show(char* buf, int size);
|
2006-02-20 12:31:34 +01:00
|
|
|
bool compare(int offset, const char* buf, int len);
|
2006-02-20 21:58:59 +01:00
|
|
|
int find(int offset, const char *buf, int len);
|
2006-03-05 02:28:19 +01:00
|
|
|
|
|
|
|
void setAddress(struct sockaddr_in *addr);
|
|
|
|
struct sockaddr_in * getAddress();
|
|
|
|
|
2006-02-02 16:55:44 +01:00
|
|
|
protected:
|
|
|
|
NetPkt(const NetPkt& x);
|
|
|
|
NetPkt& operator=(const NetPkt& x);
|
|
|
|
|
|
|
|
struct sockaddr_in addr;
|
2006-03-05 02:28:19 +01:00
|
|
|
const char *data;
|
|
|
|
int used;
|
|
|
|
|
|
|
|
private:
|
2006-02-02 16:55:44 +01:00
|
|
|
int size;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _NETPKT_H_
|