]> git.vomp.tv Git - vompclient.git/blob - tcp.h
Send MAC in login packet, volume read from hw at startup
[vompclient.git] / tcp.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3     Copyright 2003-2004 University Of Bradford
4
5     This file is part of VOMP.
6
7     VOMP is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     VOMP is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with VOMP; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 */
21
22 #ifndef TCP_H
23 #define TCP_H
24
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include <errno.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <unistd.h>
32 #include <sys/socket.h>
33 #include <arpa/inet.h>
34 #include <fcntl.h>
35 #include <ctype.h>
36 #include <sys/ioctl.h>
37 #include <net/if.h>
38
39 #include "defines.h"
40 #include "log.h"
41
42 class TCP
43 {
44   public:
45     TCP();
46     ~TCP();
47
48     int connectTo(char *host, unsigned short port);
49     void assignSocket(int tsocket);
50
51     int isConnected();
52     void disableTimeout();
53
54     int sendPacket(void *, size_t size);
55     UCHAR* receivePacket();
56     int getDataLength();
57
58     int readData(UCHAR* buffer, int totalBytes);
59
60     static void dump(unsigned char* data, ULONG size);
61
62     void getMAC(char* dest); // copies 6 MAC bytes to dest
63
64   private:
65     int sock;
66     int connected;
67     int timeoutEnabled;
68     int dataLength;
69
70     static UCHAR dcc(UCHAR c);
71 };
72
73 #endif