brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · 9a7a2d9 Raw
67 lines · c
1/*2 * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.3 *4 * This software is available to you under a choice of one of two5 * licenses.  You may choose to be licensed under the terms of the GNU6 * General Public License (GPL) Version 2, available from the file7 * COPYING in the main directory of this source tree, or the8 * BSD license below:9 *10 *     Redistribution and use in source and binary forms, with or11 *     without modification, are permitted provided that the following12 *     conditions are met:13 *14 *      - Redistributions of source code must retain the above15 *        copyright notice, this list of conditions and the following16 *        disclaimer.17 *18 *      - Redistributions in binary form must reproduce the above19 *        copyright notice, this list of conditions and the following20 *        disclaimer in the documentation and/or other materials21 *        provided with the distribution.22 *23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE30 * SOFTWARE.31 *32 */33 34#ifndef USNIC_TRANSPORT_H_35#define USNIC_TRANSPORT_H_36 37#include "usnic_abi.h"38 39const char *usnic_transport_to_str(enum usnic_transport_type trans_type);40/*41 * Returns number of bytes written, excluding null terminator. If42 * nothing was written, the function returns 0.43 */44int usnic_transport_sock_to_str(char *buf, int buf_sz,45					struct socket *sock);46/*47 * Reserve a port. If "port_num" is set, then the function will try48 * to reserve that particular port.49 */50u16 usnic_transport_rsrv_port(enum usnic_transport_type type, u16 port_num);51void usnic_transport_unrsrv_port(enum usnic_transport_type type, u16 port_num);52/*53 * Do a fget on the socket refered to by sock_fd and returns the socket.54 * Socket will not be destroyed before usnic_transport_put_socket has55 * been called.56 */57struct socket *usnic_transport_get_socket(int sock_fd);58void usnic_transport_put_socket(struct socket *sock);59/*60 * Call usnic_transport_get_socket before calling *_sock_get_addr61 */62int usnic_transport_sock_get_addr(struct socket *sock, int *proto,63					uint32_t *addr, uint16_t *port);64int usnic_transport_init(void);65void usnic_transport_fini(void);66#endif /* !USNIC_TRANSPORT_H */67