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.2 by pcg, Wed Apr 2 03:25:17 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); 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 {
46 return sizeof (sockaddr_in); 48 { return sizeof (sockaddr_in); }
47 }
48 49
49 const char *ntoa () const; 50 const char *ntoa () const;
50 51
51 sockinfo() 52 bool valid () const
52 { 53 { return prot != 0 && host != 0; }
53 prot = 0;
54 }
55 54
55 sockinfo() { prot = 0; }
56
56 sockinfo(const sockaddr_in &sa, u8 prot_ = PROT_UDPv4) 57 sockinfo(const sockaddr_in &sa, u8 prot)
57 {
58 set (&sa, prot_); 58 { set (&sa, prot); }
59 } 59
60 sockinfo(const conf_node *conf, u8 prot)
61 { set (conf, prot); }
60 }; 62 };
61 63
62inline bool
63operator == (const sockinfo &a, const sockinfo &b) 64bool operator == (const sockinfo &a, const sockinfo &b);
64{ 65bool operator < (const sockinfo &a, const sockinfo &b);
65 return a.host == b.host && a.port == b.port && a.prot == b.prot;
66}
67 66
68#endif 67#endif
69 68

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines