X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Fuser-tcpip.h;h=9812fb976d2592dd60f6b50078d28ce4a2e08731;hp=342c03997155076867b88f1555fad47a72f65b4a;hb=d39408943a56f452d68b3c8b170ee4ce10e416fa;hpb=e1b3d71a27c166bebd26ab33f7299c41bd75dab5 diff --git a/libcfs/include/libcfs/user-tcpip.h b/libcfs/include/libcfs/user-tcpip.h index 342c039..9812fb9 100644 --- a/libcfs/include/libcfs/user-tcpip.h +++ b/libcfs/include/libcfs/user-tcpip.h @@ -1,22 +1,35 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright (C) 2005 Cluster File Systems, Inc. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * This file is part of Lustre, http://www.lustre.org. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * Lustre is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Lustre is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * GPL HEADER END + */ +/* + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. */ #ifndef __LIBCFS_USER_TCPIP_H__ @@ -29,6 +42,7 @@ #ifndef __KERNEL__ #include +#include /* * Functions to get network interfaces info @@ -43,25 +57,36 @@ int libcfs_ipif_enumerate (char ***namesp); * Network function used by user-land lnet acceptor */ -int libcfs_sock_listen (int *sockp, __u32 local_ip, int local_port, int backlog); -int libcfs_sock_accept (int *newsockp, int sock, __u32 *peer_ip, int *peer_port); -int libcfs_sock_read (int sock, void *buffer, int nob, int timeout); -void libcfs_sock_abort_accept(__u16 port); +typedef struct cfs_socket { + int s_fd; +} cfs_socket_t; + +#define LIBCFS_SOCK2FD(sock) ((sock)->s_fd) + +int libcfs_sock_listen(cfs_socket_t **sockp, __u32 ip, int port, int backlog); +int libcfs_sock_accept(cfs_socket_t **newsockp, cfs_socket_t *sock); +int libcfs_sock_read(cfs_socket_t *sock, void *buffer, int nob, int timeout); +int libcfs_sock_write(cfs_socket_t *sock, void *buffer, int nob, int timeout); +void libcfs_sock_abort_accept(cfs_socket_t *sock); +void libcfs_sock_release(cfs_socket_t *sock); +int libcfs_sock_getaddr(cfs_socket_t *sock, int remote, __u32 *ip, int *port); /* * Network functions of common use */ -int libcfs_getpeername(int sock_fd, __u32 *ipaddr_p, __u16 *port_p); -int libcfs_socketpair(int *fdp); -int libcfs_fcntl_nonblock(int fd); -int libcfs_sock_set_nagle(int fd, int nagle); -int libcfs_sock_set_bufsiz(int fd, int bufsiz); -int libcfs_sock_create(int *fdp); -int libcfs_sock_bind_to_port(int fd, __u16 port); -int libcfs_sock_connect(int fd, __u32 ip, __u16 port); -int libcfs_sock_writev(int fd, const struct iovec *vector, int count); -int libcfs_sock_readv(int fd, const struct iovec *vector, int count); +int libcfs_socketpair(cfs_socket_t **sockp); +int libcfs_fcntl_nonblock(cfs_socket_t *sock); +int libcfs_sock_set_nagle(cfs_socket_t *sock, int nagle); +int libcfs_sock_set_bufsiz(cfs_socket_t *sock, int bufsiz); +int libcfs_sock_connect(cfs_socket_t *sock, __u32 ip, __u16 port); +int libcfs_sock_writev(cfs_socket_t *sock, + const struct iovec *vector, int count); +int libcfs_sock_readv(cfs_socket_t *sock, + const struct iovec *vector, int count); +int libcfs_sock_create(cfs_socket_t **sockp, int *fatal, + __u32 local_ip, int local_port); + /* * Macros for easy printing IP-adresses @@ -73,13 +98,13 @@ int libcfs_sock_readv(int fd, const struct iovec *vector, int count); ((unsigned char *)&addr)[2], \ ((unsigned char *)&addr)[3] -#if defined(__LITTLE_ENDIAN) || defined(_LITTLE_ENDIAN) +#if __BYTE_ORDER == __LITTLE_ENDIAN #define HIPQUAD(addr) \ ((unsigned char *)&addr)[3], \ ((unsigned char *)&addr)[2], \ ((unsigned char *)&addr)[1], \ ((unsigned char *)&addr)[0] -#elif defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN) +#elif __BYTE_ORDER == __BIG_ENDIAN #define HIPQUAD NIPQUAD #else #error "Undefined byteorder??"