1e3cf00d0SUpinder Malhi /* 2e3cf00d0SUpinder Malhi * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. 3e3cf00d0SUpinder Malhi * 4e3cf00d0SUpinder Malhi * This program is free software; you may redistribute it and/or modify 5e3cf00d0SUpinder Malhi * it under the terms of the GNU General Public License as published by 6e3cf00d0SUpinder Malhi * the Free Software Foundation; version 2 of the License. 7e3cf00d0SUpinder Malhi * 8e3cf00d0SUpinder Malhi * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 9e3cf00d0SUpinder Malhi * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 10e3cf00d0SUpinder Malhi * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 11e3cf00d0SUpinder Malhi * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 12e3cf00d0SUpinder Malhi * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 13e3cf00d0SUpinder Malhi * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14e3cf00d0SUpinder Malhi * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 15e3cf00d0SUpinder Malhi * SOFTWARE. 16e3cf00d0SUpinder Malhi * 17e3cf00d0SUpinder Malhi */ 18e3cf00d0SUpinder Malhi 19e3cf00d0SUpinder Malhi #ifndef USNIC_TRANSPORT_H_ 20e3cf00d0SUpinder Malhi #define USNIC_TRANSPORT_H_ 21e3cf00d0SUpinder Malhi 22e3cf00d0SUpinder Malhi #include "usnic_abi.h" 23e3cf00d0SUpinder Malhi 2462141054SUpinder Malhi const char *usnic_transport_to_str(enum usnic_transport_type trans_type); 2562141054SUpinder Malhi /* 2662141054SUpinder Malhi * Returns number of bytes written, excluding null terminator. If 2762141054SUpinder Malhi * nothing was written, the function returns 0. 2862141054SUpinder Malhi */ 2962141054SUpinder Malhi int usnic_transport_sock_to_str(char *buf, int buf_sz, 3062141054SUpinder Malhi struct socket *sock); 31e3cf00d0SUpinder Malhi u16 usnic_transport_rsrv_port(enum usnic_transport_type type, u16 port_num); 32e3cf00d0SUpinder Malhi void usnic_transport_unrsrv_port(enum usnic_transport_type type, u16 port_num); 3362141054SUpinder Malhi /* 3462141054SUpinder Malhi * Do a fget on the socket refered to by sock_fd and returns the socket. 3562141054SUpinder Malhi * Socket will not be destroyed before usnic_transport_put_socket has 3662141054SUpinder Malhi * been called. 3762141054SUpinder Malhi */ 3862141054SUpinder Malhi struct socket *usnic_transport_get_socket(int sock_fd); 3962141054SUpinder Malhi void usnic_transport_put_socket(struct socket *sock); 4062141054SUpinder Malhi /* 4162141054SUpinder Malhi * Call usnic_transport_get_socket before calling *_sock_get_addr 4262141054SUpinder Malhi */ 4362141054SUpinder Malhi int usnic_transport_sock_get_addr(struct socket *sock, int *proto, 4462141054SUpinder Malhi uint32_t *addr, uint16_t *port); 45e3cf00d0SUpinder Malhi int usnic_transport_init(void); 46e3cf00d0SUpinder Malhi void usnic_transport_fini(void); 47e3cf00d0SUpinder Malhi #endif /* !USNIC_TRANSPORT_H */ 48