summaryrefslogtreecommitdiff
path: root/io/hpmud/dot4.h
blob: 26231944fb70381227b7decfd9ce3a0ffdeb1170 (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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*****************************************************************************\

  dot4.h - 1284.4 support for multi-point transport driver 
 
  (c) 2005-2007 Copyright Hewlett-Packard Development Company, LP

  Permission is hereby granted, free of charge, to any person obtaining a copy 
  of this software and associated documentation files (the "Software"), to deal 
  in the Software without restriction, including without limitation the rights 
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
  of the Software, and to permit persons to whom the Software is furnished to do 
  so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 
  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

\*****************************************************************************/

#ifndef _DOT4_H
#define _DOT4_H

enum DOT4_COMMAND
{
  DOT4_INIT = MLC_INIT,
  DOT4_OPEN_CHANNEL = MLC_OPEN_CHANNEL,
  DOT4_CLOSE_CHANNEL = MLC_CLOSE_CHANNEL,
  DOT4_CREDIT = MLC_CREDIT,
  DOT4_CREDIT_REQUEST = MLC_CREDIT_REQUEST,
  DOT4_GET_SOCKET = 0x9,
  DOT4_GET_SERVICE = 0xa,
  DOT4_EXIT = MLC_EXIT,
  DOT4_ERROR = MLC_ERROR
};

/*
 * Note, following structures must be packed. The "pragma pack" statement is not recognized by all gcc compilers (ie: ARM based),
 * so we use __attribute__((packed)) instead.
 */

typedef struct
{
   unsigned char psid;   /* primary socket id (ie: host) */
   unsigned char ssid;   /* secondary socket id (ie: peripheral) */
   unsigned short length;   /* packet length (includes header) */ 
   unsigned char credit;   /* data packet credit, reserved if command */
   unsigned char control;  /* bit field: 0=normal */
} __attribute__((packed)) DOT4Header;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char rev;
} __attribute__((packed)) DOT4Init;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char result;
   unsigned char rev;
} __attribute__((packed)) DOT4InitReply;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
} __attribute__((packed)) DOT4Exit;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char result;
} __attribute__((packed)) DOT4ExitReply;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char psocket;      /* primary socket id */
   unsigned char ssocket;      /* secondary socket id */
   unsigned short maxp2s;      /* max primary to secondary packet size in bytes */
   unsigned short maxs2p;      /* max secondary to primary packet size in bytes */
   unsigned short maxcredit;   /* max outstanding credit */
} __attribute__((packed)) DOT4OpenChannel;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char result;
   unsigned char psocket;
   unsigned char ssocket;
   unsigned short maxp2s;      /* max primary to secondary packet size in bytes */
   unsigned short maxs2p;      /* max secondary to primary packet size in bytes */
   unsigned short maxcredit;   /* max outstanding credit */
   unsigned short credit;
} __attribute__((packed)) DOT4OpenChannelReply;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char psocket;      /* primary socket id */
   unsigned char ssocket;      /* secondary socket id */
} __attribute__((packed)) DOT4CloseChannel;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char result;
   unsigned char psocket;      /* primary socket id */
   unsigned char ssocket;      /* secondary socket id */
} __attribute__((packed)) DOT4CloseChannelReply;

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char result;
   unsigned char socket;
} __attribute__((packed)) DOT4GetSocketReply; 

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char psocket;
   unsigned char ssocket;
   unsigned short credit;    /* credit for sender */ 
} __attribute__((packed)) DOT4Credit; 

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char psocket;
   unsigned char ssocket;
   unsigned short maxcredit;   /* maximum outstanding credit */
} __attribute__((packed)) DOT4CreditRequest; 

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char result;
   unsigned char psocket;
   unsigned char ssocket;
   unsigned short credit;   /* credit for sender */
} __attribute__((packed)) DOT4CreditRequestReply; 

typedef struct
{
   DOT4Header h;
   unsigned char cmd;
   unsigned char psocket;     /* primary socket id which contains the error */
   unsigned char ssocket;     /* secondary socket id which contains the error */
   unsigned char error;
} __attribute__((packed)) DOT4Error; 

typedef DOT4ExitReply DOT4Reply;
typedef DOT4Exit DOT4Cmd;
typedef DOT4CloseChannelReply DOT4CreditReply;
typedef DOT4Exit DOT4GetSocket;

int __attribute__ ((visibility ("hidden"))) Dot4ReverseCmd(struct _mud_channel *pc, int fd);
int __attribute__ ((visibility ("hidden"))) Dot4Init(struct _mud_channel *pc, int fd);
int __attribute__ ((visibility ("hidden"))) Dot4Exit(struct _mud_channel *pc, int fd);
int __attribute__ ((visibility ("hidden"))) Dot4GetSocket(struct _mud_channel *pc, int fd);
int __attribute__ ((visibility ("hidden"))) Dot4ForwardData(struct _mud_channel *pc, int fd, const void *buf, int size, int usec_timeout);
int __attribute__ ((visibility ("hidden"))) Dot4ReverseData(struct _mud_channel *pc, int fd, void *buf, int length, int usec_timeout);
int __attribute__ ((visibility ("hidden"))) Dot4OpenChannel(struct _mud_channel *pc, int fd);
int __attribute__ ((visibility ("hidden"))) Dot4CloseChannel(struct _mud_channel *pc, int fd);
int __attribute__ ((visibility ("hidden"))) Dot4Credit(struct _mud_channel *pc, int fd, unsigned short credit);
int __attribute__ ((visibility ("hidden"))) Dot4CreditRequest(struct _mud_channel *pc, int fd, unsigned short credit);

#endif // _DOT4_H