williamr@2: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // IPv6/IPv4 socket library public header williamr@2: // williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file in_sock.h williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: #ifndef __IN_SOCK_H__ williamr@2: #define __IN_SOCK_H__ williamr@2: williamr@2: #ifndef __ES_SOCK_H__ williamr@2: #include williamr@2: #endif williamr@2: williamr@2: /** williamr@2: * @name TCP/IP Protocol and address family williamr@2: * williamr@2: * The TCP/IP stack supports two different address formats williamr@2: * in the TInetAddr: KAfInet for plain IPv4 addresses (for williamr@2: * backward compatibility), and KAfInet6 for both IPv6 and williamr@2: * IPv4 addresses. williamr@2: * williamr@2: * Only the KAfInet is used as a protocol family constant williamr@2: * for the TCP/IP protocol family, when sockets are opened williamr@2: * (RSocket::Open() and RHostResolver::Open() ). williamr@2: * williamr@2: * KAfInet6 is only address family, and can only appear williamr@2: * as a family constant in TSockAddr class. williamr@2: * williamr@2: * @since 7.0 williamr@2: */ williamr@2: //@{ williamr@2: /** Identifies the TCP/IP protocol family and v4 address family. williamr@2: * williamr@2: * @see TInetAddr williamr@2: */ williamr@2: const TUint KAfInet = 0x0800; williamr@2: /** Identifies the TCP/IP v6 address family. williamr@2: * williamr@2: * @see TInetAddr williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KAfInet6 = 0x0806; williamr@2: //@} williamr@2: williamr@2: /** williamr@2: * @name IP protocol IDs williamr@2: * @ingroup ip_packet_formats williamr@2: */ williamr@2: //@{ williamr@2: /** williamr@2: * Identifies the ICMP protocol. williamr@2: * williamr@2: * @capability NetworkServices Required for opening 'icmp' sockets. williamr@2: * @ref RSocket::Open() williamr@2: */ williamr@2: const TUint KProtocolInetIcmp = 1; williamr@2: williamr@2: /** williamr@2: * Identifies the TCP protocol. williamr@2: * williamr@2: * @capability NetworkServices Required for opening 'tcp' sockets. williamr@2: * @ref RSocket::Open() williamr@2: */ williamr@2: const TUint KProtocolInetTcp = 6; williamr@2: williamr@2: /** williamr@2: * Identifies the UDP protocol. williamr@2: * williamr@2: * @capability NetworkServices Required for opening 'udp' sockets. williamr@2: * @ref RSocket::Open() williamr@2: */ williamr@2: const TUint KProtocolInetUdp = 17; williamr@2: williamr@2: /** IPv6 inside IP (v4 or v6). @since 7.0 */ williamr@2: const TUint KProtocolInet6Ipip = 41; williamr@2: williamr@2: /** Identifies the ICMPv6 protocol. williamr@2: * williamr@2: * @since 7.0 williamr@2: * @capability NetworkServices Required for opening 'icmp6' sockets. williamr@2: * @ref RSocket::Open() williamr@2: */ williamr@2: const TUint KProtocolInet6Icmp = 58; williamr@2: //@} williamr@2: williamr@2: /** williamr@2: * @name Internal Protocol IDs williamr@2: * Internal protocol id's do not appear in real williamr@2: * packets. An internal id only identifies a protocol williamr@2: * instance. williamr@2: * @{ williamr@2: */ williamr@2: /** williamr@2: * Identifies the IP (v4) protocol module. williamr@2: * williamr@2: * @capability NetworkControl Required for opening 'ip' sockets. williamr@2: * @ref RSocket::Open() williamr@2: */ williamr@2: const TUint KProtocolInetIp = 0x100; williamr@2: williamr@2: /** williamr@2: * Identifies the IP (v6) protocol module. williamr@2: * williamr@2: * @since 7.0 williamr@2: * @capability NetworkControl Required for opening 'ip6' sockets. williamr@2: * @ref RSocket::Open() williamr@2: */ williamr@2: const TUint KProtocolInet6Ip = 0xF00; williamr@2: williamr@2: /** Unknown Protocol ID. @deprecated (never use in anything that binds to IP) */ williamr@2: const TUint KProtocolUnknown = 0xdead; williamr@2: williamr@2: //@} williamr@2: williamr@2: /** @name Socket option/ioctl levels */ williamr@2: //@{ williamr@2: /** ICMP socket option level (no options). */ williamr@2: const TUint KSolInetIcmp = 0x101; williamr@2: /** TCP socket options level. */ williamr@2: const TUint KSolInetTcp = 0x106; williamr@2: /** UDP socket options level. */ williamr@2: const TUint KSolInetUdp = 0x111; williamr@2: /** IP socket options level. */ williamr@2: const TUint KSolInetIp = 0x100; williamr@2: /** Interface control socket options level. */ williamr@2: const TUint KSolInetIfCtrl = 0x201; williamr@2: /** Route control socket options level. */ williamr@2: const TUint KSolInetRtCtrl = 0x202; williamr@2: /** DNS control socket options level. @removed */ williamr@2: const TUint KSolInetDnsCtrl = 0x204; williamr@2: /** Interface query socket options level. @since 7.0 */ williamr@2: const TUint KSolInetIfQuery = 0x206; williamr@2: //@} williamr@2: williamr@2: /** Maximum IPv4 address length (bits). */ williamr@2: const TInt KInetAddrMaxBits = 32; williamr@2: /** Maximum IPv6 address length (bits). */ williamr@2: const TInt KInet6AddrMaxBits = 128; williamr@2: williamr@2: /** @name Port constants */ williamr@2: //@{ williamr@2: /** Any port flag (0). */ williamr@2: const TUint KInetPortAny = 0x0000; williamr@2: /** No port flag (0). */ williamr@2: const TUint KInetPortNone = 0x0000; williamr@2: /** Minimum value of an automatically allocated port. */ williamr@2: const TUint KInetMinAutoPort = 32768; williamr@2: /** Maximum value of an automatically allocated port. */ williamr@2: const TUint KInetMaxAutoPort = 60999; williamr@2: //@} williamr@2: williamr@2: /** @name IPv4 address constants and definitions */ williamr@2: //@{ williamr@2: williamr@2: /** williamr@2: * Forms a 32-bit integer IPv4 address from the normal dotted-decimal representation. williamr@2: * williamr@2: * The four arguments are the four parts of the IPv4 address. williamr@2: * williamr@2: * Example: williamr@2: * @code williamr@2: * TInetAddr addr; williamr@2: * const TUint32 KInetAddr = INET_ADDR(194,129,2,54); williamr@2: * addr.SetAddress(KInetAddr); williamr@2: * @endcode williamr@2: */ williamr@2: #define INET_ADDR(a,b,c,d) (TUint32)((((TUint32)(a))<<24)|((b)<<16)|((c)<<8)|(d)) williamr@2: williamr@2: /** Any address flag (0.0.0.0). */ williamr@2: const TUint32 KInetAddrAny = INET_ADDR(0,0,0,0); williamr@2: /** No address flag (0.0.0.0). */ williamr@2: const TUint32 KInetAddrNone = INET_ADDR(0,0,0,0); williamr@2: /** All addresses mask (255.255.255.255). */ williamr@2: const TUint32 KInetAddrAll = INET_ADDR(255,255,255,255); williamr@2: /** Broadcast address (255.255.255.255). */ williamr@2: const TUint32 KInetAddrBroadcast = INET_ADDR(255,255,255,255); williamr@2: /** Loopback address (127.0.0.1). */ williamr@2: const TUint32 KInetAddrLoop = INET_ADDR(127,0,0,1); williamr@2: williamr@2: /** Group address range start. */ williamr@2: const TUint32 KInetAddrGroupUnspec = INET_ADDR(224,0,0,0); williamr@2: /** All hosts address (224.0.0.1). */ williamr@2: const TUint32 KInetAddrGroupAllHosts = INET_ADDR(224,0,0,1); williamr@2: /** Link-local net number. @since 7.0s */ williamr@2: const TUint32 KInetAddrLinkLocalNet = INET_ADDR(169,254,0,0); williamr@2: /** Link-local net mask. @since 7.0s */ williamr@2: const TUint32 KInetAddrLinkLocalNetMask = INET_ADDR(255,255,0,0); williamr@2: williamr@2: /** All addresses mask (0.0.0.0). */ williamr@2: const TUint32 KInetAddrMaskAll = INET_ADDR(0,0,0,0); williamr@2: /** All bits mask (255.255.255.255). */ williamr@2: const TUint32 KInetAddrMaskHost = INET_ADDR(255,255,255,255); williamr@2: williamr@2: /** Class A net mask (255.0.0.0). */ williamr@2: const TUint32 KInetAddrNetMaskA = INET_ADDR(255,0,0,0); williamr@2: /** Class A host mask (0.255.255.255). */ williamr@2: const TUint32 KInetAddrHostMaskA = ~KInetAddrNetMaskA; williamr@2: /** Number of bits to right-shift a Class A address to obtain the network number. */ williamr@2: const TInt KInetAddrShiftA = 24; williamr@2: /** Class B net mask (255.255.0.0). */ williamr@2: const TUint32 KInetAddrNetMaskB = INET_ADDR(255,255,0,0); williamr@2: /** Class B host mask (0.0.255.255). */ williamr@2: const TUint32 KInetAddrHostMaskB = ~KInetAddrNetMaskB; williamr@2: /** Number of bits to right-shift a Class B address to obtain the network number. */ williamr@2: const TInt KInetAddrShiftB = 16; williamr@2: /** Class C net mask (255.255.255.0). */ williamr@2: const TUint32 KInetAddrNetMaskC = INET_ADDR(255,255,255,0); williamr@2: /** Class C host mask (0.0.0.255). */ williamr@2: const TUint32 KInetAddrHostMaskC = ~KInetAddrNetMaskC; williamr@2: /** Number of bits to right-shift a Class C address to obtain the network number. */ williamr@2: const TInt KInetAddrShiftC = 8; williamr@2: williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdMaskA = 0x80000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdValA = 0x00000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdMaskB = 0xc0000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdValB = 0x80000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdMaskC = 0xe0000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdValC = 0xc0000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdMaskD = 0xf0000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdValD = 0xe0000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdMaskE = 0xf8000000; williamr@2: /** . */ williamr@2: const TUint32 KInetAddrIdValE = 0xf0000000; williamr@2: williamr@2: enum TInetAddrClass williamr@2: /** williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: { williamr@2: EInetClassUnknown = 0, williamr@2: EInetClassA, williamr@2: EInetClassB, williamr@2: EInetClassC, williamr@2: EInetClassD, williamr@2: EInetClassE, williamr@2: EInetMulticast = EInetClassD, williamr@2: EInetExperimental = EInetClassE williamr@2: }; williamr@2: //@} williamr@2: williamr@2: struct SInetAddr williamr@2: /** williamr@2: * IPv4 socket address. williamr@2: * williamr@2: * This exists for backward compatibility. SInet6Addr is williamr@2: * the preferred format for both IPv4 and IPv6 addresses williamr@2: * in TInetAddr. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: { williamr@2: /** Plain IPv4 address */ williamr@2: TUint32 iAddr; williamr@2: }; williamr@2: williamr@2: williamr@2: class TIp6Addr williamr@2: /** williamr@2: * The 128 bits of IPv6 or IPv4 address stored in network byte order. williamr@2: * williamr@2: * IPv4 addresses are stored in IPv4 mapped format. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: * @since 7.0 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBool IsUnicast() const; williamr@2: IMPORT_C TBool IsMulticast() const; williamr@2: IMPORT_C TBool IsLoopback() const; williamr@2: IMPORT_C TBool IsUnspecified() const; williamr@2: IMPORT_C TBool IsLinkLocal() const; williamr@2: IMPORT_C TBool IsSiteLocal() const; williamr@2: IMPORT_C TBool IsV4Compat() const; williamr@2: IMPORT_C TBool IsV4Mapped() const; williamr@2: IMPORT_C TBool IsEqual(const TIp6Addr &aAddr) const; williamr@2: IMPORT_C TInt Match(const TIp6Addr &aAddr) const; williamr@2: IMPORT_C TInt Scope() const; williamr@2: union williamr@2: { williamr@2: TUint8 iAddr8[16]; williamr@2: TUint16 iAddr16[8]; williamr@2: TUint32 iAddr32[4]; williamr@2: } u; williamr@2: }; williamr@2: williamr@2: struct SInet6Addr williamr@2: /** williamr@2: * IPv4 and IPv6 socket address. williamr@2: * williamr@2: * Defines the address information inside the TInetAddr. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: * williamr@2: * @sa SInetAddr williamr@2: * @since 7.0 williamr@2: */ williamr@2: { williamr@2: /** 16 bytes of IP6/IP4 address (128 bits) */ williamr@2: TIp6Addr iAddr; williamr@2: /** 4 bytes of Flow Id */ williamr@2: TUint32 iFlow; williamr@2: /** 4 bytes of Scope Id. */ williamr@2: TUint32 iScope; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * @name IPv6 address constants.. williamr@2: * @since 7.0 williamr@2: */ williamr@2: //@{ williamr@2: /** Node-local scope level (RFC-2373 2.7). */ williamr@2: const TInt KIp6AddrScopeNodeLocal = 0x01; williamr@2: /** Link-local scope level (RFC-2373 2.7). */ williamr@2: const TInt KIp6AddrScopeLinkLocal = 0x02; williamr@2: /** Site-local scope level (RFC-2373 2.7). */ williamr@2: const TInt KIp6AddrScopeSiteLocal = 0x05; williamr@2: /** Organisation-local scope level (RFC-2373 2.7). */ williamr@2: const TInt KIp6AddrScopeOrganization = 0x08; williamr@2: /** Global scope level (RFC-2373 2.7). */ williamr@2: const TInt KIp6AddrScopeGlobal = 0x0E; williamr@2: /** Network scope level (non-standard value, used internally) */ williamr@2: const TInt KIp6AddrScopeNetwork = 0x10; williamr@2: williamr@2: /** No address (all 0s). */ williamr@2: const TIp6Addr KInet6AddrNone = {{{0}}}; williamr@2: /** Loopback address (::1). */ williamr@2: const TIp6Addr KInet6AddrLoop = {{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}}; williamr@2: /** Link-local address (prefix fe80::). */ williamr@2: const TIp6Addr KInet6AddrLinkLocal = {{{0xfe, 0x80, }}}; williamr@2: //@} williamr@2: williamr@2: class TInetAddr : public TSockAddr williamr@2: /** williamr@2: * This class specialises the generic socket server address class williamr@2: * TSockAddr for the TCP/IP protocol family. It represents an IP williamr@2: * address and stores either an IPv4 or an IPv6 address in its buffer williamr@2: * after the generic data defined by TSockAddr. The protocol family williamr@2: * field provided by the TSockAddr base class can be set to KAfInet, williamr@2: * KAfInet6 or KAFUnspec. williamr@2: * williamr@2: * The address family defines the format of the stored address: williamr@2: * williamr@2: * @li #KAfInet williamr@2: * is for plain 32 bits IPv4 address presented as SInetAddr williamr@2: * structure. williamr@2: * @li #KAfInet6 williamr@2: * is for both IPv4 and IPv6 addresses (IPv4 addresses williamr@2: * are in IPv4 mapped format). The content is presented as williamr@2: * SInet6Addr structure, which includes the scope id williamr@2: * and flow label, in addition to the 128 address bits. williamr@2: * @li KAFUnspec williamr@2: * does not contain any addresses and works in most williamr@2: * contexts as unspecified address, This is better than williamr@2: * placing explicit IPv4 "0.0.0.0" or IPv6 "::", which williamr@2: * in certain situations may limit the connections to either williamr@2: * IPv4 or IPv6, but not both. williamr@2: * williamr@2: * The flow label and scope id fields exist only in KAfInet6 williamr@2: * format. However, the access functions TInetAddr::FlowLabel williamr@2: * and TInetAddr::Scope will also work for other address formats williamr@2: * by always returning 0. williamr@2: * williamr@2: * Any function which sets or changes the address bits, will williamr@2: * always reset the scope id and flow label to 0 (the williamr@2: * TInetAddr::Init is always called internally). These are williamr@2: * reasonable defaults, and normal application user does not williamr@2: * normally need to worry about flow label or scope id. williamr@2: * williamr@2: * When address is returned from the stack, it will often williamr@2: * be in KAfInet6 format, and may contain non-zero values williamr@2: * for flow label and scope id fields. When copying addresses, williamr@2: * the full TInetAddr (or at least SInet6Addr) should be williamr@2: * copied to preserve these fields. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: * @since 7.0 williamr@2: * The IPv4 only portion is backward compatible with williamr@2: * older versions. In 7.0s some functions have additional williamr@2: * features. williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TInetAddr(); williamr@2: IMPORT_C TInetAddr(const TSockAddr& aAddr); williamr@2: IMPORT_C TInetAddr(TUint aPort); williamr@2: IMPORT_C TInetAddr(const TIp6Addr &aAddr, TUint aPort); williamr@2: IMPORT_C TInetAddr(TUint32 aAddr, TUint aPort); williamr@2: IMPORT_C void SetAddress(TUint32 aAddr); williamr@2: IMPORT_C void SetAddress(const TIp6Addr &aAddr); williamr@2: IMPORT_C void SetV4CompatAddress(TUint32 aAddr); williamr@2: IMPORT_C void SetV4MappedAddress(TUint32 aAddr); williamr@2: IMPORT_C void SetFlowLabel(TInt aLabel); williamr@2: IMPORT_C TInt FlowLabel() const; williamr@2: IMPORT_C const TIp6Addr &Ip6Address() const; williamr@2: IMPORT_C void ConvertToV4Compat(); williamr@2: IMPORT_C void ConvertToV4Mapped(); williamr@2: IMPORT_C void ConvertToV4(); williamr@2: IMPORT_C TBool CmpAddr(const TInetAddr& aAddr) const; williamr@2: IMPORT_C TBool Match(const TInetAddr& aHost) const; williamr@2: IMPORT_C TBool Match(const TInetAddr& aNet, const TInetAddr& aMask) const; williamr@2: IMPORT_C TBool Match(const TInetAddr& aNet, TInt aPrefixLen) const; williamr@2: IMPORT_C void PrefixMask(TInt aPrefixLen); williamr@2: IMPORT_C void Prefix(const TInetAddr& aAddr, TInt aPrefixLen); williamr@2: IMPORT_C void Output(TDes &aBuf) const; williamr@2: IMPORT_C TInt Input(const TDesC &aBuf); williamr@2: inline static TInetAddr& Cast(const TSockAddr& aAddr); williamr@2: inline static TInetAddr& Cast(const TSockAddr* aAddr); williamr@2: williamr@2: IMPORT_C TBool IsUnicast() const; williamr@2: IMPORT_C TBool IsMulticast() const; williamr@2: IMPORT_C TBool IsLoopback() const; williamr@2: IMPORT_C TBool IsUnspecified() const; williamr@2: IMPORT_C TBool IsLinkLocal() const; williamr@2: IMPORT_C TBool IsSiteLocal() const; williamr@2: IMPORT_C TBool IsV4Compat() const; williamr@2: IMPORT_C TBool IsV4Mapped() const; williamr@2: williamr@2: IMPORT_C TUint32 Address() const; williamr@2: IMPORT_C void NetMask(const TInetAddr& aAddr); williamr@2: IMPORT_C void Net(const TInetAddr& aAddr); williamr@2: IMPORT_C void NetBroadcast(const TInetAddr& aAddr); williamr@2: IMPORT_C void SubNet(const TInetAddr& aAddr, const TInetAddr& aMask); williamr@2: IMPORT_C void SubNetBroadcast(const TInetAddr& aAddr, const TInetAddr& aMask); williamr@2: williamr@2: inline TBool IsClassA() const; williamr@2: inline TBool IsClassB() const; williamr@2: inline TBool IsClassC() const; williamr@2: inline TBool IsBroadcast() const; williamr@2: inline TBool IsWildAddr() const; williamr@2: inline TBool IsWildPort() const; williamr@2: williamr@2: IMPORT_C void SetScope(TUint32 aScope); williamr@2: IMPORT_C TUint32 Scope() const; williamr@2: williamr@2: IMPORT_C void Init(TUint aFamily); williamr@2: IMPORT_C void OutputWithScope(TDes &aBuf) const; williamr@2: protected: williamr@2: inline SInetAddr *Addr4Ptr() const; williamr@2: inline SInet6Addr *AddrPtr() const; williamr@2: inline static TInt AddrLen(); williamr@2: private: williamr@2: TInt Ipv4Input(const TDesC& aDes); williamr@2: TInt Ipv6Input(const TDesC& aDes); williamr@2: }; williamr@2: williamr@2: inline SInet6Addr* TInetAddr::AddrPtr() const williamr@2: /** Returns a pointer to #KAfInet6 content format. */ williamr@2: { return (SInet6Addr*)UserPtr(); } williamr@2: williamr@2: inline TInt TInetAddr::AddrLen() williamr@2: /** Returns the size of the #KAfInet6 content format. */ williamr@2: { return sizeof(SInet6Addr); } williamr@2: williamr@2: inline TInetAddr& TInetAddr::Cast(const TSockAddr& aAddr) williamr@2: /** williamr@2: * Casts a TSockAddr to a TInetAddr reference. williamr@2: * williamr@2: * The cast is only safe if the object being referenced is actually aTInetAddr. williamr@2: * williamr@2: * @param aAddr TSockAddr to cast williamr@2: * @return Casted reference to a TInetAddr. williamr@2: */ williamr@2: { return *((TInetAddr*)&aAddr); } williamr@2: williamr@2: inline TInetAddr& TInetAddr::Cast(const TSockAddr* aAddr) williamr@2: /** williamr@2: * Casts a TSockAddr to a TInetAddr reference. williamr@2: * williamr@2: * The cast is only safe if the object being referenced is actually aTInetAddr. williamr@2: * williamr@2: * @param aAddr TSockAddr to cast williamr@2: * @return Casted pointer to a TInetAddr. williamr@2: */ williamr@2: { return *((TInetAddr*)aAddr); } williamr@2: williamr@2: inline SInetAddr* TInetAddr::Addr4Ptr() const williamr@2: /** Returns a pointer to #KAfInet content format */ williamr@2: { return (SInetAddr*)UserPtr(); } williamr@2: williamr@2: inline TBool TInetAddr::IsBroadcast() const williamr@2: /** williamr@2: * Tests if the IP address is a limited broadcast address (255.255.255.255). williamr@2: * williamr@2: * @return ETrue if the IPv4 address value is a limited broadcast address; otherwise, EFalse williamr@2: */ williamr@2: { return Address() == KInetAddrBroadcast; } williamr@2: williamr@2: inline TBool TInetAddr::IsWildPort() const williamr@2: /** williamr@2: * Tests if the port is zero. williamr@2: * williamr@2: * @return ETrue if the port is zero; otherwise, EFalse. williamr@2: */ williamr@2: { return Port() == KInetPortNone; } williamr@2: williamr@2: inline TBool TInetAddr::IsWildAddr() const williamr@2: /** williamr@2: * Tests if the IP address is unspecified. williamr@2: * williamr@2: * This is same as IsUnspecified() williamr@2: * williamr@2: * @return ETrue if the IP address value is unspecified; otherwise, EFalse. williamr@2: */ williamr@2: { return IsUnspecified(); } williamr@2: williamr@2: inline TBool TInetAddr::IsClassA() const williamr@2: /** williamr@2: * Tests if the IP address is Class A. williamr@2: * williamr@2: * @return ETrue if the IPv4 address value is Class A; otherwise, EFalse williamr@2: * williamr@2: * @deprecated Works only for IPv4. It assumes the old IPv4 address classes williamr@2: * (A, B, C). Applications using this function may not work properly in the williamr@2: * current internet environment. williamr@2: */ williamr@2: { williamr@2: return (Family() == KAfInet || IsV4Mapped() || IsV4Compat()) && (Address() & KInetAddrIdMaskA) == KInetAddrIdValA; williamr@2: } williamr@2: williamr@2: inline TBool TInetAddr::IsClassB() const williamr@2: /** williamr@2: * Tests if the IP address is Class B. williamr@2: * williamr@2: * @return ETrue if the IPv4 address value is Class B; otherwise. EFalse williamr@2: * williamr@2: * @deprecated Works only for IPv4. It assumes the old IPv4 address classes williamr@2: * (A, B, C). Applications using this function may not work properly in the williamr@2: * current internet environment. williamr@2: */ williamr@2: { return (Address() & KInetAddrIdMaskB) == KInetAddrIdValB; } williamr@2: williamr@2: inline TBool TInetAddr::IsClassC() const williamr@2: /** williamr@2: * Tests if the IP address is Class C. williamr@2: * williamr@2: * @return ETrue if the IPv4 address value is Class C; otherwise, EFalse williamr@2: * @deprecated Works only for IPv4. It assumes the old IPv4 address classes williamr@2: * (A, B, C). Applications using this function may not work properly in the williamr@2: * current internet environment. williamr@2: */ williamr@2: { return (Address() & KInetAddrIdMaskC) == KInetAddrIdValC; } williamr@2: williamr@2: /** williamr@2: * @name Send/Recv flags (datagram sockets only) williamr@2: */ williamr@2: //@{ williamr@2: /** Don't fragment the packet. williamr@2: * williamr@2: * If the packet would require fragmentation due to a small williamr@2: * maximum transmission unit size (MTU), the packet is dropped williamr@2: * and an ICMP error message is generated: for ICMPv4 type=3 and code=4 williamr@2: * (#KInet4ICMP_Unreachable); and for ICMPv6 type=2 and code=0 williamr@2: * (#KInet6ICMP_PacketTooBig). williamr@2: * williamr@2: * Application must enable #KSoInetLastError to detect this situation. williamr@2: */ williamr@2: const TUint KIpDontFragment = 0x010000; williamr@2: /** williamr@2: * Packet includes IP or IPv6 header. williamr@2: * williamr@2: * When reading, the returned buffer starts with the received williamr@2: * IP header, which can be either IPv6 (TInet6HeaderIP4) or williamr@2: * IPv4 (TInet6HeaderIP). williamr@2: * williamr@2: * When writing buffers, the buffer must start with the IP williamr@2: * header and it must be complete. The stack does not williamr@2: * provide any defaults. williamr@2: * williamr@2: * @sa KSoRawMode, KSoHeaderIncluded williamr@2: */ williamr@2: const TUint KIpHeaderIncluded = 0x020000; williamr@2: /** williamr@2: * Don't route the packet. williamr@2: * williamr@2: * Not supported in Symbian 7.0 and 7.0s. williamr@2: */ williamr@2: const TUint KIpDontRoute = 0x040000; williamr@2: //@} williamr@2: williamr@2: williamr@2: /** williamr@2: * @name Interface control socket options williamr@2: * williamr@2: * Level: #KSolInetIfCtrl williamr@2: * williamr@2: * Enumerating & Configuring Interfaces using TSoInetInterfaceInfo and TSoInet6InterfaceInfo. williamr@2: */ williamr@2: //@{ williamr@2: /** williamr@2: * Begin enumeration of network interfaces. williamr@2: * williamr@2: * This option should be set before enumerating interfaces with #KSoInetNextInterface. williamr@2: * williamr@2: * This option is for use with RSocket::SetOpt() only. williamr@2: */ williamr@2: const TInt KSoInetEnumInterfaces = 0x211; williamr@2: /** williamr@2: * Return details of the next interface in an enumeration started by setting the williamr@2: * option #KSoInetEnumInterfaces. williamr@2: * williamr@2: * This option is for use with RSocket::GetOpt() only. williamr@2: * williamr@2: * Option data type is TSoInetInterfaceInfo. williamr@2: * williamr@2: * @note williamr@2: * If the interface has multiple addresses, then each address williamr@2: * is returned as a separate instance of TSoInetInterfaceInfo williamr@2: * (only address information is different each time). williamr@2: * @note williamr@2: * If the interface has no addresses, then one entry williamr@2: * with unspecified address is returned. williamr@2: */ williamr@2: const TInt KSoInetNextInterface = 0x212; williamr@2: williamr@2: /** williamr@2: * Configures the interface. williamr@2: * williamr@2: * This option is for use with RSocket::SetOpt() only. williamr@2: * williamr@2: * Option data type is TSoInet6InterfaceInfo. williamr@2: * williamr@2: * The interface is specified by setting the TSoInetInterfaceInfo::iName, williamr@2: * @since 7.0 williamr@2: * williamr@2: * @capability NetworkControl Modifying interfaces is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TInt KSoInetConfigInterface = 0x213; williamr@2: /** williamr@2: * Deletes the interface. williamr@2: * williamr@2: * This option is for use with RSocket::SetOpt() only. williamr@2: * williamr@2: * Option data type is TSoInet6InterfaceInfo. williamr@2: * williamr@2: * The interface is specified by setting the TSoInetInterfaceInfo::iName, williamr@2: * @since 7.0 williamr@2: * williamr@2: * @capability NetworkControl Modifying interfaces is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TUint KSoInetDeleteInterface = 0x214; williamr@2: /** williamr@2: * Configure the interface details, if it exists. williamr@2: * williamr@2: * Option data type is TSoInet6InterfaceInfo. williamr@2: * williamr@2: * The interface is specified by setting the TSoInetInterfaceInfo::iName, williamr@2: * williamr@2: * @note williamr@2: * Unlike KSoInetConfigInterface, never creates a new interface williamr@2: * entry, if one does not already exist. KSoInetConfigInterface williamr@2: * never fails with interface not found, as it always finds or williamr@2: * creates one. williamr@2: * @since 7.0 williamr@2: * williamr@2: * @capability NetworkControl Modifying interfaces is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TUint KSoInetChangeInterface = 0x215; williamr@2: /** williamr@2: * Resets interface to initial state. williamr@2: * williamr@2: * Delete all configuration (routes and addresses) from the williamr@2: * interface. Any sockets (flows) currently using this interface, williamr@2: * are set to holding state (#KSoNoInterfaceError is not required). williamr@2: * williamr@2: * The interface reconfigures, if the NIF driver williamr@2: * calls CProtocolBase::StartSending(), or if williamr@2: * #KSoInetStartInterface socket option is used. williamr@2: * williamr@2: * Option data type is TSoInet6InterfaceInfo. williamr@2: * williamr@2: * The interface is specified by setting the TSoInetInterfaceInfo::iName, williamr@2: * No other fields are used. williamr@2: * @since 7.0s williamr@2: * williamr@2: * @capability NetworkControl Modifying interfaces is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TUint KSoInetResetInterface = 0x216; williamr@2: /** williamr@2: * Restart interface, auto-reconfigure. williamr@2: * williamr@2: * Option data type is TSoInet6InterfaceInfo. williamr@2: * williamr@2: * The interface is specified by setting the TSoInetInterfaceInfo::iName, williamr@2: * No other fields are used. The selected interface is autoconfigured using the williamr@2: * information supplied by the attached network driver. williamr@2: * williamr@2: * Should normally only be called after #KSoInetResetInterface. williamr@2: * @since 7.0 williamr@2: * williamr@2: * @capability NetworkControl Modifying interfaces is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TUint KSoInetStartInterface = 0x217; williamr@2: williamr@2: /** williamr@2: * Trigger link local creation. williamr@2: * williamr@2: * Option data type is TSoInet6InterfaceInfo. williamr@2: * williamr@2: * The interface is specified by setting the TSoInetInterfaceInfo::iName and any state williamr@2: * change required. Called by a configuration deamon to trigger IPv4 zeroconf and link williamr@2: * local creation if no address server is found. Does nothing if williamr@2: * EV4LLConfigDaemonControlled option is not specified for interface. williamr@2: * williamr@2: * @since 9.2 williamr@2: * williamr@2: * @capability NetworkControl Modifying interfaces is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TUint KSoInetCreateIPv4LLOnInterface = 0x226; williamr@2: williamr@2: /** williamr@2: * Describes the state of an interface. williamr@2: * williamr@2: * It is used as a data member of TSoInetInterfaceInfo. williamr@2: * williamr@2: * @note williamr@2: * This enumeration is supported only because of backward williamr@2: * compatibility. The real interface state uses the system williamr@2: * error codes directly. The interface is either up williamr@2: * (KErrNone) or down because of some error condition (state williamr@2: * is one of the system wide error codes indicating the reason williamr@2: * for the down state). williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: enum TIfStatus williamr@2: { williamr@2: /** The interface has been initiated, but is not yet available. */ williamr@2: EIfPending, williamr@2: /** The interface is up and available. */ williamr@2: EIfUp, williamr@2: /** The interface is up, but flowed off. */ williamr@2: EIfBusy, williamr@2: /** The interface is down. */ williamr@2: EIfDown, williamr@2: }; williamr@2: williamr@2: class TSoInetInterfaceInfo williamr@2: /** williamr@2: * Used when listing interfaces with socket option. williamr@2: * williamr@2: * Used with interface level #KSolInetIfCtrl option #KSoInetNextInterface. williamr@2: * williamr@2: * This is also a base class for the TSoInet6InterfaceInfo, williamr@2: * which is used in modifying the interface configuration. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** Ignored since 7.0. @removed The field exists, but it is ignored. */ williamr@2: TName iTag; williamr@2: /** Interface name */ williamr@2: TName iName; williamr@2: /** Interface state. */ williamr@2: TIfStatus iState; williamr@2: /** Maximum transmission unit (bytes) */ williamr@2: TInt iMtu; williamr@2: /** An approximation of the interface speed in Kbps. */ williamr@2: TInt iSpeedMetric; williamr@2: /** williamr@2: * Feature flags. williamr@2: * williamr@2: * Possible values are defined in in_iface.h. williamr@2: */ williamr@2: TUint iFeatures; williamr@2: /** Hardware address. */ williamr@2: TSockAddr iHwAddr; williamr@2: /** Interface IP address. */ williamr@2: TInetAddr iAddress; williamr@2: /** IP netmask. */ williamr@2: TInetAddr iNetMask; williamr@2: /** IP broadcast address. */ williamr@2: TInetAddr iBrdAddr; williamr@2: /** IP default gateway or peer address (if known). */ williamr@2: TInetAddr iDefGate; williamr@2: /** IP primary name server (if any). */ williamr@2: TInetAddr iNameSer1; williamr@2: /** IP secondary name server (if any). */ williamr@2: TInetAddr iNameSer2; williamr@2: }; williamr@2: williamr@2: class TSoInet6InterfaceInfo : public TSoInetInterfaceInfo williamr@2: /** williamr@2: * Extension for TSoInetInterfaceInfo. Available in Symbian OS v7.0 and later. williamr@2: * williamr@2: * Used with the following interface level #KSolInetIfCtrl options: williamr@2: * @li #KSoInetConfigInterface williamr@2: * @li #KSoInetDeleteInterface williamr@2: * @li #KSoInetChangeInterface williamr@2: * @li #KSoInetResetInterface williamr@2: * @li #KSoInetStartInterface williamr@2: * @li #KSoInetCreateIPv4LLOnInterface williamr@2: * williamr@2: * The following configuration changes are only activated with williamr@2: * #KSoInetConfigInterface and #KSoInetChangeInterface options. williamr@2: * For these two, the extension specifies the details of actions williamr@2: * to be performed. The extension is a collection of control bits, williamr@2: * which can be grouped as williamr@2: * williamr@2: * @li modifiers (#iDelete and #iAlias) williamr@2: * @li actions: #iDoState, #iDoId (with subactions #iDoAnycast or #iDoProxy) and #iDoPrefix. williamr@2: * williamr@2: * The effect of the modifiers depend on the chosen action (in some williamr@2: * actions modifiers are ignored). williamr@2: * The iDoState can be combined with any other actions, but for the williamr@2: * remaining only the following combinations are valid: williamr@2: * williamr@2: * @li williamr@2: * no address configuration: iDoId=0, iDoPrefix=0 (iDoProxy, williamr@2: * iDoAnycast, iDelete and iAlias are ignored). williamr@2: * @li williamr@2: * configure single IPv6 or IPv4 address: williamr@2: * iDoid, iAddress has the address, iNetMask unspecified. williamr@2: * @li williamr@2: * configure IPv6 id part: iDoId, iAddress is IPv6 address williamr@2: * (fe80::id) and iNetMask defined (for 64 bits, use williamr@2: * ffff:ffff:ffff:ffff::). williamr@2: * @li williamr@2: * configure IPv4 address and netmask: iDoId, iNetMask defined. williamr@2: * @li williamr@2: * configure IPv6 or IPv4 anycast address: iDoId, iDoAnycast, williamr@2: * iAddress has the address (iNetMask ignored). williamr@2: * @li williamr@2: * configure IPv6 or IPv4 proxy address: iDoId, iDoProxy, williamr@2: * iAddress has the address (iNetMask ignored). williamr@2: * @li williamr@2: * configure IPv6 prefix and id part: iDoId, iDoPrefix, williamr@2: * iAddress is the IPv6 address (prefix::id) and iNetMask defined williamr@2: * (for 64 bits, use ffff:ffff:ffff:ffff::). williamr@2: * @li williamr@2: * configure IPv6 prefix: iDoPrefix, iAddress is the prefix (prefix::) williamr@2: * and iNetMask defined (for 64 bits, use ffff:ffff:ffff:ffff::). williamr@2: * williamr@2: * The default route is processed if #iDefGate is specified. williamr@2: * If the gateway address is an IPv4 address, then it defines IPv4 williamr@2: * default route. Additionally, if the iDefGate is same as iAddress, then williamr@2: * this is interpreted as a request to treat the default route as williamr@2: * "onlink route" instead of the normal gateway route. #iDelete modifier williamr@2: * controls whether default route is added or deleted. williamr@2: * williamr@2: * The MTU is updated, if #iMtu has non-zero value. williamr@2: * williamr@2: * Available in Symbian OS v9.2 and later. williamr@2: * williamr@2: * Used with the following interface level #KSolInetIfCtrl option: williamr@2: * @li #KSoInetCreateIPv4LLOnInterface williamr@2: * williamr@2: * @li actions: #iDoState. williamr@2: * williamr@2: * This configuration acts as a notification from a config daemon to the IP stack williamr@2: * which controls link local behaviour if the llv4linklocal=ELLV4ConfigDeamonControlled williamr@2: * TCPIP.ini option is specified for the interface: williamr@2: * williamr@2: * @li williamr@2: * notification from config daemon (e.g., DHCP) that address assignment terminated williamr@2: * so a link local should be created if appropriate TCPIP.ini setting is used: williamr@2: * iDoState. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: * @since 7.0 (some functionality only in 7.0s and >=9.3 for config daemon controlled link local creation) williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Add or delete modifier. williamr@2: * williamr@2: * 0 = add, 1 = delete williamr@2: * williamr@2: * Modifies the actions for address configuration (#iDoId, #iDoPrefix) williamr@2: * and iDefGate processing (see detail descripton above). williamr@2: */ williamr@2: TUint iDelete:1; williamr@2: /** williamr@2: * Primary or alias modifier. williamr@2: * williamr@2: * 0 = primary, 1 = alias. williamr@2: * williamr@2: * @note williamr@2: * Always use 1 here (this is a relic, that most likely williamr@2: * should be deprecated, and defaulted to 1 always). williamr@2: */ williamr@2: TUint iAlias:1; williamr@2: /** williamr@2: * Prefix action (only for IPv6 addresses). williamr@2: * williamr@2: * 0 = don't do prefix, 1 = do the prefix. williamr@2: * williamr@2: * #iAddress must be specified. williamr@2: * williamr@2: * If set and iNetMask is defined, then #iNetMask and #iAddress williamr@2: * define a prefix for the interface (link). If iNetMask is williamr@2: * unspecified, then the iDoPrefix is ignored. williamr@2: * williamr@2: * @li iDelete=0: williamr@2: * Acts as if an IPv6 Router Advertisement with prefix option A=1 williamr@2: * and L=1 has arrived (e.g. this prefix can be used in address williamr@2: * generation and all addresses with this prefix are onlink on williamr@2: * this interface). williamr@2: * williamr@2: * @li iDelete=1: williamr@2: * The specified prefix is deleted from the interface (if it williamr@2: * existed before). williamr@2: * williamr@2: * @note williamr@2: * Current IPv6 specification allows only 64 for the number williamr@2: * of prefix bits. williamr@2: */ williamr@2: TUint iDoPrefix:1; williamr@2: /** williamr@2: * Address action. williamr@2: * williamr@2: * 0 = don't do address, 1= do the address. williamr@2: * williamr@2: * #iAddress must be specified. williamr@2: * williamr@2: * @note williamr@2: * If also either #iDoAnycast or #iDoProxy is set, then williamr@2: * the action is special for them (and the following williamr@2: * does not apply). williamr@2: * williamr@2: * If #iNetMask is unspecified, then #iAddress defines a single williamr@2: * address (either IPv4 or IPv6) which is to be added or removed, williamr@2: * depending on the state of the #iDelete modifier. #iAlias williamr@2: * is ignored. williamr@2: * williamr@2: * If #iNetMask is specified, then the following applies: williamr@2: * williamr@2: * @li iDelete=0 and iAddress is IPv4 address: williamr@2: * iAddress and iNetMask are used to configure additional williamr@2: * IPv4 address and netmask for the interface. williamr@2: * @li iDelete=0 and iAddress is IPv6 address williamr@2: * The iNetmask and iAddress define a ID part, which can be williamr@2: * combined with any defined prefix to form a full IPv6 address. williamr@2: * If iAlias is set, then a new ID is added; otherwise whatever williamr@2: * happens to be stored in the primary id slot is overwritten williamr@2: * (always use iAlias=1 to avoid confusion). williamr@2: * williamr@2: * @li iDelete=1: williamr@2: * The previously configured address or ID is deleted. williamr@2: * williamr@2: * @note williamr@2: * The IPv4 netmask alone cannot be added or deleted. Use #KSolInetRtCtrl williamr@2: * options. williamr@2: */ williamr@2: TUint iDoId:1; williamr@2: /** williamr@2: * Interface state action. williamr@2: * williamr@2: * 0 = ignore TSoInetInterfaceInfo::iState, williamr@2: * williamr@2: * 1 = set interface state based on williamr@2: * TSoInetInterfaceInfo::iState as follows: williamr@2: * @li EIfDown: williamr@2: * The interface state is set to KErrNotReady. williamr@2: * @li EIfUp: williamr@2: * The interface state is set to 0 (KErrNone). williamr@2: * @li williamr@2: * Attempt to set any other state results failed operation williamr@2: * with KErrArgument result. williamr@2: */ williamr@2: TUint iDoState:1; williamr@2: /** williamr@2: * Configure address as Anycast. williamr@2: * williamr@2: * The anycast address is defined by #iAddress. williamr@2: * williamr@2: * Anycast address is recognized as own address for incoming williamr@2: * packets, but it cannot be used as a source address for williamr@2: * outgoing packets. IPv6 DAD (or IPv4 ARP duplicate address) williamr@2: * test is not done for anycast addresses. Anycast address is williamr@2: * advertised on the link as an address of this host. williamr@2: * williamr@2: * 1 = configure anycast (#iDoId must also be set, #iDoPrefix is ignored) williamr@2: * williamr@2: * @li iDelete=0: williamr@2: * Add anycast address. williamr@2: * @li iDelete=1: williamr@2: * Remove the previously configured anycast address. williamr@2: * williamr@2: * @since 7.0s williamr@2: */ williamr@2: TUint iDoAnycast:1; williamr@2: /** williamr@2: * Confiture address as Proxy. williamr@2: * williamr@2: * The proxy address is defined by #iAddress. williamr@2: * williamr@2: * Proxy address is not recognized as own address for incoming williamr@2: * packets (nor can it be used as own address for outgoing packets). williamr@2: * IPv6 DAD (or IPv4 ARP duplicate address) test is performed for williamr@2: * proxy address. Proxy address is advertised on the link as an williamr@2: * address of this host. williamr@2: * williamr@2: * 1 = configure proxy (#iDoId must also be set, #iDoPrefix is ignored) williamr@2: * williamr@2: * @li iDelete=0: williamr@2: * Add proxy address. williamr@2: * @li iDelete=1: williamr@2: * Remove the previously configured proxy address. williamr@2: * williamr@2: * @since 7.0s williamr@2: */ williamr@2: TUint iDoProxy:1; williamr@2: }; williamr@2: //@} williamr@2: williamr@2: /** williamr@2: * @name Interface query socket options williamr@2: * williamr@2: * Level: #KSolInetIfQuery williamr@2: * williamr@2: * Querying information about interfaces using TSoInetIfQuery. williamr@2: * williamr@2: * @since 7.0 (some additions in 7.0s) williamr@2: */ williamr@2: //@{ williamr@2: /** Scope Id vector (member of TSoInetIfQuery). @since 7.0s */ williamr@2: typedef TUint32 TInetScopeIds[16]; williamr@2: williamr@2: class TSoInetIfQuery williamr@2: /** williamr@2: * Interface query. williamr@2: * williamr@2: * Used with interface query options: williamr@2: * @li #KSoInetIfQueryByDstAddr williamr@2: * @li #KSoInetIfQueryBySrcAddr williamr@2: * @li #KSoInetIfQueryByIndex williamr@2: * @li #KSoInetIfQueryByName williamr@2: * williamr@2: * Only GetOption for KSolInetIfQuery is supported. It returns williamr@2: * information about the selected interface. The option name williamr@2: * determines the input field in the TSoInetIfQuery, which is williamr@2: * used as a key for locating the interface. williamr@2: * williamr@2: * Returns, KErrNotFound, if interface is not found williamr@2: * williamr@2: * Returns, KErrNone, if interface is located, and fills williamr@2: * fields from the interface with following logic williamr@2: * williamr@2: * @li iDstAddr: not touched, left as is williamr@2: * @li iSrcAddr is result of the Select Source Address algorithm williamr@2: * for the interface using the iDstAddr as input. If there williamr@2: * is no valid source address, the value will be KAFUnspec. williamr@2: * @li iIndex is loaded with the interface index of the interface williamr@2: * @li iName is loaded from the name of the interface williamr@2: * @li iIsUp is set 1, if interface has CNifIfBase pointer attached, williamr@2: * and 0 otherwise. williamr@2: * williamr@2: * For example, if QueryByDstAddr for specified destination address williamr@2: * results iIsUp == 1, then there is an interface and route for that williamr@2: * destination. iIsUp == 0, means that trying to connect to the address williamr@2: * will most likely activate a netdial/interface link startup phase. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Destination address. williamr@2: * @li input: williamr@2: * If the option is #KSoInetIfQueryByDstAddr, select williamr@2: * interface by finding a route for this address; williamr@2: * otherwise, ignored. williamr@2: * @li output: not changed. williamr@2: * williamr@2: * @note williamr@2: * On returning interface information, regardless of williamr@2: * the option used, the content of this is used to select williamr@2: * a matching source address (#iSrcAddr). williamr@2: */ williamr@2: TInetAddr iDstAddr; williamr@2: /** williamr@2: * Source address. williamr@2: * @li input: williamr@2: * If the option is #KSoInetIfQueryBySrcAddr, select williamr@2: * interface by source address; otherwise, ignored. williamr@2: * @li output: williamr@2: * The result of the source address williamr@2: * selection algorithm based on the content of the williamr@2: * #iDstAddr. williamr@2: */ williamr@2: TInetAddr iSrcAddr; williamr@2: /** williamr@2: * Interface Index. williamr@2: * williamr@2: * @li input: williamr@2: * If the option is #KSoInetIfQueryByIndex, select williamr@2: * interface by this interface index; otherwise, williamr@2: * ignored. williamr@2: * @li output: williamr@2: * The interface index the located interface. williamr@2: * (always same as iZone[0] in 7.0s). williamr@2: */ williamr@2: TUint32 iIndex; williamr@2: /** Interface name. williamr@2: * @li input: williamr@2: * If the option is #KSoInetIfQueryByName, select williamr@2: * interface by this name; otherwise, ignored. williamr@2: * @li output: williamr@2: * The name of the located interface. williamr@2: */ williamr@2: TName iName; williamr@2: /** williamr@2: * Flag that is set to 1 if the network interface is attached. williamr@2: * @li input: ignored williamr@2: * @li output: set as indicated. williamr@2: */ williamr@2: TUint iIsUp:1; williamr@2: /** williamr@2: * Scope Id Vector (iZone[0] = Interface Index, iZone[1] = IAP ID, iZone[15] = Network ID). williamr@2: * @li input: ignored williamr@2: * @li output: The scope id vector williamr@2: * @since 7.0s williamr@2: */ williamr@2: TInetScopeIds iZone; williamr@2: }; williamr@2: /** williamr@2: * Get information for the interface specified by the destination address (iDstAddr) williamr@2: * field of the passed packaged TSoInetIfQuery. williamr@2: * williamr@2: * This allows the caller to find out what interface would be used (without invoking williamr@2: * a dial-up process) for the specified destination. A path for this destination williamr@2: * is open, if GetOpt() returns KErrNone, iSrcAddr is not KAFUnspec, and iIsUp williamr@2: * == 1. williamr@2: */ williamr@2: const TUint KSoInetIfQueryByDstAddr = 0x1; williamr@2: /** williamr@2: * Get information for the interface specified by the source address (iSrcAddr) williamr@2: * field of the passed packaged TSoInetIfQuery. williamr@2: * williamr@2: * If there are multiple interfaces with the same source address, then the first williamr@2: * matching interface is returned. williamr@2: * williamr@2: * @note williamr@2: * The information return phase will overwrite the iSrcAddr based on williamr@2: * whatever happens to be in iDstAddr. It is not necessary to initialize williamr@2: * iDstAddr, if application is not interested in resulting iSrcAddr. williamr@2: */ williamr@2: const TUint KSoInetIfQueryBySrcAddr = 0x2; williamr@2: /** williamr@2: * Get information for the interface specified by the Interface Index (iIndex) williamr@2: * field of the passed packaged TSoInetIfQuery. williamr@2: */ williamr@2: const TUint KSoInetIfQueryByIndex = 0x3; williamr@2: /** williamr@2: * Get information for the interface specified by the Interface Name (iName) field williamr@2: * of the passed packaged TSoInetIfQuery. williamr@2: */ williamr@2: const TUint KSoInetIfQueryByName = 0x4; williamr@2: williamr@2: /** Load scope vector from iZone (Set) @internalAll */ williamr@2: const TUint KSoInetIfQuerySetScope = 0x10; williamr@2: /** Set interface to Host mode @internalAll */ williamr@2: const TUint KSoInetIfQuerySetHost = 0x11; williamr@2: /** Set interface to Router mode @internalAll */ williamr@2: const TUint KSoInetIfQuerySetRouter = 0x12; williamr@2: williamr@2: //@} williamr@2: williamr@2: /** williamr@2: * @name Route control socket options williamr@2: * williamr@2: * Level: #KSolInetRtCtrl williamr@2: * williamr@2: * Enumerating & Configuring Routes using TSoInetRouteInfo. williamr@2: */ williamr@2: //@{ williamr@2: /** williamr@2: * Begin enumeration of routes. williamr@2: * williamr@2: * This option can only be used with RSocket::SetOpt(). williamr@2: * williamr@2: * This option should be set before enumerating routes with #KSoInetNextRoute. williamr@2: * williamr@2: * @capability NetworkServices williamr@2: */ williamr@2: const TInt KSoInetEnumRoutes = 0x221; williamr@2: /** williamr@2: * Return the next route in an enumeration started by setting the option #KSoInetEnumRoutes. williamr@2: * williamr@2: * Option data type is TSoInetRouteInfo. williamr@2: * williamr@2: * This option can only be used with RSocket::GetOpt(). williamr@2: * williamr@2: * @capability NetworkServices williamr@2: */ williamr@2: const TInt KSoInetNextRoute = 0x222; williamr@2: /** williamr@2: * Adds the specified route to the routing table. williamr@2: * williamr@2: * Option data type is TSoInetRouteInfo. williamr@2: * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist. williamr@2: * williamr@2: * This option can only be used with RSocket::SetOpt(). williamr@2: * williamr@2: * @capability NetworkControl Modifying routes is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TInt KSoInetAddRoute = 0x223; williamr@2: /** williamr@2: * Deletes the specified route from the routing table. williamr@2: * williamr@2: * The route is identified by destination, netmask and gateway, williamr@2: * These must exactly match the old route to be deleted. williamr@2: * williamr@2: * Option data type is TSoInetRouteInfo. williamr@2: * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist. williamr@2: * williamr@2: * This option can only be used with RSocket::SetOpt(). williamr@2: * williamr@2: * @capability NetworkControl Modifying routes is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TInt KSoInetDeleteRoute = 0x224; williamr@2: /** williamr@2: * Modifies the specified route in the routing table. williamr@2: * williamr@2: * The destination, netmask and gateway settings must be the same williamr@2: * in the new route as in the old. williamr@2: * williamr@2: * Option data type is TSoInetRouteInfo. williamr@2: * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist. williamr@2: * williamr@2: * This option can only be used with RSocket::SetOpt(). williamr@2: * williamr@2: * @capability NetworkControl Modifying routes is allowed for authorized apps only. williamr@2: * @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TInt KSoInetChangeRoute = 0x225; williamr@2: williamr@2: /** williamr@2: * Identifies the state of a route held in an entry in the IP routing table. williamr@2: * williamr@2: * It is used as a data member of TSoInetRouteInfo. williamr@2: * williamr@2: * @note williamr@2: * This enumeration is present only because of backward williamr@2: * compatibility. Only two values are used. williamr@2: * williamr@2: * @since 7.0 (in this form) williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: enum TRouteState williamr@2: { williamr@2: /** Unused. */ williamr@2: ERtNone, williamr@2: /** Route is neighbour cache entry, ARP or Neighbor discovery is in progress. */ williamr@2: ERtPending, williamr@2: /** Unused */ williamr@2: ERtBusy, williamr@2: /** The interface for the route is up and ready. */ williamr@2: ERtReady, williamr@2: /** Unused */ williamr@2: ERtDown williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Identifies the type of creator of an entry in the IP routing table. williamr@2: * williamr@2: * It is used as a data member of TSoInetRouteInfo. williamr@2: * williamr@2: * @note williamr@2: * This enumeration is present only because of backward williamr@2: * compatibility. Only two values are used. williamr@2: * williamr@2: * @since 7.0 (in this form) williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: enum TRouteType williamr@2: { williamr@2: /** Normal route entry */ williamr@2: ERtNormal, williamr@2: /** Unused */ williamr@2: ERtUser, williamr@2: /** Route is ARP or neighbor cache entry */ williamr@2: ERtIcmpAdd, williamr@2: /** Unused */ williamr@2: ERtIcmpDel williamr@2: }; williamr@2: williamr@2: class TLinkAddr : public TSockAddr williamr@2: /** williamr@2: * TLinkAddr williamr@2: * williamr@2: * Link layer address utility. williamr@2: * williamr@2: * Lightweight helper class for handling link layer addresses. williamr@2: * williamr@2: * This class is mainly used to obtain direct access to the raw address williamr@2: * bytes which are inacessible from the TSockAddr interface. williamr@2: * williamr@2: * A link layer address is a binary string of octets. williamr@2: * williamr@2: * The address family of the TLinkAddr is determined by the interface. If williamr@2: * the interface uses link layer addresses, it must support the williamr@2: * #KSoIfHardwareAddr control option, and the returned address family of the williamr@2: * harware address is supposed to represent the family of all link layer addresses williamr@2: * of peers on the interface. williamr@2: * williamr@2: * Link layer addresses can be obtained from e.g. TSoInetRouteInfo structures williamr@2: * using the TSoInetRouteInfo::GetLinkAddr function. Note: this may fail if the williamr@2: * link layer address of the peer corresponding to the route is not known. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TLinkAddr(); williamr@2: IMPORT_C void SetAddress(const TDesC8 &aAddr); williamr@2: williamr@2: IMPORT_C TPtrC8 Address() const; williamr@2: williamr@2: IMPORT_C const static TLinkAddr& Cast(const TSockAddr& aAddr); williamr@2: IMPORT_C static TLinkAddr& Cast(TSockAddr& aAddr); williamr@2: IMPORT_C const static TLinkAddr* Cast(const TSockAddr* aAddr); williamr@2: IMPORT_C static TLinkAddr* Cast(TSockAddr* aAddr); williamr@2: }; williamr@2: williamr@2: class TSoInetRouteInfo williamr@2: /** williamr@2: * Route information structure. williamr@2: * williamr@2: * Used with route options: williamr@2: * williamr@2: * @li #KSoInetNextRoute williamr@2: * @li #KSoInetAddRoute williamr@2: * @li #KSoInetDeleteRoute williamr@2: * williamr@2: * IPv4 addresses are returned as IPv4-mapped IPv6 addresses williamr@2: * qualified with appropriate scope id (Symbian OS 7.0 and later). williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TInt GetLinkAddr( TLinkAddr &aInfo ) const; williamr@2: williamr@2: /** Route type. */ williamr@2: TRouteType iType; williamr@2: /** Route state. */ williamr@2: TRouteState iState; williamr@2: /** Route preference, with a smaller value indicating a preferred route. */ williamr@2: TInt iMetric; williamr@2: /** IP address of the interface used for this route. */ williamr@2: TInetAddr iIfAddr; williamr@2: /** IP address of the gateway, or link-layer address for neighbour cache entries */ williamr@2: TInetAddr iGateway; williamr@2: /** IP address of the destination network or host. */ williamr@2: TInetAddr iDstAddr; williamr@2: /** Destination mask of network. */ williamr@2: TInetAddr iNetMask; williamr@2: }; williamr@2: williamr@2: class TSoInetCachedRouteInfo : public TSoInetRouteInfo williamr@2: /** williamr@2: * Access to route cache TPckgBuf, set iDstAddr for required address williamr@2: * With a level of KSolInetRtCtrl. This API is no longer suported. williamr@2: * williamr@2: * @removed williamr@2: * @since 7.0 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** Unused */ williamr@2: TInt iPathMtu; williamr@2: /** Unused */ williamr@2: TUint iPathRtt; williamr@2: }; williamr@2: williamr@2: /** No longer supported. @removed. @since 7.0 */ williamr@2: const TInt KSoInetCachedRouteByDest = 0x225; williamr@2: williamr@2: //@} williamr@2: williamr@2: williamr@2: /** williamr@2: * @name DNS definitions williamr@2: */ williamr@2: //@{ williamr@2: /** williamr@2: * Flags returned from DNS records. williamr@2: * williamr@2: * Provides flag bitmasks that are used to describe properties of results of DNS williamr@2: * queries via RHostResolver. williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: enum TNameRecordFlags williamr@2: { williamr@2: /** Name is an Alias. */ williamr@2: EDnsAlias=0x00000001, williamr@2: /** Answer is authoritive. */ williamr@2: EDnsAuthoritive=0x00000002, williamr@2: /** Answer is from hosts file. */ williamr@2: EDnsHostsFile=0x00000004, williamr@2: /** Answer is from a DNS server. */ williamr@2: EDnsServer=0x00000008, williamr@2: /** Answer is host name for this host. */ williamr@2: EDnsHostName=0x00000010, williamr@2: /** Answer is from the resolver cache. */ williamr@2: EDnsCache=0x00000020, williamr@2: /** Answer does not have a route set */ williamr@2: EDnsNoRoute=0x00000040 williamr@2: }; williamr@2: williamr@2: /** No longer supported. williamr@2: * @removed williamr@2: * @since 7.0 */ williamr@2: const TUint KSoDnsCacheEnable = 0x600; williamr@2: /** No longer supported. williamr@2: * @removed williamr@2: * @since 7.0 */ williamr@2: const TUint KSoDnsCacheFlush = 0x601; williamr@2: //@} williamr@2: williamr@2: /** williamr@2: * @name TCP socket options williamr@2: * williamr@2: * Level: #KSolInetTcp williamr@2: */ williamr@2: //@{ williamr@2: /** williamr@2: * Complete the ioctl request when the data has been sent. williamr@2: */ williamr@2: const TUint KIoctlTcpNotifyDataSent = 0x300; williamr@2: williamr@2: /** williamr@2: * The maximum number of bytes that can be queued for sending. williamr@2: * williamr@2: * If this option is set when the connection state is not closed, williamr@2: * then KErrLocked is returned. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * The default value is 8192. williamr@2: */ williamr@2: const TUint KSoTcpSendWinSize = 0x301; williamr@2: /** williamr@2: * The maximum number of bytes that can be buffered for receiving. williamr@2: * williamr@2: * If this option is set when the connection state is not closed, williamr@2: * then KErrLocked is returned. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * The default value is 8192. williamr@2: */ williamr@2: const TUint KSoTcpRecvWinSize = 0x302; williamr@2: /** williamr@2: * The maximum TCP segment size (bytes). williamr@2: * williamr@2: * If this option is set when the connection state is not closed, williamr@2: * then KErrLocked is returned. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * The default value is 1460. williamr@2: */ williamr@2: const TUint KSoTcpMaxSegSize = 0x303; williamr@2: /** williamr@2: * Send data at once if there is an established connection, without williamr@2: * waiting for the maximum segment size to be reached. williamr@2: * williamr@2: * The default is disabled. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: */ williamr@2: const TUint KSoTcpNoDelay = 0x304; williamr@2: /** williamr@2: * On the time-out expiring without an acknowledgement being received, williamr@2: * send a packet designed to force a response if the peer is up and reachable. williamr@2: * williamr@2: * The default is disabled. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: */ williamr@2: const TUint KSoTcpKeepAlive = 0x305; williamr@2: /** williamr@2: * If address reuse is allowed, and a connection already exists between williamr@2: * the requested local and remote addresses, wait for the address to williamr@2: * become available. williamr@2: * williamr@2: * The default is disabled. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: * @removed williamr@2: */ williamr@2: const TUint KSoTcpAsync2MslWait = 0x306; williamr@2: /** williamr@2: * The number of bytes currently queued for sending. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt(). williamr@2: */ williamr@2: const TUint KSoTcpSendBytesPending = 0x307; williamr@2: /** williamr@2: * The number of bytes currently available for reading (the same value as williamr@2: * is obtained using KSOReadBytesPending). williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt(). williamr@2: */ williamr@2: const TUint KSoTcpReadBytesPending = 0x308; williamr@2: /** williamr@2: * The socket has been set to listen (through RSocket::Listen()). williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * Values are: 0. Not listening, 1. Listening williamr@2: * williamr@2: * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt(). williamr@2: */ williamr@2: const TUint KSoTcpListening = 0x309; williamr@2: /** williamr@2: * The number of current TCP sockets. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt(). williamr@2: */ williamr@2: const TUint KSoTcpNumSockets = 0x310; williamr@2: /** williamr@2: * Read out-of-band urgent data. williamr@2: * williamr@2: * KErrNotFound is returned if there is no data waiting and no williamr@2: * urgent data pointer has been received. williamr@2: * williamr@2: * KErrWouldBlock is returned if and urgent is available but data needs to be williamr@2: * read from the current stream to match the urgent data mark. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt(). williamr@2: */ williamr@2: const TUint KSoTcpReadUrgentData = 0x311; williamr@2: /** williamr@2: * Peeks for urgent data. The behaviour is the same as KSoTcpReadUrgentData, williamr@2: * but the urgent data is not removed. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt(). williamr@2: */ williamr@2: const TUint KSoTcpPeekUrgentData = 0x312; williamr@2: /** williamr@2: * True if the data stream has been read up to the point where urgent williamr@2: * data is available, otherwise false. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt(). williamr@2: */ williamr@2: const TUint KSoTcpRcvAtMark = 0x313; williamr@2: /** williamr@2: * The next send operation will mark the last byte sent as urgent data. williamr@2: * williamr@2: * The default is disabled. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: */ williamr@2: const TUint KSoTcpNextSendUrgentData = 0x314; williamr@2: /** williamr@2: * Receive out-of-band data in the normal data stream. williamr@2: * williamr@2: * The default is disabled. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: */ williamr@2: const TUint KSoTcpOobInline = 0x315; williamr@2: /** Not supported. @removed */ williamr@2: const TUint KSOTcpDebugMode = 0x11110000; williamr@2: //@} williamr@2: williamr@2: /** williamr@2: * @name IPv6 and IPv4 socket options williamr@2: * williamr@2: * Level: #KSolInetIp williamr@2: * williamr@2: */ williamr@2: //@{ williamr@2: /** williamr@2: * Data to place in IP Options field of sent datagrams. williamr@2: * williamr@2: * Not supported. @removed williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoIpOptions = 0x401; williamr@2: /** williamr@2: * Include IP header in data returned to client. williamr@2: * williamr@2: * IPv4 packets are returned as is with all headers in network byte order (until williamr@2: * v7.0, this returned IPv4 headers in host order). See TInet6HeaderIP4 and williamr@2: * TInet6HeaderIP for the header layout. williamr@2: * williamr@2: * The default is disabled. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: * williamr@2: * @sa KSoHeaderIncluded, KIpHeaderIncluded williamr@2: */ williamr@2: const TUint KSoRawMode = 0x402; williamr@2: /** williamr@2: * Assume that the IP header is included in all data written by the client. williamr@2: * williamr@2: * KSoRawMode must be set before this is allowed. williamr@2: * williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are: 0. Disable; 1. Enable williamr@2: * williamr@2: * The default is disabled. williamr@2: * williamr@2: * @sa KSoRawMode, KIpHeaderIncluded williamr@2: */ williamr@2: const TUint KSoHeaderIncluded = 0x403; williamr@2: /** williamr@2: * Type of Service field of outgoing datagrams. williamr@2: * williamr@2: * For IPv6, there is no Type of Service field, so this option sets the Traffic Class. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are 0-255. Because Explicit Congestion Notification [RFC3168] uses bits 6 & 7 williamr@2: * in the IP field, modifying the two least significant bits is not allowed with TCP. williamr@2: * SetOpt processing silently ignores any modifications on these bits when using TCP socket. williamr@2: * williamr@2: * The default value is 0. williamr@2: */ williamr@2: const TUint KSoIpTOS = 0x404; williamr@2: /** williamr@2: * Time to Live field of outgoing datagrams. williamr@2: * williamr@2: * This is same as #KSoIp6UnicastHops. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are [-1,,255]. The -1 resets to the configured default value. williamr@2: * williamr@2: * There are separate configured default values for the link local and other williamr@2: * destinations. Both defaults can be configured by the TCPIP.INI parameters williamr@2: * maxttl and linklocalttl, The compiled defaults are williamr@2: * #KTcpipIni_Maxttl and #KTcpipIni_LinkLocalttl. williamr@2: * williamr@2: * @note williamr@2: * For the TTL of multicast destinations, @see KSoIp6MulticastHops. williamr@2: */ williamr@2: const TUint KSoIpTTL = 0x405; williamr@2: /** williamr@2: * Allow a socket to be bound to an local address that is already in use. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: * williamr@2: * The default is disabled. williamr@2: * @capability NetworkControl Required for 'udp' sockets. williamr@2: */ williamr@2: const TUint KSoReuseAddr = 0x406; williamr@2: /** williamr@2: * Do not set socket into error state if currently connected williamr@2: * interface reports an error. williamr@2: * williamr@2: * For example, this could be enabled for a unconnected datagram williamr@2: * socket. Unconnected datagram sockets are connected to the williamr@2: * interface of the last sent packet. If multiple interfaces williamr@2: * are present, erroring the socket might not be the desired williamr@2: * action if just one interface gives an error. williamr@2: * williamr@2: * Another use case would be a connected socket (TCP), which williamr@2: * does not get error even if interface goes down, and comes williamr@2: * up with the same source address after a while. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: * williamr@2: * The default can be changed by the TCPIP.INI parameter noiferror, williamr@2: * and the compiled default is #KTcpipIni_Noiferror.. williamr@2: * williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoNoInterfaceError = 0x407; williamr@2: /** williamr@2: * Modify socket visibility. williamr@2: * williamr@2: * Background internet services that have sockets open count as active williamr@2: * user and prevents the TCPIP from shutting down. williamr@2: * By this socket option, such a process can make selected sockets to be williamr@2: * excluded from the count. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * By setting the value to 0, the socket is not counted as active user. The value williamr@2: * 1 makes it visible again. williamr@2: * williamr@2: * The option has no effect if the visibility state already matches the parameter. williamr@2: * williamr@2: * By default, all sockets are initially visible. williamr@2: * williamr@2: * @note williamr@2: * This option should only be used by background daemons which are williamr@2: * started by the TCPIP stack. williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoUserSocket = 0x408; williamr@2: /** williamr@2: * Set or get interface index of the socket. williamr@2: * williamr@2: * Gets the current interface index of the socket. Returns the williamr@2: * value used in the last set. williamr@2: * williamr@2: * If interface index has not been set by this option, then value is williamr@2: * determined as follows: williamr@2: * williamr@2: * @li williamr@2: * the interface index of the interface which got the last packet williamr@2: * from this socket. williamr@2: * @li williamr@2: * zero, if no packets have been sent or interface cannot be williamr@2: * determined. williamr@2: * williamr@2: * Option data type is TUint32. williamr@2: * williamr@2: * @since 7.0s williamr@2: */ williamr@2: const TUint KSoInterfaceIndex = 0x409; williamr@2: /** williamr@2: * Controls whether the interface flow counter is affected by this socket. williamr@2: * williamr@2: * This counter is used in determining when the interface can be brought down. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are: 0=Don't count, 1= count flow against williamr@2: * interface flow count. williamr@2: * williamr@2: * The default can be changed by the TCPIP.INI parameter keepinterfaceup, williamr@2: * and the compiled default is #KTcpipIni_KeepInterfaceUp. williamr@2: * williamr@2: * @since 7.0s williamr@2: */ williamr@2: const TUint KSoKeepInterfaceUp = 0x40a; williamr@2: /** williamr@2: * Enable use of 0 as a source address. williamr@2: * williamr@2: * When socket is bound to unspecified address (0), the stack will automaticly williamr@2: * select the source address for the outgoing packets. When this option is williamr@2: * set after bind, the stack will not select a new address. williamr@2: * williamr@2: * @since 7.0s williamr@2: */ williamr@2: const TUint KSoNoSourceAddressSelect = 0x40b; williamr@2: /** williamr@2: * Retrieve last error information. williamr@2: * williamr@2: * This option is for use with GetOpt() only. williamr@2: * williamr@2: * Option data type is TSoInetLastErr. williamr@2: */ williamr@2: const TUint KSoInetLastError = 0x200; williamr@2: /** williamr@2: * An Ioctl corresponding to the socket option KSoInetLastError. williamr@2: */ williamr@2: const TUint KIoctlInetLastError = 0x200; williamr@2: /** williamr@2: * Hop limit for outgoing datagrams: same as #KSoIpTTL. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are [-1,,255]. The -1 resets to the configured default value. williamr@2: * williamr@2: * @see #KSoIpTTL for details. williamr@2: * williamr@2: * @note williamr@2: * KSoIp6UnicastHops can be used to detect dual IPv4/IPv6 stack from williamr@2: * from the old TCPIP only-IPv4 stack. This option is only implemented williamr@2: * in the dual stack. williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoIp6UnicastHops = 0x465; williamr@2: /** williamr@2: * Interface for outgoing multicast packets williamr@2: * williamr@2: * Unused. williamr@2: */ williamr@2: const TUint KSoIp6MulticastIf = 0x46a; williamr@2: /** williamr@2: * Hop limit for multicast packets. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are [-1..255]. The -1 resets to the configured default value. williamr@2: * williamr@2: * The default is 1. williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoIp6MulticastHops = 0x46b; williamr@2: /** williamr@2: * Enable/disable loopback of the multicast packets. williamr@2: * williamr@2: * When enabled, multicast packets sent to this socket are internally williamr@2: * looped back (in addition to sending them onto the interface). Another williamr@2: * or same application listening the group and port, receives copies of williamr@2: * the transmitted packets. williamr@2: * williamr@2: * When disabled, an application on this host listening the same group williamr@2: * and port, does not receive multicast packets originating from this williamr@2: * socket (unless the interface or link echoes them back to the TCP/IP williamr@2: * stack). williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are 1=enable; 0=disable. The default is 1. williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoIp6MulticastLoop = 0x46c; williamr@2: /** williamr@2: * Join multicast group. williamr@2: * williamr@2: * Option data type is TIp6Mreq. williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoIp6JoinGroup = 0x46d; williamr@2: /** williamr@2: * Leave multicast group. williamr@2: * williamr@2: * Option data type is TIp6Mreq. williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoIp6LeaveGroup = 0x46e; williamr@2: /** williamr@2: * Hop limit for outgoing datagrams: similar to KSoIp6UnicastHops except williamr@2: * any socket option to override the current setting is ignored. The value williamr@2: * returned is either the value of the associated interface or the TCP/IP 6 williamr@2: * stack default if no interface has been selected yet. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are [0..255]. Value cannot be modified, only queried. williamr@2: * williamr@2: * @see KSoIp6UnicastHops for details. williamr@2: * williamr@2: * @since 9.2 williamr@2: */ williamr@2: const TUint KSoIp6InterfaceUnicastHops = 0x46f; williamr@2: williamr@2: williamr@2: class TSoInetLastErr williamr@2: /** williamr@2: * Error information for TCP/IP protocols. williamr@2: * williamr@2: * An object of this class is returned packaged as a TPckgBuf williamr@2: * in the option argument of RSocket::GetOpt(), when this function is called williamr@2: * with (KSolInetIp, KSoInetLastError). The data members of this object williamr@2: * are updated whenever a packet carrying an ICMP message is received. williamr@2: * williamr@2: * @note williamr@2: * This class is originally defined only for the IPv4 environment, and williamr@2: * there is no definite way of knowing whether the fields iErrType and williamr@2: * iErrCode contain ICMPv4 or ICMPv6 codes. A solution that will give williamr@2: * the correct answer in most normal cases, is williamr@2: @code williamr@2: TSoInetLastErr p; williamr@2: ... williamr@2: if (p.iErrAddr.Family() == KAfInet || p.iErrAddr.IsV4Mapped()) williamr@2: // assume ICMPv4 type and code williamr@2: else williamr@2: // assume ICMPv6 type and code williamr@2: @endcode williamr@2: williamr@2: * Alternatively, the error can be interpreted based on the member variable williamr@2: * iStatus, if it contains one of the extended error codes. These are are williamr@2: * common for both IPv4 and IPv6. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** The error code returned by the last ESOCK API function called. */ williamr@2: TInt iStatus; williamr@2: /** The value of the Type field of the last ICMP message. */ williamr@2: TInt iErrType; williamr@2: /** The value of the Code field of the last ICMP message. */ williamr@2: TInt iErrCode; williamr@2: /** A TInetAddr with the IP address and port set to the source address and port williamr@2: * of the failed datagram. */ williamr@2: TInetAddr iSrcAddr; williamr@2: /** A TInetAddr with the IP address and port set to the destination address and williamr@2: * port of the failed datagram. */ williamr@2: TInetAddr iDstAddr; williamr@2: /** A TInetAddr with the IP address set to the address of the host that generated williamr@2: * the error. */ williamr@2: TInetAddr iErrAddr; williamr@2: }; williamr@2: williamr@2: class TIp6Mreq williamr@2: /** williamr@2: * TIp6Mreq. williamr@2: * williamr@2: * Used by IPv6 or IPv4 multicast join/leave group socket options williamr@2: * #KSoIp6JoinGroup and #KSoIp6LeaveGroup. williamr@2: * williamr@2: * Joining to a multicast group address adds this address to the williamr@2: * list of addresses for which incoming packets are accepted. williamr@2: * Optionally, if the required support has been installed, some williamr@2: * MLD (Multicast Listener Discovery) protocol messages may be williamr@2: * generated. williamr@2: * williamr@2: * The multicast join/leave are always interface specific, williamr@2: * and the interface index should be specified in the set option call. williamr@2: * If the index value is set to 0, the stack attempts to select williamr@2: * some interface. williamr@2: * williamr@2: * @publishedAll williamr@2: * @released williamr@2: * @since 7.0 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** IPv6 or IPv4 multicast address. */ williamr@2: TIp6Addr iAddr; williamr@2: /** Interface Index. */ williamr@2: TUint iInterface; williamr@2: }; williamr@2: //@} williamr@2: williamr@2: /** williamr@2: * @name UDP options williamr@2: * williamr@2: * Level: #KSolInetUdp williamr@2: */ williamr@2: //@{ williamr@2: /** williamr@2: * Inform client of error if ICMP error packets received. williamr@2: * williamr@2: * The default is disabled. williamr@2: * williamr@2: * Option data type is TInt. williamr@2: * Values are: 0 = Disable, 1 = Enable. williamr@2: */ williamr@2: const TUint KSoUdpReceiveICMPError = 0x500; williamr@2: williamr@2: /** williamr@2: Set the UDP receive buffer size for a socket in bytes. Overrides global ini parameter williamr@2: udp_recv_buf. At least one datagram always fits to the buffer, no matter how williamr@2: small it is. williamr@2: williamr@2: Default receive buffer size is 8192 bytes, or the value given in udp_recv_buf. williamr@2: williamr@2: @internalAll williamr@2: @released williamr@2: */ williamr@2: const TUint KSoUdpRecvBuf = 0x501; williamr@2: williamr@2: /** williamr@2: Modifies address flag of UDP. Flag is used to control whether the socket is bound to williamr@2: IP address or not. Binding to specific address and then clearing this flag makes possible williamr@2: to receive packets sent to broadcast address but still to have a specific bound address williamr@2: for outgoing packets. williamr@2: */ williamr@2: const TUint KSoUdpAddressSet = 0x502; williamr@2: williamr@2: /** williamr@2: * Setting this option causes the UDP send operation to block when dynamic interface williamr@2: * setup is in progress, or when local flow control within the stack would otherwise williamr@2: * cause the packet to be dropped. williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoUdpSynchronousSend = 0x560; williamr@2: //@} williamr@2: williamr@2: /** williamr@2: * @name TCP/IP specific Socket provider options williamr@2: * williamr@2: * Level: #KSOLProvider williamr@2: */ williamr@2: //@{ williamr@2: /** williamr@2: * Internal flow option called when the flow is about to be closed. williamr@2: * williamr@2: * This option is only for the outbound flow hooks, which are williamr@2: * attached to the TCIP/IP stack. The stack generates a call, just williamr@2: * before the flow context associated with service access point williamr@2: * (SAP) provider is about to be closed. If a hook has stored williamr@2: * some socket specific state information into the flow context, williamr@2: * then this option event may be of some use to it. williamr@2: * @since 7.0 williamr@2: */ williamr@2: const TUint KSoFlowClosing = 0x600 | KSocketInternalOptionBit; williamr@2: //@} williamr@2: williamr@2: /** @name Extended error codes */ williamr@2: //@{ williamr@2: /** Network could not be reached. */ williamr@2: const TInt KErrNetUnreach = -190; williamr@2: /** Host could not be reached. */ williamr@2: const TInt KErrHostUnreach = -191; williamr@2: /** Protocol could not be reached. */ williamr@2: const TInt KErrNoProtocolOpt = -192; williamr@2: /** Urgent data error. */ williamr@2: const TInt KErrUrgentData = -193; williamr@2: //@} williamr@2: williamr@2: #endif