-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathheader.h
77 lines (60 loc) · 1.55 KB
/
header.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* File : dcomm.h
*/
#ifndef _RECEIVER_H_
#define _RECEIVER_H_
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
/* ASCII Const */
#define SOH 1 /* Start of Header Character */
#define STX 2 /* Start of Text Character */
#define ETX 3 /* End of Text Character */
#define ENQ 5 /* Enquiry Character */
#define ACK 6 /* Acknowledgement */
#define BEL 7 /* Message Error Warning */
#define CR 13 /* Carriage Return */
#define LF 10 /* Line Feed */
#define NAK 21 /* Negative Acknowledgement */
#define Endfile 26 /* End of file character */
#define ESC 27 /* ESC key */
/* Const */
#define BYTESIZE 256 /* The maximum value of a byte */
#define MAXLEN 1024 /* Maximum messages length */
#define DELAY 1
#define bzero(p, size) (void)memset((p), 0 , (size))
/* Define receive buffer size */
#define WINDOWSIZE 3
#define BUFMAX 7 /* Maximum size of buffer that can be sent */
typedef unsigned char Byte;
/* FRAMES AND WINDOW */
typedef struct MESGB {
unsigned int soh;
unsigned int stx;
unsigned int etx;
Byte checksum;
Byte msgno;
char data[BUFMAX];
} MESGB;
typedef struct QTYPE {
unsigned int count, front, rear, maxsize;
MESGB *window;
} QTYPE;
//////////////////////
/* ACKNOWLEDGMENTS */
typedef struct RESPL {
unsigned int ack;
Byte msgno;
Byte checksum;
} RESPL;
/////////////////////
/* FUNCTIONS AND PROCEDURES */
void *childRProcess(void * threadid);
void error(const char* message);
#endif