ia64/xen-unstable

view tools/vnet/libxutil/sys_net.h @ 6766:219d96d545fc

merge?
author cl349@firebug.cl.cam.ac.uk
date Mon Sep 12 20:00:41 2005 +0000 (2005-09-12)
parents 9f22db685802
children
line source
1 /*
2 * Copyright (C) 2001 - 2004 Mike Wray <mike.wray@hp.com>
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
19 #ifndef _XUTIL_SYS_NET_H_
20 #define _XUTIL_SYS_NET_H_
21 /** @file
22 *
23 * Replacement for standard network includes.
24 * Works in user or kernel code.
25 */
27 extern int get_inet_addr(const char *s, unsigned long *address);
28 extern unsigned long bits_to_mask(int n);
29 extern int mask_to_bits(unsigned long mask);
30 extern int get_host_address(const char *name, unsigned long *address);
31 extern int get_service_port(const char *name, unsigned long *port);
32 extern char *get_port_service(unsigned long port);
33 extern int convert_service_to_port(const char *s, unsigned long *port);
35 #ifdef __KERNEL__
36 #include <linux/kernel.h>
37 #include <linux/types.h>
38 #include <linux/errno.h>
39 #include <linux/slab.h>
40 #include <asm/byteorder.h>
42 #ifndef htonl
43 #define htonl(x) __constant_htonl(x)
44 #endif
46 #ifndef ntohl
47 #define ntohl(x) __constant_ntohl(x)
48 #endif
50 #ifndef htons
51 #define htons(x) __constant_htons(x)
52 #endif
54 #ifndef ntohs
55 #define ntohs(x) __constant_ntohs(x)
56 #endif
58 #include <linux/in.h>
59 extern char *inet_ntoa(struct in_addr inaddr);
60 extern int inet_aton(const char *address, struct in_addr *inp);
62 #else
64 #include <limits.h>
65 #include <sys/socket.h>
66 #include <netinet/in.h>
67 #include <netdb.h>
68 #include <arpa/inet.h>
70 #endif
72 extern char *mac_ntoa(const unsigned char *macaddr);
73 extern int mac_aton(const char *addr, unsigned char *macaddr);
75 #endif /* !_XUTIL_SYS_NET_H_ */