aboutsummaryrefslogtreecommitdiffstats
path: root/ncpd/packet.h
blob: 8348ba7d90d094aec2d6ad717a3b3115b14294d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef _packet_h
#define _packet_h

#include <stdio.h>

#include "bool.h"
class psiEmul;
class bufferStore;
class IOWatch;

#define PKT_DEBUG_LOG  1
#define PKT_DEBUG_DUMP 2

class packet {
	public:
		packet(const char *fname, int baud, IOWatch &iow, short int verbose = 0);
		~packet();
		void send(unsigned char type, const bufferStore &b);
		bool get(unsigned char &type, bufferStore &b);
		void setVerbose(short int);
		short int getVerbose();
		bool linkFailed();
  
	private:
		bool terminated();
		void addToCrc(unsigned short a, unsigned short *crc);
		void opByte(unsigned char a);
		void realWrite();

		unsigned short crcOut;
		unsigned short crcIn;
		unsigned char *inPtr;
		unsigned char *outPtr;
		unsigned char *endPtr;
		unsigned char *inBuffer;
		unsigned char *outBuffer;
		bufferStore rcv;
		int inLen;
		int outLen;
		int termLen;
		int fd;
		bool verbose;
		bool esc;
		char *devname;
		int baud;
		IOWatch &iow;
};

#endif