-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcp.h
120 lines (97 loc) · 2.27 KB
/
tcp.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* This source file is Copyright 1995 by Evan Scott.
* All rights reserved.
* Permission is granted to distribute this file provided no
* fees beyond distribution costs are levied.
*/
typedef union
{
struct
{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
} dot;
unsigned long l;
} ipnum;
typedef union
{
struct
{
unsigned char a;
unsigned char b;
} dot;
unsigned short w;
} portnum;
/* something like an iorequest ... probably a real exec device
implementation would be good, but for now just DIY */
typedef struct tcpm
{
struct Message header;
magic_verify;
unsigned long command;
void* ident; /* stores pointer to context information */
ipnum address;
portnum port;
void* data;
struct tcpm* interrupt;
unsigned long length;
unsigned long result;
unsigned long error;
unsigned long flags;
unsigned long userid;
void* userdata;
} tcpmessage;
typedef struct
{
magic_verify;
signed long fd;
void* connecting_port;
boolean eof;
} tcpident;
#define V_tcpmessage 4159
#define V_tcpident 7592
/* commands */
#define TCP_NOOP 0
#define TCP_CONNECT 1
#define TCP_LISTEN 2
#define TCP_READ 3
#define TCP_WRITE 4
#define TCP_CLOSE 5
#define TCP_INTERRUPT 6
/* hmmm, keep these??? */
#define TCP_NEWMESSAGE 7
#define TCP_DISPOSE 8
/* internal */
#define TCP_CONNECTED 9 /* CONNECT reply */
#define TCP_ACCEPTED 10 /* Async ACCEPT */
#define TCP_WRITTEN 11 /* WRITE reply (not used) */
#define TCP_GOT 12 /* READ reply (not used) */
#define TCP_STARTUP 13 /* STARTUP was successful/unsuccessful */
#define TCP_DIE 14
/* info */
#define TCP_PEERNAME 15
#define TCP_SERVICE 16
/* errors */
#define NO_ERROR 0
#define ERROR_OOM 1
#define ERROR_UNKNOWN_COMMAND 2
#define ERROR_NO_CONNECTION 3
#define ERROR_LOST_CONNECTION 4
#define ERROR_ALREADY_CONNECTED 5
#define ERROR_ACCESS_DENIED 6
#define ERROR_EOF 7
#define ERROR_INTERRUPTED 8
#define ERROR_UNKNOWN_HOST 9
#define ERROR_CANT_CONNECT 10
#define ERROR_UNREACHABLE 11
#define ERROR_CONNECT_REFUSED 12
/* flags */
#define FLAG_READLINE 1
#ifndef __MORPHOS__
void SAVEDS ASM tcp_handler(REG(a0, unsigned char *parent_port));
#else
void tcp_handler(unsigned char *parent_port);
#endif
void unique_name(void*, unsigned char*, unsigned char*);