1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2005 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
22 #ifndef __LIBCFS_USER_TCPIP_H__
23 #define __LIBCFS_USER_TCPIP_H__
25 #ifndef __LIBCFS_LIBCFS_H__
26 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
34 * Functions to get network interfaces info
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);
43 * Network function used by user-land lnet acceptor
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);
52 * Network functions of common use
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);
67 * Macros for easy printing IP-adresses
70 #define NIPQUAD(addr) \
71 ((unsigned char *)&addr)[0], \
72 ((unsigned char *)&addr)[1], \
73 ((unsigned char *)&addr)[2], \
74 ((unsigned char *)&addr)[3]
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
85 #error "Undefined byteorder??"
86 #endif /* __LITTLE_ENDIAN */
88 #endif /* !__KERNEL__ */