Tizen 2.1 base
[platform/upstream/hplip.git] / io / hpmud / dot4.h
1 /*****************************************************************************\
2
3   dot4.h - 1284.4 support for multi-point transport driver 
4  
5   (c) 2005-2007 Copyright Hewlett-Packard Development Company, LP
6
7   Permission is hereby granted, free of charge, to any person obtaining a copy 
8   of this software and associated documentation files (the "Software"), to deal 
9   in the Software without restriction, including without limitation the rights 
10   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
11   of the Software, and to permit persons to whom the Software is furnished to do 
12   so, subject to the following conditions:
13
14   The above copyright notice and this permission notice shall be included in all
15   copies or substantial portions of the Software.
16
17   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
18   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 
19   FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
20   COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
21   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
22   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 \*****************************************************************************/
25
26 #ifndef _DOT4_H
27 #define _DOT4_H
28
29 enum DOT4_COMMAND
30 {
31   DOT4_INIT = MLC_INIT,
32   DOT4_OPEN_CHANNEL = MLC_OPEN_CHANNEL,
33   DOT4_CLOSE_CHANNEL = MLC_CLOSE_CHANNEL,
34   DOT4_CREDIT = MLC_CREDIT,
35   DOT4_CREDIT_REQUEST = MLC_CREDIT_REQUEST,
36   DOT4_GET_SOCKET = 0x9,
37   DOT4_GET_SERVICE = 0xa,
38   DOT4_EXIT = MLC_EXIT,
39   DOT4_ERROR = MLC_ERROR
40 };
41
42 /*
43  * Note, following structures must be packed. The "pragma pack" statement is not recognized by all gcc compilers (ie: ARM based),
44  * so we use __attribute__((packed)) instead.
45  */
46
47 typedef struct
48 {
49    unsigned char psid;   /* primary socket id (ie: host) */
50    unsigned char ssid;   /* secondary socket id (ie: peripheral) */
51    unsigned short length;   /* packet length (includes header) */ 
52    unsigned char credit;   /* data packet credit, reserved if command */
53    unsigned char control;  /* bit field: 0=normal */
54 } __attribute__((packed)) DOT4Header;
55
56 typedef struct
57 {
58    DOT4Header h;
59    unsigned char cmd;
60    unsigned char rev;
61 } __attribute__((packed)) DOT4Init;
62
63 typedef struct
64 {
65    DOT4Header h;
66    unsigned char cmd;
67    unsigned char result;
68    unsigned char rev;
69 } __attribute__((packed)) DOT4InitReply;
70
71 typedef struct
72 {
73    DOT4Header h;
74    unsigned char cmd;
75 } __attribute__((packed)) DOT4Exit;
76
77 typedef struct
78 {
79    DOT4Header h;
80    unsigned char cmd;
81    unsigned char result;
82 } __attribute__((packed)) DOT4ExitReply;
83
84 typedef struct
85 {
86    DOT4Header h;
87    unsigned char cmd;
88    unsigned char psocket;      /* primary socket id */
89    unsigned char ssocket;      /* secondary socket id */
90    unsigned short maxp2s;      /* max primary to secondary packet size in bytes */
91    unsigned short maxs2p;      /* max secondary to primary packet size in bytes */
92    unsigned short maxcredit;   /* max outstanding credit */
93 } __attribute__((packed)) DOT4OpenChannel;
94
95 typedef struct
96 {
97    DOT4Header h;
98    unsigned char cmd;
99    unsigned char result;
100    unsigned char psocket;
101    unsigned char ssocket;
102    unsigned short maxp2s;      /* max primary to secondary packet size in bytes */
103    unsigned short maxs2p;      /* max secondary to primary packet size in bytes */
104    unsigned short maxcredit;   /* max outstanding credit */
105    unsigned short credit;
106 } __attribute__((packed)) DOT4OpenChannelReply;
107
108 typedef struct
109 {
110    DOT4Header h;
111    unsigned char cmd;
112    unsigned char psocket;      /* primary socket id */
113    unsigned char ssocket;      /* secondary socket id */
114 } __attribute__((packed)) DOT4CloseChannel;
115
116 typedef struct
117 {
118    DOT4Header h;
119    unsigned char cmd;
120    unsigned char result;
121    unsigned char psocket;      /* primary socket id */
122    unsigned char ssocket;      /* secondary socket id */
123 } __attribute__((packed)) DOT4CloseChannelReply;
124
125 typedef struct
126 {
127    DOT4Header h;
128    unsigned char cmd;
129    unsigned char result;
130    unsigned char socket;
131 } __attribute__((packed)) DOT4GetSocketReply; 
132
133 typedef struct
134 {
135    DOT4Header h;
136    unsigned char cmd;
137    unsigned char psocket;
138    unsigned char ssocket;
139    unsigned short credit;    /* credit for sender */ 
140 } __attribute__((packed)) DOT4Credit; 
141
142 typedef struct
143 {
144    DOT4Header h;
145    unsigned char cmd;
146    unsigned char psocket;
147    unsigned char ssocket;
148    unsigned short maxcredit;   /* maximum outstanding credit */
149 } __attribute__((packed)) DOT4CreditRequest; 
150
151 typedef struct
152 {
153    DOT4Header h;
154    unsigned char cmd;
155    unsigned char result;
156    unsigned char psocket;
157    unsigned char ssocket;
158    unsigned short credit;   /* credit for sender */
159 } __attribute__((packed)) DOT4CreditRequestReply; 
160
161 typedef struct
162 {
163    DOT4Header h;
164    unsigned char cmd;
165    unsigned char psocket;     /* primary socket id which contains the error */
166    unsigned char ssocket;     /* secondary socket id which contains the error */
167    unsigned char error;
168 } __attribute__((packed)) DOT4Error; 
169
170 typedef DOT4ExitReply DOT4Reply;
171 typedef DOT4Exit DOT4Cmd;
172 typedef DOT4CloseChannelReply DOT4CreditReply;
173 typedef DOT4Exit DOT4GetSocket;
174
175 int __attribute__ ((visibility ("hidden"))) Dot4ReverseCmd(struct _mud_channel *pc, int fd);
176 int __attribute__ ((visibility ("hidden"))) Dot4Init(struct _mud_channel *pc, int fd);
177 int __attribute__ ((visibility ("hidden"))) Dot4Exit(struct _mud_channel *pc, int fd);
178 int __attribute__ ((visibility ("hidden"))) Dot4GetSocket(struct _mud_channel *pc, int fd);
179 int __attribute__ ((visibility ("hidden"))) Dot4ForwardData(struct _mud_channel *pc, int fd, const void *buf, int size, int usec_timeout);
180 int __attribute__ ((visibility ("hidden"))) Dot4ReverseData(struct _mud_channel *pc, int fd, void *buf, int length, int usec_timeout);
181 int __attribute__ ((visibility ("hidden"))) Dot4OpenChannel(struct _mud_channel *pc, int fd);
182 int __attribute__ ((visibility ("hidden"))) Dot4CloseChannel(struct _mud_channel *pc, int fd);
183 int __attribute__ ((visibility ("hidden"))) Dot4Credit(struct _mud_channel *pc, int fd, unsigned short credit);
184 int __attribute__ ((visibility ("hidden"))) Dot4CreditRequest(struct _mud_channel *pc, int fd, unsigned short credit);
185
186 #endif // _DOT4_H
187