1 /* 2 * QEMU SPDM socket support 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to deal 6 * in the Software without restriction, including without limitation the rights 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 * copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 * THE SOFTWARE. 21 */ 22 23 #ifndef SPDM_REQUESTER_H 24 #define SPDM_REQUESTER_H 25 26 /** 27 * spdm_socket_connect: connect to an external SPDM socket 28 * @port: port to connect to 29 * @errp: error object handle 30 * 31 * This will connect to an external SPDM socket server. On error 32 * it will return -1 and errp will be set. On success this function 33 * will return the socket number. 34 */ 35 int spdm_socket_connect(uint16_t port, Error **errp); 36 37 /** 38 * spdm_socket_rsp: send and receive a message to a SPDM server 39 * @socket: socket returned from spdm_socket_connect() 40 * @transport_type: SPDM_SOCKET_TRANSPORT_TYPE_* macro 41 * @req: request buffer 42 * @req_len: request buffer length 43 * @rsp: response buffer 44 * @rsp_len: response buffer length 45 * 46 * Send platform data to a SPDM server on socket and then receive 47 * a response. 48 */ 49 uint32_t spdm_socket_rsp(const int socket, uint32_t transport_type, 50 void *req, uint32_t req_len, 51 void *rsp, uint32_t rsp_len); 52 53 /** 54 * spdm_socket_close: send a shutdown command to the server 55 * @socket: socket returned from spdm_socket_connect() 56 * @transport_type: SPDM_SOCKET_TRANSPORT_TYPE_* macro 57 * 58 * This will issue a shutdown command to the server. 59 */ 60 void spdm_socket_close(const int socket, uint32_t transport_type); 61 62 #define SPDM_SOCKET_COMMAND_NORMAL 0x0001 63 #define SPDM_SOCKET_COMMAND_OOB_ENCAP_KEY_UPDATE 0x8001 64 #define SPDM_SOCKET_COMMAND_CONTINUE 0xFFFD 65 #define SPDM_SOCKET_COMMAND_SHUTDOWN 0xFFFE 66 #define SPDM_SOCKET_COMMAND_UNKOWN 0xFFFF 67 #define SPDM_SOCKET_COMMAND_TEST 0xDEAD 68 69 #define SPDM_SOCKET_TRANSPORT_TYPE_MCTP 0x01 70 #define SPDM_SOCKET_TRANSPORT_TYPE_PCI_DOE 0x02 71 72 #define SPDM_SOCKET_MAX_MESSAGE_BUFFER_SIZE 0x1200 73 74 #endif 75