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 | */ |
---|
18 | |
---|
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 | */ |
---|
26 | |
---|
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); |
---|
34 | |
---|
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> |
---|
41 | |
---|
42 | #ifndef htonl |
---|
43 | #define htonl(x) __constant_htonl(x) |
---|
44 | #endif |
---|
45 | |
---|
46 | #ifndef ntohl |
---|
47 | #define ntohl(x) __constant_ntohl(x) |
---|
48 | #endif |
---|
49 | |
---|
50 | #ifndef htons |
---|
51 | #define htons(x) __constant_htons(x) |
---|
52 | #endif |
---|
53 | |
---|
54 | #ifndef ntohs |
---|
55 | #define ntohs(x) __constant_ntohs(x) |
---|
56 | #endif |
---|
57 | |
---|
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); |
---|
61 | |
---|
62 | #else |
---|
63 | |
---|
64 | #include <limits.h> |
---|
65 | #include <sys/socket.h> |
---|
66 | #include <netinet/in.h> |
---|
67 | #include <netdb.h> |
---|
68 | #include <arpa/inet.h> |
---|
69 | |
---|
70 | #endif |
---|
71 | |
---|
72 | extern char *mac_ntoa(const unsigned char *macaddr); |
---|
73 | extern int mac_aton(const char *addr, unsigned char *macaddr); |
---|
74 | |
---|
75 | #endif /* !_XUTIL_SYS_NET_H_ */ |
---|
76 | |
---|
77 | |
---|
78 | |
---|