~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/usb/usbip/src/usbip_network.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Copyright (C) 2005-2007 Takahiro Hirofuchi
  4  */
  5 
  6 #ifndef __USBIP_NETWORK_H
  7 #define __USBIP_NETWORK_H
  8 
  9 #ifdef HAVE_CONFIG_H
 10 #include "../config.h"
 11 #endif
 12 
 13 #include <sys/types.h>
 14 
 15 #include <stdint.h>
 16 
 17 extern int usbip_port;
 18 extern char *usbip_port_string;
 19 void usbip_setup_port_number(char *arg);
 20 
 21 /* ---------------------------------------------------------------------- */
 22 /* Common header for all the kinds of PDUs. */
 23 struct op_common {
 24         uint16_t version;
 25 
 26 #define OP_REQUEST      (0x80 << 8)
 27 #define OP_REPLY        (0x00 << 8)
 28         uint16_t code;
 29 
 30         /* status codes defined in usbip_common.h */
 31         uint32_t status; /* op_code status (for reply) */
 32 
 33 } __attribute__((packed));
 34 
 35 /* ---------------------------------------------------------------------- */
 36 /* Dummy Code */
 37 #define OP_UNSPEC       0x00
 38 #define OP_REQ_UNSPEC   OP_UNSPEC
 39 #define OP_REP_UNSPEC   OP_UNSPEC
 40 
 41 /* ---------------------------------------------------------------------- */
 42 /* Retrieve USB device information. (still not used) */
 43 #define OP_DEVINFO      0x02
 44 #define OP_REQ_DEVINFO  (OP_REQUEST | OP_DEVINFO)
 45 #define OP_REP_DEVINFO  (OP_REPLY   | OP_DEVINFO)
 46 
 47 struct op_devinfo_request {
 48         char busid[SYSFS_BUS_ID_SIZE];
 49 } __attribute__((packed));
 50 
 51 struct op_devinfo_reply {
 52         struct usbip_usb_device udev;
 53         struct usbip_usb_interface uinf[];
 54 } __attribute__((packed));
 55 
 56 /* ---------------------------------------------------------------------- */
 57 /* Import a remote USB device. */
 58 #define OP_IMPORT       0x03
 59 #define OP_REQ_IMPORT   (OP_REQUEST | OP_IMPORT)
 60 #define OP_REP_IMPORT   (OP_REPLY   | OP_IMPORT)
 61 
 62 struct op_import_request {
 63         char busid[SYSFS_BUS_ID_SIZE];
 64 } __attribute__((packed));
 65 
 66 struct op_import_reply {
 67         struct usbip_usb_device udev;
 68 //      struct usbip_usb_interface uinf[];
 69 } __attribute__((packed));
 70 
 71 #define PACK_OP_IMPORT_REQUEST(pack, request)  do {\
 72 } while (0)
 73 
 74 #define PACK_OP_IMPORT_REPLY(pack, reply)  do {\
 75         usbip_net_pack_usb_device(pack, &(reply)->udev);\
 76 } while (0)
 77 
 78 /* ---------------------------------------------------------------------- */
 79 /* Export a USB device to a remote host. */
 80 #define OP_EXPORT       0x06
 81 #define OP_REQ_EXPORT   (OP_REQUEST | OP_EXPORT)
 82 #define OP_REP_EXPORT   (OP_REPLY   | OP_EXPORT)
 83 
 84 struct op_export_request {
 85         struct usbip_usb_device udev;
 86 } __attribute__((packed));
 87 
 88 struct op_export_reply {
 89         int returncode;
 90 } __attribute__((packed));
 91 
 92 
 93 #define PACK_OP_EXPORT_REQUEST(pack, request)  do {\
 94         usbip_net_pack_usb_device(pack, &(request)->udev);\
 95 } while (0)
 96 
 97 #define PACK_OP_EXPORT_REPLY(pack, reply)  do {\
 98 } while (0)
 99 
100 /* ---------------------------------------------------------------------- */
101 /* un-Export a USB device from a remote host. */
102 #define OP_UNEXPORT     0x07
103 #define OP_REQ_UNEXPORT (OP_REQUEST | OP_UNEXPORT)
104 #define OP_REP_UNEXPORT (OP_REPLY   | OP_UNEXPORT)
105 
106 struct op_unexport_request {
107         struct usbip_usb_device udev;
108 } __attribute__((packed));
109 
110 struct op_unexport_reply {
111         int returncode;
112 } __attribute__((packed));
113 
114 #define PACK_OP_UNEXPORT_REQUEST(pack, request)  do {\
115         usbip_net_pack_usb_device(pack, &(request)->udev);\
116 } while (0)
117 
118 #define PACK_OP_UNEXPORT_REPLY(pack, reply)  do {\
119 } while (0)
120 
121 /* ---------------------------------------------------------------------- */
122 /* Negotiate IPSec encryption key. (still not used) */
123 #define OP_CRYPKEY      0x04
124 #define OP_REQ_CRYPKEY  (OP_REQUEST | OP_CRYPKEY)
125 #define OP_REP_CRYPKEY  (OP_REPLY   | OP_CRYPKEY)
126 
127 struct op_crypkey_request {
128         /* 128bit key */
129         uint32_t key[4];
130 } __attribute__((packed));
131 
132 struct op_crypkey_reply {
133         uint32_t __reserved;
134 } __attribute__((packed));
135 
136 
137 /* ---------------------------------------------------------------------- */
138 /* Retrieve the list of exported USB devices. */
139 #define OP_DEVLIST      0x05
140 #define OP_REQ_DEVLIST  (OP_REQUEST | OP_DEVLIST)
141 #define OP_REP_DEVLIST  (OP_REPLY   | OP_DEVLIST)
142 
143 struct op_devlist_request {
144 } __attribute__((packed));
145 
146 struct op_devlist_reply {
147         uint32_t ndev;
148         /* followed by reply_extra[] */
149 } __attribute__((packed));
150 
151 struct op_devlist_reply_extra {
152         struct usbip_usb_device    udev;
153         struct usbip_usb_interface uinf[];
154 } __attribute__((packed));
155 
156 #define PACK_OP_DEVLIST_REQUEST(pack, request)  do {\
157 } while (0)
158 
159 #define PACK_OP_DEVLIST_REPLY(pack, reply)  do {\
160         (reply)->ndev = usbip_net_pack_uint32_t(pack, (reply)->ndev);\
161 } while (0)
162 
163 uint32_t usbip_net_pack_uint32_t(int pack, uint32_t num);
164 uint16_t usbip_net_pack_uint16_t(int pack, uint16_t num);
165 void usbip_net_pack_usb_device(int pack, struct usbip_usb_device *udev);
166 void usbip_net_pack_usb_interface(int pack, struct usbip_usb_interface *uinf);
167 
168 ssize_t usbip_net_recv(int sockfd, void *buff, size_t bufflen);
169 ssize_t usbip_net_send(int sockfd, void *buff, size_t bufflen);
170 int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status);
171 int usbip_net_recv_op_common(int sockfd, uint16_t *code, int *status);
172 int usbip_net_set_reuseaddr(int sockfd);
173 int usbip_net_set_nodelay(int sockfd);
174 int usbip_net_set_keepalive(int sockfd);
175 int usbip_net_set_v6only(int sockfd);
176 int usbip_net_tcp_connect(char *hostname, char *port);
177 
178 #endif /* __USBIP_NETWORK_H */
179 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php