Whamcloud - gitweb
342c03997155076867b88f1555fad47a72f65b4a
[fs/lustre-release.git] / lnet / include / libcfs / user-tcpip.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2005 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #ifndef __LIBCFS_USER_TCPIP_H__
23 #define __LIBCFS_USER_TCPIP_H__
24
25 #ifndef __LIBCFS_LIBCFS_H__
26 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
27 #endif
28
29 #ifndef __KERNEL__
30
31 #include <sys/uio.h>
32
33 /*
34  * Functions to get network interfaces info
35  */
36
37 int libcfs_sock_ioctl(int cmd, unsigned long arg);
38 int libcfs_ipif_query (char *name, int *up, __u32 *ip);
39 void libcfs_ipif_free_enumeration (char **names, int n);
40 int libcfs_ipif_enumerate (char ***namesp);
41
42 /*
43  * Network function used by user-land lnet acceptor
44  */
45
46 int libcfs_sock_listen (int *sockp, __u32 local_ip, int local_port, int backlog);
47 int libcfs_sock_accept (int *newsockp, int sock, __u32 *peer_ip, int *peer_port);
48 int libcfs_sock_read (int sock, void *buffer, int nob, int timeout);
49 void libcfs_sock_abort_accept(__u16 port);
50
51 /*
52  * Network functions of common use
53  */
54
55 int libcfs_getpeername(int sock_fd, __u32 *ipaddr_p, __u16 *port_p);
56 int libcfs_socketpair(int *fdp);
57 int libcfs_fcntl_nonblock(int fd);
58 int libcfs_sock_set_nagle(int fd, int nagle);
59 int libcfs_sock_set_bufsiz(int fd, int bufsiz);
60 int libcfs_sock_create(int *fdp);
61 int libcfs_sock_bind_to_port(int fd, __u16 port);
62 int libcfs_sock_connect(int fd, __u32 ip, __u16 port);
63 int libcfs_sock_writev(int fd, const struct iovec *vector, int count);
64 int libcfs_sock_readv(int fd, const struct iovec *vector, int count);
65
66 /*
67  * Macros for easy printing IP-adresses
68  */
69
70 #define NIPQUAD(addr) \
71         ((unsigned char *)&addr)[0], \
72         ((unsigned char *)&addr)[1], \
73         ((unsigned char *)&addr)[2], \
74         ((unsigned char *)&addr)[3]
75
76 #if defined(__LITTLE_ENDIAN) || defined(_LITTLE_ENDIAN)
77 #define HIPQUAD(addr)                \
78         ((unsigned char *)&addr)[3], \
79         ((unsigned char *)&addr)[2], \
80         ((unsigned char *)&addr)[1], \
81         ((unsigned char *)&addr)[0]
82 #elif defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN)
83 #define HIPQUAD NIPQUAD
84 #else
85 #error "Undefined byteorder??"
86 #endif /* __LITTLE_ENDIAN */
87
88 #endif /* !__KERNEL__ */
89
90 #endif