Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vsnet_address.h
Go to the documentation of this file.
1 #ifndef VSNET_ADDRESS_H
2 #define VSNET_ADDRESS_H
3 
4 #include <config.h>
5 
6 /*
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 /*
23  * netUI - Network Interface - written by Stephane Vaxelaire <svax@free.fr>
24  */
25 
26 #include <iostream>
27 #include "networking/const.h"
28 #include "vsnet_headers.h"
29 
30 struct AddressIP : public sockaddr_in
31 {
33  {
34  memset( this, 0, sizeof (AddressIP) );
35  }
36  AddressIP( const AddressIP &orig )
37  {
38  memcpy( this, &orig, sizeof (AddressIP) );
39  }
40  AddressIP( const sockaddr_in &orig )
41  {
42  memcpy( this, &orig, sizeof (AddressIP) );
43  }
44 
45  AddressIP( const AddressIP &orig, unsigned short port );
46  AddressIP( const char *address, unsigned short port );
47 
48  AddressIP& operator=( const AddressIP &orig )
49  {
50  memcpy( this, &orig, sizeof (AddressIP) );
51  return *this;
52  }
53  AddressIP&operator=( const sockaddr_in &orig )
54  {
55  memcpy( this, &orig, sizeof (AddressIP) );
56  return *this;
57  }
59  void dump();
60 
64  const char * ipadr() const;
65  unsigned long inaddr() const;
66 
67  friend std::ostream&operator<<( std::ostream &ostr, const AddressIP &adr );
68 
69  friend bool operator==( const AddressIP &l, const AddressIP &r );
70  friend bool operator!=( const AddressIP &l, const AddressIP &r );
71  friend bool operator<( const AddressIP &l, const AddressIP &r );
72 };
73 
74 std::ostream&operator<<( std::ostream &ostr, const AddressIP &adr );
75 
76 bool operator==( const AddressIP &l, const AddressIP &r );
77 bool operator!=( const AddressIP &l, const AddressIP &r );
78 bool operator<( const AddressIP &l, const AddressIP &r );
79 #endif /* VSNET_ADDRESS_H */
80