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
|
|
|
|
|
|
|
class NetPkt {
|
|
|
|
public:
|
|
|
|
~NetPkt();
|
|
|
|
|
|
|
|
static NetPkt* createFromSocket(int fd);
|
|
|
|
int show(char* buf, int size);
|
|
|
|
|
2006-02-20 12:31:34 +01:00
|
|
|
int checkPortArray(struct game_ports* arr);
|
|
|
|
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-02-20 12:31:34 +01:00
|
|
|
|
2006-02-02 16:55:44 +01:00
|
|
|
protected:
|
|
|
|
NetPkt(const NetPkt& x);
|
|
|
|
NetPkt& operator=(const NetPkt& x);
|
|
|
|
|
|
|
|
private:
|
|
|
|
NetPkt(int size);
|
|
|
|
int readFromSocket(int fd);
|
|
|
|
|
|
|
|
struct sockaddr_in addr;
|
|
|
|
int size;
|
|
|
|
char *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _NETPKT_H_
|