1 /*****************************************************************************\ 2 3 mlc.h - MLC support for multi-point transport driver 4 5 (c) 2004-2007 Copyright HP 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 _MLC_H 27 #define _MLC_H 28 29 enum MLC_COMMAND 30 { 31 MLC_INIT = 0, 32 MLC_OPEN_CHANNEL = 1, 33 MLC_CLOSE_CHANNEL = 2, 34 MLC_CREDIT = 3, 35 MLC_CREDIT_REQUEST = 4, 36 MLC_DEBIT = 5, 37 MLC_DEBIT_REQUEST = 6, 38 MLC_CONFIG_SOCKET = 7, 39 MLC_EXIT = 8, 40 MLC_ERROR = 0x7f 41 }; 42 43 typedef struct 44 { 45 unsigned char hsid; /* host socket id */ 46 unsigned char psid; /* peripheral socket id */ 47 unsigned short length; /* packet length (includes header) */ 48 unsigned char credit; /* data packet credit, reserved if command */ 49 unsigned char status; /* upper layer status */ 50 } __attribute__((packed)) MLCHeader; 51 52 typedef struct 53 { 54 MLCHeader h; 55 unsigned char cmd; 56 unsigned char rev; 57 } __attribute__((packed)) MLCInit; 58 59 typedef struct 60 { 61 MLCHeader h; 62 unsigned char cmd; 63 unsigned char result; 64 unsigned char rev; 65 } __attribute__((packed)) MLCInitReply; 66 67 typedef struct 68 { 69 MLCHeader h; 70 unsigned char cmd; 71 } __attribute__((packed)) MLCExit; 72 73 typedef struct 74 { 75 MLCHeader h; 76 unsigned char cmd; 77 unsigned char result; 78 } __attribute__((packed)) MLCExitReply; 79 80 typedef struct 81 { 82 MLCHeader h; 83 unsigned char cmd; 84 unsigned char socket; /* socket id */ 85 unsigned short h2psize; /* host-to-peripheral packet size */ 86 unsigned short p2hsize; /* peripheral-to-host packet size */ 87 unsigned char status; /* status level */ 88 } __attribute__((packed)) MLCConfigSocket; 89 90 typedef struct 91 { 92 MLCHeader h; 93 unsigned char cmd; 94 unsigned char result; 95 unsigned short h2psize; /* host-to-peripheral packet size */ 96 unsigned short p2hsize; /* peripheral-to-host packet size */ 97 unsigned char status; /* status level */ 98 } __attribute__((packed)) MLCConfigSocketReply; 99 100 typedef struct 101 { 102 MLCHeader h; 103 unsigned char cmd; 104 unsigned char hsocket; /* host socket id */ 105 unsigned char psocket; /* peripheral socket id */ 106 unsigned short credit; 107 } __attribute__((packed)) MLCOpenChannel; 108 109 typedef struct 110 { 111 MLCHeader h; 112 unsigned char cmd; 113 unsigned char result; 114 unsigned short credit; 115 } __attribute__((packed)) MLCOpenChannelReply; 116 117 typedef struct 118 { 119 MLCHeader h; 120 unsigned char cmd; 121 unsigned char hsocket; /* host socket id */ 122 unsigned char psocket; /* peripheral socket id */ 123 } __attribute__((packed)) MLCCloseChannel; 124 125 typedef MLCExitReply MLCCloseChannelReply; 126 typedef MLCExitReply MLCReply; 127 typedef MLCExit MLCCmd; 128 typedef MLCOpenChannel MLCCredit; 129 typedef MLCExitReply MLCCreditReply; 130 typedef MLCOpenChannel MLCCreditRequest; 131 typedef MLCOpenChannelReply MLCCreditRequestReply; 132 typedef MLCExitReply MLCError; 133 134 struct _mud_device; 135 struct _mud_channel; 136 137 int __attribute__ ((visibility ("hidden"))) cut_buf(struct _mud_channel *pc, char *buf, int size); 138 int __attribute__ ((visibility ("hidden"))) MlcInit(struct _mud_channel *pc, int fd); 139 int __attribute__ ((visibility ("hidden"))) MlcExit(struct _mud_channel *pc, int fd); 140 int __attribute__ ((visibility ("hidden"))) MlcConfigSocket(struct _mud_channel *pc, int fd); 141 int __attribute__ ((visibility ("hidden"))) MlcForwardData(struct _mud_channel *pc, int fd, const void *buf, int size, int usec_timeout); 142 int __attribute__ ((visibility ("hidden"))) MlcReverseData(struct _mud_channel *pc, int fd, void *buf, int length, int usec_timeout); 143 int __attribute__ ((visibility ("hidden"))) MlcOpenChannel(struct _mud_channel *pc, int fd); 144 int __attribute__ ((visibility ("hidden"))) MlcCloseChannel(struct _mud_channel *pc, int fd); 145 int __attribute__ ((visibility ("hidden"))) MlcCredit(struct _mud_channel *pc, int fd, unsigned short credit); 146 int __attribute__ ((visibility ("hidden"))) MlcCreditRequest(struct _mud_channel *pc, int fd, unsigned short credit); 147 int __attribute__ ((visibility ("hidden"))) MlcReverseCmd(struct _mud_channel *pc, int fd); 148 149 #endif // _MLC_H 150 151