--- gvpe/src/sockinfo.h 2003/03/28 04:05:10 1.1 +++ gvpe/src/sockinfo.h 2003/10/16 02:41:21 1.8 @@ -1,8 +1,6 @@ /* sockinfo.h -- socket address management - Copyright (C) 1998-2002 Ivo Timmermans - 2000-2002 Guus Sliepen - 2003 Marc Lehmannn + Copyright (C) 2003 Marc Lehmann 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 @@ -19,11 +17,10 @@ Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef SOCKINFO_H__ -#define SOCKINFO_H__ +#ifndef VPE_SOCKINFO_H__ +#define VPE_SOCKINFO_H__ -#include -#include +#include "netcompat.h" #include "conf.h" @@ -36,35 +33,36 @@ u8 prot; u8 pad1; - void set (const sockaddr_in *sa, u8 prot_ = PROT_UDPv4); - void set (const conf_node *conf); + void set (const sockaddr_in *sa, u8 prot_); + void set (const conf_node *conf, u8 prot_); + void set (const char *hostname, u16 port_, u8 prot_); + + // return the supported protocols + u8 supported_protocols (conf_node *conf = 0); + bool upgrade_protocol (u8 prot_, conf_node *conf = 0); operator const char *() const; const sockaddr *sav4 () const; const socklen_t salenv4 () const - { - return sizeof (sockaddr_in); - } + { return sizeof (sockaddr_in); } const char *ntoa () const; - sockinfo() - { - prot = 0; - } - - sockinfo(const sockaddr_in &sa, u8 prot_ = PROT_UDPv4) - { - set (&sa, prot_); - } + bool valid () const + { return prot != 0 && host != 0; } + + sockinfo() { prot = 0; } + + sockinfo(const sockaddr_in &sa, u8 prot) + { set (&sa, prot); } + + sockinfo(const conf_node *conf, u8 prot) + { set (conf, prot); } }; -inline bool -operator == (const sockinfo &a, const sockinfo &b) -{ - return a.host == b.host && a.port == b.port && a.prot == b.prot; -} +bool operator == (const sockinfo &a, const sockinfo &b); +bool operator < (const sockinfo &a, const sockinfo &b); #endif