annotate trunk/external/oscpack/ip/IpEndpointName.h @ 706:f8e90b5d85fd tip

Delete CARFAC code from this repository. It has been moved to https://github.com/google/carfac Please email me with your github username to get access. I've also created a new mailing list to discuss CARFAC development: https://groups.google.com/forum/#!forum/carfac-dev
author ronw@google.com
date Thu, 18 Jul 2013 20:56:51 +0000
parents 4b37b53105a3
children
rev   line source
tomwalters@570 1 /*
tomwalters@570 2 oscpack -- Open Sound Control packet manipulation library
tomwalters@570 3 http://www.audiomulch.com/~rossb/oscpack
tomwalters@570 4
tomwalters@570 5 Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
tomwalters@570 6
tomwalters@570 7 Permission is hereby granted, free of charge, to any person obtaining
tomwalters@570 8 a copy of this software and associated documentation files
tomwalters@570 9 (the "Software"), to deal in the Software without restriction,
tomwalters@570 10 including without limitation the rights to use, copy, modify, merge,
tomwalters@570 11 publish, distribute, sublicense, and/or sell copies of the Software,
tomwalters@570 12 and to permit persons to whom the Software is furnished to do so,
tomwalters@570 13 subject to the following conditions:
tomwalters@570 14
tomwalters@570 15 The above copyright notice and this permission notice shall be
tomwalters@570 16 included in all copies or substantial portions of the Software.
tomwalters@570 17
tomwalters@570 18 Any person wishing to distribute modifications to the Software is
tomwalters@570 19 requested to send the modifications to the original developer so that
tomwalters@570 20 they can be incorporated into the canonical version.
tomwalters@570 21
tomwalters@570 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
tomwalters@570 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
tomwalters@570 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
tomwalters@570 25 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
tomwalters@570 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
tomwalters@570 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
tomwalters@570 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tomwalters@570 29 */
tomwalters@570 30 #ifndef INCLUDED_IPENDPOINTNAME_H
tomwalters@570 31 #define INCLUDED_IPENDPOINTNAME_H
tomwalters@570 32
tomwalters@570 33
tomwalters@570 34 class IpEndpointName{
tomwalters@570 35 static unsigned long GetHostByName( const char *s );
tomwalters@570 36 public:
tomwalters@570 37 static const unsigned long ANY_ADDRESS = 0xFFFFFFFF;
tomwalters@570 38 static const int ANY_PORT = -1;
tomwalters@570 39
tomwalters@570 40 IpEndpointName()
tomwalters@570 41 : address( ANY_ADDRESS ), port( ANY_PORT ) {}
tomwalters@570 42 IpEndpointName( int port_ )
tomwalters@570 43 : address( ANY_ADDRESS ), port( port_ ) {}
tomwalters@570 44 IpEndpointName( unsigned long ipAddress_, int port_ )
tomwalters@570 45 : address( ipAddress_ ), port( port_ ) {}
tomwalters@570 46 IpEndpointName( const char *addressName, int port_=ANY_PORT )
tomwalters@570 47 : address( GetHostByName( addressName ) )
tomwalters@570 48 , port( port_ ) {}
tomwalters@570 49 IpEndpointName( int addressA, int addressB, int addressC, int addressD, int port_=ANY_PORT )
tomwalters@570 50 : address( ( (addressA << 24) | (addressB << 16) | (addressC << 8) | addressD ) )
tomwalters@570 51 , port( port_ ) {}
tomwalters@570 52
tomwalters@570 53 // address and port are maintained in host byte order here
tomwalters@570 54 unsigned long address;
tomwalters@570 55 int port;
tomwalters@570 56
tomwalters@570 57 enum { ADDRESS_STRING_LENGTH=17 };
tomwalters@570 58 void AddressAsString( char *s ) const;
tomwalters@570 59
tomwalters@570 60 enum { ADDRESS_AND_PORT_STRING_LENGTH=23};
tomwalters@570 61 void AddressAndPortAsString( char *s ) const;
tomwalters@570 62 };
tomwalters@570 63
tomwalters@570 64 inline bool operator==( const IpEndpointName& lhs, const IpEndpointName& rhs )
tomwalters@570 65 {
tomwalters@570 66 return (lhs.address == rhs.address && lhs.port == rhs.port );
tomwalters@570 67 }
tomwalters@570 68
tomwalters@570 69 inline bool operator!=( const IpEndpointName& lhs, const IpEndpointName& rhs )
tomwalters@570 70 {
tomwalters@570 71 return !(lhs == rhs);
tomwalters@570 72 }
tomwalters@570 73
tomwalters@570 74 #endif /* INCLUDED_IPENDPOINTNAME_H */