ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/sockinfo.h
(Generate patch)

Comparing gvpe/src/sockinfo.h (file contents):
Revision 1.3 by pcg, Wed Apr 2 05:15:00 2003 UTC vs.
Revision 1.8 by pcg, Thu Oct 16 02:41:21 2003 UTC

1/* 1/*
2 sockinfo.h -- socket address management 2 sockinfo.h -- socket address management
3
4 Copyright (C) 2003 Marc Lehmann <pcg@goof.com> 3 Copyright (C) 2003 Marc Lehmann <pcg@goof.com>
5 4
6 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
19*/ 18*/
20 19
21#ifndef VPE_SOCKINFO_H__ 20#ifndef VPE_SOCKINFO_H__
22#define VPE_SOCKINFO_H__ 21#define VPE_SOCKINFO_H__
23 22
24#include <sys/socket.h> 23#include "netcompat.h"
25#include <netinet/in.h>
26 24
27#include "conf.h" 25#include "conf.h"
28 26
29// encapsulate one or more network addresses. this structure 27// encapsulate one or more network addresses. this structure
30// gets transferred over the wire, so be careful with endianness etc. 28// gets transferred over the wire, so be careful with endianness etc.
33 u32 host; 31 u32 host;
34 u16 port; 32 u16 port;
35 u8 prot; 33 u8 prot;
36 u8 pad1; 34 u8 pad1;
37 35
38 void set (const sockaddr_in *sa, u8 prot_ = PROT_UDPv4); 36 void set (const sockaddr_in *sa, u8 prot_);
39 void set (const conf_node *conf, u8 prot_ = PROT_UDPv4); 37 void set (const conf_node *conf, u8 prot_);
38 void set (const char *hostname, u16 port_, u8 prot_);
39
40 // return the supported protocols
41 u8 supported_protocols (conf_node *conf = 0);
42 bool upgrade_protocol (u8 prot_, conf_node *conf = 0);
40 43
41 operator const char *() const; 44 operator const char *() const;
42 45
43 const sockaddr *sav4 () const; 46 const sockaddr *sav4 () const;
44 const socklen_t salenv4 () const 47 const socklen_t salenv4 () const
45 { return sizeof (sockaddr_in); } 48 { return sizeof (sockaddr_in); }
46 49
47 const char *ntoa () const; 50 const char *ntoa () const;
48 51
52 bool valid () const
53 { return prot != 0 && host != 0; }
54
49 sockinfo() { prot = 0; } 55 sockinfo() { prot = 0; }
50 56
51 sockinfo(const sockaddr_in &sa, u8 prot_ = PROT_UDPv4) 57 sockinfo(const sockaddr_in &sa, u8 prot)
52 { set (&sa, prot_); } 58 { set (&sa, prot); }
53 59
54 sockinfo(const conf_node *conf, u8 prot_ = PROT_UDPv4) 60 sockinfo(const conf_node *conf, u8 prot)
55 { set (conf, prot_); } 61 { set (conf, prot); }
56 }; 62 };
57 63
58inline bool
59operator == (const sockinfo &a, const sockinfo &b) 64bool operator == (const sockinfo &a, const sockinfo &b);
60{ 65bool operator < (const sockinfo &a, const sockinfo &b);
61 return a.host == b.host && a.port == b.port && a.prot == b.prot;
62}
63 66
64#endif 67#endif
65 68

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines