rob@76: /* rob@76: oscpack -- Open Sound Control (OSC) packet manipulation library rob@76: http://www.rossbencina.com/code/oscpack rob@76: rob@76: Copyright (c) 2004-2013 Ross Bencina rob@76: rob@76: Permission is hereby granted, free of charge, to any person obtaining rob@76: a copy of this software and associated documentation files rob@76: (the "Software"), to deal in the Software without restriction, rob@76: including without limitation the rights to use, copy, modify, merge, rob@76: publish, distribute, sublicense, and/or sell copies of the Software, rob@76: and to permit persons to whom the Software is furnished to do so, rob@76: subject to the following conditions: rob@76: rob@76: The above copyright notice and this permission notice shall be rob@76: included in all copies or substantial portions of the Software. rob@76: rob@76: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, rob@76: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF rob@76: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. rob@76: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR rob@76: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF rob@76: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION rob@76: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rob@76: */ rob@76: rob@76: /* rob@76: The text above constitutes the entire oscpack license; however, rob@76: the oscpack developer(s) also make the following non-binding requests: rob@76: rob@76: Any person wishing to distribute modifications to the Software is rob@76: requested to send the modifications to the original developer so that rob@76: they can be incorporated into the canonical version. It is also rob@76: requested that these non-binding requests be included whenever the rob@76: above license is reproduced. rob@76: */ rob@76: #ifndef INCLUDED_OSCPACK_IPENDPOINTNAME_H rob@76: #define INCLUDED_OSCPACK_IPENDPOINTNAME_H rob@76: rob@76: rob@76: class IpEndpointName{ rob@76: static unsigned long GetHostByName( const char *s ); rob@76: public: rob@76: static const unsigned long ANY_ADDRESS = 0xFFFFFFFF; rob@76: static const int ANY_PORT = -1; rob@76: rob@76: IpEndpointName() rob@76: : address( ANY_ADDRESS ), port( ANY_PORT ) {} rob@76: IpEndpointName( int port_ ) rob@76: : address( ANY_ADDRESS ), port( port_ ) {} rob@76: IpEndpointName( unsigned long ipAddress_, int port_ ) rob@76: : address( ipAddress_ ), port( port_ ) {} rob@76: IpEndpointName( const char *addressName, int port_=ANY_PORT ) rob@76: : address( GetHostByName( addressName ) ) rob@76: , port( port_ ) {} rob@76: IpEndpointName( int addressA, int addressB, int addressC, int addressD, int port_=ANY_PORT ) rob@76: : address( ( (addressA << 24) | (addressB << 16) | (addressC << 8) | addressD ) ) rob@76: , port( port_ ) {} rob@76: rob@76: // address and port are maintained in host byte order here rob@76: unsigned long address; rob@76: int port; rob@76: rob@76: bool IsMulticastAddress() const { return ((address >> 24) & 0xFF) >= 224 && ((address >> 24) & 0xFF) <= 239; } rob@76: rob@76: enum { ADDRESS_STRING_LENGTH=17 }; rob@76: void AddressAsString( char *s ) const; rob@76: rob@76: enum { ADDRESS_AND_PORT_STRING_LENGTH=23}; rob@76: void AddressAndPortAsString( char *s ) const; rob@76: }; rob@76: rob@76: inline bool operator==( const IpEndpointName& lhs, const IpEndpointName& rhs ) rob@76: { rob@76: return (lhs.address == rhs.address && lhs.port == rhs.port ); rob@76: } rob@76: rob@76: inline bool operator!=( const IpEndpointName& lhs, const IpEndpointName& rhs ) rob@76: { rob@76: return !(lhs == rhs); rob@76: } rob@76: rob@76: #endif /* INCLUDED_OSCPACK_IPENDPOINTNAME_H */