1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
* Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef INCLUDED_ADDR_TYPES
#define INCLUDED_ADDR_TYPES
#ifdef JUST_NEED_TYPES
#include "list.h"
#else
#define JUST_NEED_TYPES
#include "list.h"
#undef JUST_NEED_TYPES
#endif
typedef union
{
unsigned long n;
void * p;
} t_addr_data;
typedef struct addr_struct
#ifdef ADDR_INTERNAL_ACCESS
{
char const * str; /* hostname or ip */
unsigned int ip;
unsigned int port;
t_addr_data data; /* data argument */
}
#endif
t_addr;
typedef t_list t_addrlist;
#endif
#ifndef JUST_NEED_TYPES
#ifndef INCLUDED_ADDR_PROTOS
#define INCLUDED_ADDR_PROTOS
/* ipaddr and port are in host byte order */
extern t_addr * addr_create_num(unsigned int ipaddr, unsigned short port);
/* defipaddr and defport are in host byte order */
extern t_addr * addr_create_str(char const * str, unsigned int defipaddr, unsigned short defport);
extern int addr_destroy(t_addr const * addr);
extern int addr_get_host_str(t_addr const * addr, char * str, unsigned int len);
extern int addr_get_addr_str(t_addr const * addr, char * str, unsigned int len);
/* returned in host byte order */
extern unsigned int addr_get_ip(t_addr const * addr);
/* returned in host byte order */
extern unsigned short addr_get_port(t_addr const * addr);
extern int addr_set_data(t_addr * addr, t_addr_data data);
extern t_addr_data addr_get_data(t_addr const * addr);
/* defipaddr and defport are in host byte order */
extern t_addrlist * addrlist_create(char const * str, unsigned int defipaddr, unsigned short defport);
extern int addrlist_destroy(t_addrlist * * addrlist);
extern int addrlist_get_length(t_addrlist const * addrlist);
extern t_addr * addrlist_get_first(t_addrlist const * addrlist, t_list const * const * * save);
extern t_addr * addrlist_get_next(t_list const * const * * save);
#endif
#endif
|