/[LeafOK_CVS]/pvpgn-1.7.4/src/common/addr.h
ViewVC logotype

Contents of /pvpgn-1.7.4/src/common/addr.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Tue Jun 6 03:41:38 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-chdr
no message

1 /*
2 * Copyright (C) 1999,2000,2001 Ross Combs (rocombs@cs.nmsu.edu)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program 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 General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #ifndef INCLUDED_ADDR_TYPES
19 #define INCLUDED_ADDR_TYPES
20
21 #ifdef JUST_NEED_TYPES
22 # include "common/list.h"
23 #else
24 # define JUST_NEED_TYPES
25 # include "common/list.h"
26 # undef JUST_NEED_TYPES
27 #endif
28
29 typedef union
30 {
31 unsigned long n;
32 int i;
33 void * p;
34 } t_addr_data;
35
36 typedef struct addr_struct
37 #ifdef ADDR_INTERNAL_ACCESS
38 {
39 char const * str; /* hostname or ip */
40 unsigned int ip;
41 unsigned int port;
42 t_addr_data data; /* data argument */
43 }
44 #endif
45 t_addr;
46
47 typedef struct netaddr_struct
48 #ifdef ADDR_INTERNAL_ACCESS
49 {
50 unsigned int ip;
51 unsigned int mask;
52 }
53 #endif
54 t_netaddr;
55
56 typedef t_list t_addrlist;
57
58 #endif
59
60
61 /*****/
62 #ifndef JUST_NEED_TYPES
63 #ifndef INCLUDED_ADDR_PROTOS
64 #define INCLUDED_ADDR_PROTOS
65
66 /* ipaddr and port are in host byte order */
67 extern char const * addr_num_to_addr_str(unsigned int ipaddr, unsigned short port);
68 /* ipaddr is in host byte order */
69 extern char const * addr_num_to_ip_str(unsigned int ipaddr);
70
71 extern char const * host_lookup(char const * hoststr, unsigned int * ipaddr);
72
73 /* ipaddr and port are in host byte order */
74 extern t_addr * addr_create_num(unsigned int ipaddr, unsigned short port) ;
75
76 /* defipaddr and defport are in host byte order */
77 extern t_addr * addr_create_str(char const * str, unsigned int defipaddr, unsigned short defport) ;
78
79 extern int addr_destroy(t_addr const * addr);
80 extern char * addr_get_host_str(t_addr const * addr, char * str, unsigned int len);
81 extern char * addr_get_addr_str(t_addr const * addr, char * str, unsigned int len);
82 /* returned in host byte order */
83 extern unsigned int addr_get_ip(t_addr const * addr);
84 /* returned in host byte order */
85 extern unsigned short addr_get_port(t_addr const * addr);
86 extern int addr_set_data(t_addr * addr, t_addr_data data);
87 extern t_addr_data addr_get_data(t_addr const * addr);
88 extern t_netaddr * netaddr_create_str(char const * str) ;
89 extern int netaddr_destroy(t_netaddr const * netaddr);
90 extern char * netaddr_get_addr_str(t_netaddr const * netaddr, char * str, unsigned int len);
91 extern int netaddr_contains_addr_num(t_netaddr const * netaddr, unsigned int ipaddr);
92
93 /* defipaddr and defport are in host byte order */
94 extern int addrlist_append(t_addrlist * addrlist, char const * str, unsigned int defipaddr, unsigned short defport);
95 extern t_addrlist * addrlist_create(char const * str, unsigned int defipaddr, unsigned short defport) ;
96 extern int addrlist_destroy(t_addrlist * addrlist);
97 extern int addrlist_get_length(t_addrlist const * addrlist);
98
99 #endif
100 #endif

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1