epoc32/include/in_sock.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // IPv6/IPv4 socket library public header 
    15 // 
    16 //
    17 
    18 /**
    19  @file in_sock.h
    20  @publishedAll
    21  @released
    22 */
    23 
    24 #ifndef __IN_SOCK_H__
    25 #define __IN_SOCK_H__
    26 
    27 #ifndef __ES_SOCK_H__
    28 #include <es_sock.h>
    29 #endif
    30 
    31 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
    32 #include <in_sock_internal.h>
    33 #endif
    34 
    35 /**
    36 * @name TCP/IP Protocol and address family
    37 *
    38 * The TCP/IP stack supports two different address formats
    39 * in the TInetAddr: KAfInet for plain IPv4 addresses (for
    40 * backward compatibility), and KAfInet6 for both IPv6 and
    41 * IPv4 addresses.
    42 *
    43 * Only the KAfInet is used as a <em>protocol family</em> constant
    44 * for the TCP/IP protocol family, when sockets are opened
    45 * (RSocket::Open() and RHostResolver::Open() ).
    46 *
    47 * KAfInet6 is only <em>address family</em>, and can only appear
    48 * as a family constant in TSockAddr class.
    49 *
    50 * @since 7.0
    51 */
    52 //@{
    53 /** Identifies the TCP/IP protocol family and v4 address family.
    54 *
    55 * @see TInetAddr
    56 */
    57 const TUint KAfInet				= 0x0800;
    58 /** Identifies the TCP/IP v6 address family.
    59 *
    60 * @see TInetAddr
    61 * @since 7.0
    62 */
    63 const TUint KAfInet6			= 0x0806;
    64 //@}
    65 
    66 /**
    67 * @name IP protocol IDs 
    68 * @ingroup ip_packet_formats
    69 */
    70 //@{
    71 /** 
    72 * Identifies the ICMP protocol.
    73 *
    74 * @capability NetworkServices	Required for opening 'icmp' sockets.
    75 * @ref RSocket::Open()
    76 */
    77 const TUint KProtocolInetIcmp	= 1;
    78 
    79 /**
    80 * Identifies the TCP protocol.
    81 *
    82 * @capability NetworkServices	Required for opening 'tcp' sockets.
    83 * @ref RSocket::Open()
    84 */
    85 const TUint KProtocolInetTcp	= 6;
    86 
    87 /**
    88 * Identifies the UDP protocol.
    89 *
    90 * @capability NetworkServices	Required for opening 'udp' sockets.
    91 * @ref RSocket::Open()
    92 */
    93 const TUint KProtocolInetUdp	= 17;
    94 
    95 /** IPv6 inside IP (v4 or v6). @since 7.0 */
    96 const TUint KProtocolInet6Ipip	= 41;
    97 
    98 /** Identifies the ICMPv6 protocol.
    99 *
   100 * @since 7.0
   101 * @capability NetworkServices	Required for opening 'icmp6' sockets.
   102 * @ref RSocket::Open()
   103 */
   104 const TUint KProtocolInet6Icmp	= 58;
   105 //@}
   106 
   107 /**
   108 * @name Internal Protocol IDs
   109 * Internal protocol id's do not appear in real
   110 * packets. An internal id only identifies a protocol
   111 * instance.
   112 * @{
   113 */
   114 /**
   115 * Identifies the IP (v4) protocol module.
   116 *
   117 * @capability NetworkControl		Required for opening 'ip' sockets.
   118 * @ref RSocket::Open()
   119 */
   120 const TUint KProtocolInetIp		= 0x100;
   121 
   122 /**
   123 * Identifies the IP (v6) protocol module.
   124 *
   125 * @since 7.0
   126 * @capability NetworkControl		Required for opening 'ip6' sockets.
   127 * @ref RSocket::Open()
   128 */
   129 const TUint KProtocolInet6Ip	= 0xF00;
   130 
   131 /** Unknown Protocol ID. @deprecated (never use in anything that binds to IP) */
   132 const TUint KProtocolUnknown = 0xdead;
   133 
   134 //@}
   135 
   136 /**  @name Socket option/ioctl levels */
   137 //@{
   138 /** ICMP socket option level (no options). */
   139 const TUint KSolInetIcmp		= 0x101;
   140 /** TCP socket options level. */
   141 const TUint KSolInetTcp			= 0x106;
   142 /** UDP socket options  level. */
   143 const TUint KSolInetUdp			= 0x111;
   144 /** IP socket options  level. */
   145 const TUint KSolInetIp			= 0x100;
   146 /** Interface control socket options level. */
   147 const TUint KSolInetIfCtrl		= 0x201;
   148 /** Route control socket options level.  */
   149 const TUint KSolInetRtCtrl		= 0x202;
   150 /** DNS control socket options level. @removed */
   151 const TUint KSolInetDnsCtrl		= 0x204;
   152 /** Interface query socket options level. @since 7.0 */
   153 const TUint KSolInetIfQuery		= 0x206;
   154 #ifdef SYMBIAN_DNS_PUNYCODE
   155 /** DNS set options level. */
   156 /**using a new constant instead of KSolInetDnsCtrl
   157  */
   158 const TUint KSolInetDns			= 0x208;
   159 #endif //SYMBIAN_DNS_PUNYCODE
   160 //@}
   161 
   162 /** Maximum IPv4 address length (bits). */
   163 const TInt KInetAddrMaxBits         = 32;
   164 /** Maximum IPv6 address length (bits). */
   165 const TInt KInet6AddrMaxBits        = 128;
   166 
   167 /** @name Port constants */
   168 //@{
   169 /** Any port flag (0). */
   170 const TUint KInetPortAny			= 0x0000; 
   171 /** No port flag (0). */
   172 const TUint KInetPortNone			= 0x0000;
   173 /** Minimum value of an automatically allocated port. */
   174 const TUint KInetMinAutoPort		= 32768;
   175 /** Maximum value of an automatically allocated port. */
   176 const TUint KInetMaxAutoPort		= 60999;
   177 //@}
   178 
   179 /**  @name IPv4 address constants and definitions */
   180 //@{
   181 
   182 /** 
   183 * Forms a 32-bit integer IPv4 address from the normal dotted-decimal representation. 
   184 * 
   185 * The four arguments are the four parts of the IPv4 address.
   186 * 
   187 * Example:
   188 * @code
   189 * TInetAddr addr;
   190 * const TUint32 KInetAddr = INET_ADDR(194,129,2,54);
   191 * addr.SetAddress(KInetAddr);
   192 * @endcode 
   193 */
   194 #define INET_ADDR(a,b,c,d) (TUint32)((((TUint32)(a))<<24)|((b)<<16)|((c)<<8)|(d))
   195 
   196 /** Any address flag (0.0.0.0). */
   197 const TUint32 KInetAddrAny				= INET_ADDR(0,0,0,0);
   198 /** No address flag (0.0.0.0). */
   199 const TUint32 KInetAddrNone				= INET_ADDR(0,0,0,0);
   200 /** All addresses mask (255.255.255.255). */
   201 const TUint32 KInetAddrAll				= INET_ADDR(255,255,255,255);
   202 /** Broadcast address (255.255.255.255). */
   203 const TUint32 KInetAddrBroadcast		= INET_ADDR(255,255,255,255);
   204 /** Loopback address (127.0.0.1). */
   205 const TUint32 KInetAddrLoop				= INET_ADDR(127,0,0,1);
   206 
   207 /** Group address range start. */
   208 const TUint32 KInetAddrGroupUnspec		= INET_ADDR(224,0,0,0);
   209 /** All hosts address (224.0.0.1). */
   210 const TUint32 KInetAddrGroupAllHosts	= INET_ADDR(224,0,0,1);
   211 /** Link-local net number. @since 7.0s */
   212 const TUint32 KInetAddrLinkLocalNet		= INET_ADDR(169,254,0,0);
   213 /** Link-local net mask.  @since 7.0s */
   214 const TUint32 KInetAddrLinkLocalNetMask	= INET_ADDR(255,255,0,0);
   215 
   216 /** All addresses mask (0.0.0.0). */
   217 const TUint32 KInetAddrMaskAll			= INET_ADDR(0,0,0,0);
   218 /** All bits mask (255.255.255.255). */
   219 const TUint32 KInetAddrMaskHost			= INET_ADDR(255,255,255,255);
   220 
   221 /** Class A net mask (255.0.0.0). */
   222 const TUint32 KInetAddrNetMaskA			= INET_ADDR(255,0,0,0);
   223 /** Class A host mask (0.255.255.255). */
   224 const TUint32 KInetAddrHostMaskA		= ~KInetAddrNetMaskA;
   225 /** Number of bits to right-shift a Class A address to obtain the network number. */
   226 const TInt KInetAddrShiftA				= 24;
   227 /** Class B net mask (255.255.0.0). */
   228 const TUint32 KInetAddrNetMaskB 		= INET_ADDR(255,255,0,0);
   229 /** Class B host mask (0.0.255.255). */
   230 const TUint32 KInetAddrHostMaskB		= ~KInetAddrNetMaskB;
   231 /** Number of bits to right-shift a Class B address to obtain the network number. */
   232 const TInt KInetAddrShiftB				= 16;
   233 /** Class C net mask (255.255.255.0). */
   234 const TUint32 KInetAddrNetMaskC 		= INET_ADDR(255,255,255,0);
   235 /** Class C host mask (0.0.0.255). */
   236 const TUint32 KInetAddrHostMaskC		= ~KInetAddrNetMaskC;
   237 /** Number of bits to right-shift a Class C address to obtain the network number. */
   238 const TInt KInetAddrShiftC				= 8;
   239 
   240 /** . */
   241 const TUint32 KInetAddrIdMaskA			= 0x80000000;
   242 /** . */
   243 const TUint32 KInetAddrIdValA			= 0x00000000;
   244 /** . */
   245 const TUint32 KInetAddrIdMaskB			= 0xc0000000;
   246 /** . */
   247 const TUint32 KInetAddrIdValB			= 0x80000000;
   248 /** . */
   249 const TUint32 KInetAddrIdMaskC			= 0xe0000000;
   250 /** . */
   251 const TUint32 KInetAddrIdValC			= 0xc0000000;
   252 /** . */
   253 const TUint32 KInetAddrIdMaskD			= 0xf0000000;
   254 /** . */
   255 const TUint32 KInetAddrIdValD			= 0xe0000000;
   256 /** . */
   257 const TUint32 KInetAddrIdMaskE			= 0xf8000000;
   258 /** . */
   259 const TUint32 KInetAddrIdValE			= 0xf0000000;
   260 
   261 enum TInetAddrClass
   262 /**
   263 * @publishedAll
   264 * @released
   265 */
   266 	{
   267 	EInetClassUnknown = 0,
   268 	EInetClassA,
   269 	EInetClassB,
   270 	EInetClassC,
   271 	EInetClassD,
   272 	EInetClassE,
   273 	EInetMulticast = EInetClassD,
   274 	EInetExperimental = EInetClassE
   275 	};
   276 //@}
   277 
   278 struct SInetAddr
   279 /**
   280 * IPv4 socket address.
   281 *
   282 * This exists for backward compatibility. SInet6Addr is
   283 * the preferred format for both IPv4 and IPv6 addresses
   284 * in TInetAddr.
   285 *
   286 * @publishedAll
   287 * @released
   288 */
   289 	{
   290 	/** Plain IPv4 address */
   291 	TUint32 iAddr;
   292 	};
   293 
   294 
   295 class TIp6Addr
   296 /**
   297 * The 128 bits of IPv6 or IPv4 address stored in network byte order.
   298 *
   299 * IPv4 addresses are stored in IPv4 mapped format.
   300 *
   301 * @publishedAll
   302 * @released
   303 * @since 7.0
   304 */
   305 	{
   306 public:
   307 	IMPORT_C TBool IsUnicast() const;
   308 	IMPORT_C TBool IsMulticast() const;
   309 	IMPORT_C TBool IsLoopback() const;
   310 	IMPORT_C TBool IsUnspecified() const;
   311 	IMPORT_C TBool IsLinkLocal() const;
   312 	IMPORT_C TBool IsSiteLocal() const;
   313 	IMPORT_C TBool IsV4Compat() const;
   314 	IMPORT_C TBool IsV4Mapped() const;
   315 	IMPORT_C TBool IsEqual(const TIp6Addr &aAddr) const;
   316 	IMPORT_C TInt Match(const TIp6Addr &aAddr) const;
   317 	IMPORT_C TInt Scope() const;
   318 	union
   319 		{
   320 		TUint8  iAddr8[16];
   321 		TUint16 iAddr16[8];
   322 		TUint32 iAddr32[4];
   323 		} u;
   324 	};
   325 
   326 struct SInet6Addr
   327 /**
   328 * IPv4 and IPv6 socket address.
   329 *
   330 * Defines the address information inside the TInetAddr.
   331 *
   332 * @publishedAll
   333 * @released
   334 *
   335 * @sa SInetAddr
   336 * @since 7.0
   337 */
   338 	{
   339 	/** 16 bytes of IP6/IP4 address (128 bits) */
   340 	TIp6Addr iAddr;
   341 	/** 4 bytes of Flow Id */
   342 	TUint32 iFlow;
   343 	/**  4 bytes of Scope Id. */
   344 	TUint32 iScope;
   345 	};
   346 
   347 /**
   348 * @name IPv6 address constants..
   349 * @since 7.0
   350 */
   351 //@{
   352 /** Node-local scope level (RFC-2373 2.7). */
   353 const TInt KIp6AddrScopeNodeLocal = 0x01;
   354 /** Link-local scope level (RFC-2373 2.7). */
   355 const TInt KIp6AddrScopeLinkLocal = 0x02;
   356 /** Site-local scope level (RFC-2373 2.7). */
   357 const TInt KIp6AddrScopeSiteLocal = 0x05;
   358 /** Organisation-local scope level (RFC-2373 2.7). */
   359 const TInt KIp6AddrScopeOrganization = 0x08;
   360 /** Global scope level (RFC-2373 2.7). */
   361 const TInt KIp6AddrScopeGlobal = 0x0E;
   362 /** Network scope level (non-standard value, used internally) */
   363 const TInt KIp6AddrScopeNetwork = 0x10;
   364 
   365 /** No address (all 0s). */
   366 const TIp6Addr KInet6AddrNone = {{{0}}};
   367 /** Loopback address (::1). */
   368 const TIp6Addr KInet6AddrLoop = {{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}};
   369 /** Link-local address (prefix fe80::). */
   370 const TIp6Addr KInet6AddrLinkLocal = {{{0xfe, 0x80, }}};
   371 //@}
   372 
   373 class TInetAddr : public TSockAddr
   374 /**
   375 * This class specialises the generic socket server address class
   376 * TSockAddr for the TCP/IP protocol family. It represents an IP
   377 * address and stores either an IPv4 or an IPv6 address in its buffer
   378 * after the generic data defined by TSockAddr. The protocol family
   379 * field provided by the TSockAddr base class can be set to KAfInet,
   380 * KAfInet6 or KAFUnspec.
   381 *
   382 * The address family defines the format of the stored address:
   383 *
   384 * @li #KAfInet
   385 *	is for plain 32 bits IPv4 address presented as SInetAddr
   386 *	structure.
   387 * @li #KAfInet6
   388 *	is for both IPv4 and IPv6 addresses (IPv4 addresses
   389 *	are in IPv4 mapped format). The content is presented as
   390 *	SInet6Addr structure, which includes the scope id
   391 *	and flow label, in addition to the 128 address bits.
   392 * @li KAFUnspec
   393 *	does not contain any addresses and works in most
   394 *	contexts as unspecified address, This is better than
   395 *	placing explicit IPv4 "0.0.0.0" or IPv6 "::", which
   396 *	in certain situations may limit the connections to either
   397 *	IPv4 or IPv6, but not both.
   398 *
   399 * The flow label and scope id fields exist only in KAfInet6
   400 * format. However, the access functions TInetAddr::FlowLabel
   401 * and TInetAddr::Scope will also work for other address formats
   402 * by always returning 0.
   403 *
   404 * Any function which sets or changes the address bits, will
   405 * always reset the scope id and flow label to 0 (the
   406 * TInetAddr::Init is always called internally). These are
   407 * reasonable defaults, and normal application user does not
   408 * normally need to worry about flow label or scope id.
   409 *
   410 * When address is returned from the stack, it will often
   411 * be in KAfInet6 format, and may contain non-zero values
   412 * for flow label and scope id fields. When copying addresses,
   413 * the full TInetAddr (or at least SInet6Addr) should be
   414 * copied to preserve these fields.
   415 *
   416 * @publishedAll
   417 * @released
   418 * @since 7.0
   419 *	The IPv4 only portion is backward compatible with
   420 *	older versions. In 7.0s some functions have additional
   421 *	features.
   422 */
   423 	{
   424 public:
   425 	IMPORT_C TInetAddr();
   426 	IMPORT_C TInetAddr(const TSockAddr& aAddr);
   427 	IMPORT_C TInetAddr(TUint aPort);
   428 	IMPORT_C TInetAddr(const TIp6Addr &aAddr, TUint aPort);
   429 	IMPORT_C TInetAddr(TUint32 aAddr, TUint aPort);
   430 	IMPORT_C void SetAddress(TUint32 aAddr);
   431 	IMPORT_C void SetAddress(const TIp6Addr &aAddr);
   432 	IMPORT_C void SetV4CompatAddress(TUint32 aAddr);
   433 	IMPORT_C void SetV4MappedAddress(TUint32 aAddr);
   434 	IMPORT_C void SetFlowLabel(TInt aLabel);
   435 	IMPORT_C TInt FlowLabel() const;
   436 	IMPORT_C const TIp6Addr &Ip6Address() const;
   437 	IMPORT_C void ConvertToV4Compat();
   438 	IMPORT_C void ConvertToV4Mapped();
   439 	IMPORT_C void ConvertToV4();
   440 	IMPORT_C TBool CmpAddr(const TInetAddr& aAddr) const;
   441 	IMPORT_C TBool Match(const TInetAddr& aHost) const;
   442 	IMPORT_C TBool Match(const TInetAddr& aNet, const TInetAddr& aMask) const;
   443 	IMPORT_C TBool Match(const TInetAddr& aNet, TInt aPrefixLen) const;
   444 	IMPORT_C void PrefixMask(TInt aPrefixLen);
   445 	IMPORT_C void Prefix(const TInetAddr& aAddr, TInt aPrefixLen);
   446 	IMPORT_C void Output(TDes &aBuf) const;
   447 	IMPORT_C TInt Input(const TDesC &aBuf);
   448 	inline static TInetAddr& Cast(const TSockAddr& aAddr);
   449 	inline static TInetAddr& Cast(const TSockAddr* aAddr);
   450 	
   451 	IMPORT_C TBool IsUnicast() const;
   452 	IMPORT_C TBool IsMulticast() const;
   453 	IMPORT_C TBool IsLoopback() const;
   454 	IMPORT_C TBool IsUnspecified() const;
   455 	IMPORT_C TBool IsLinkLocal() const;
   456 	IMPORT_C TBool IsSiteLocal() const;
   457 	IMPORT_C TBool IsV4Compat() const;
   458 	IMPORT_C TBool IsV4Mapped() const;
   459 
   460 	IMPORT_C TUint32 Address() const;
   461 	IMPORT_C void NetMask(const TInetAddr& aAddr);
   462 	IMPORT_C void Net(const TInetAddr& aAddr);
   463 	IMPORT_C void NetBroadcast(const TInetAddr& aAddr);
   464 	IMPORT_C void SubNet(const TInetAddr& aAddr, const TInetAddr& aMask);
   465 	IMPORT_C void SubNetBroadcast(const TInetAddr& aAddr, const TInetAddr& aMask);
   466 
   467 	inline TBool IsClassA() const;
   468 	inline TBool IsClassB() const;
   469 	inline TBool IsClassC() const;
   470 	inline TBool IsBroadcast() const;
   471 	inline TBool IsWildAddr() const;
   472 	inline TBool IsWildPort() const;
   473 
   474 	IMPORT_C void SetScope(TUint32 aScope);
   475 	IMPORT_C TUint32 Scope() const;
   476 
   477 	IMPORT_C void Init(TUint aFamily);
   478 	IMPORT_C void OutputWithScope(TDes &aBuf) const;
   479 protected:
   480 	inline SInetAddr *Addr4Ptr() const;
   481 	inline SInet6Addr *AddrPtr() const;
   482 	inline static TInt AddrLen();
   483 private:
   484 	TInt Ipv4Input(const TDesC& aDes);
   485 	TInt Ipv6Input(const TDesC& aDes);
   486 	};
   487 
   488 inline SInet6Addr* TInetAddr::AddrPtr() const
   489 	/** Returns a pointer to #KAfInet6 content format. */
   490 	{ return (SInet6Addr*)UserPtr(); }
   491 
   492 inline TInt TInetAddr::AddrLen()
   493 	/** Returns the size of the #KAfInet6 content format. */
   494 	{ return sizeof(SInet6Addr); }
   495 
   496 inline TInetAddr& TInetAddr::Cast(const TSockAddr& aAddr)
   497 	/**
   498 	* Casts a TSockAddr to a TInetAddr reference.
   499 	*
   500 	* The cast is only safe if the object being referenced is actually aTInetAddr. 
   501 	*
   502 	* @param aAddr  TSockAddr to cast
   503 	* @return Casted reference to a TInetAddr. 
   504 	*/
   505 	{ return *((TInetAddr*)&aAddr); }
   506 
   507 inline TInetAddr& TInetAddr::Cast(const TSockAddr* aAddr)
   508 	/**
   509 	* Casts a TSockAddr to a TInetAddr reference.
   510 	*
   511 	* The cast is only safe if the object being referenced is actually aTInetAddr. 
   512 	*
   513 	* @param aAddr  TSockAddr to cast
   514 	* @return Casted pointer to a TInetAddr. 
   515 	*/
   516 	{ return *((TInetAddr*)aAddr); }
   517 
   518 inline SInetAddr* TInetAddr::Addr4Ptr() const
   519 	/** Returns a pointer to #KAfInet content format  */
   520 	{ return (SInetAddr*)UserPtr(); }
   521 
   522 inline TBool TInetAddr::IsBroadcast() const
   523 	/**
   524 	* Tests if the IP address is a limited broadcast address (255.255.255.255).
   525 	*
   526 	* @return ETrue if the IPv4 address value is a limited broadcast address; otherwise, EFalse
   527 	*/
   528 	{ return Address() == KInetAddrBroadcast; }
   529 
   530 inline TBool TInetAddr::IsWildPort() const
   531 	/**
   532 	* Tests if the port is zero.
   533 	*
   534 	* @return ETrue if the port is zero; otherwise, EFalse.
   535 	*/
   536 	{ return Port() == KInetPortNone; }
   537 
   538 inline TBool TInetAddr::IsWildAddr() const
   539 	/**
   540 	* Tests if the IP address is unspecified.
   541 	*
   542 	* This is same as IsUnspecified()
   543 	*
   544 	* @return ETrue if the IP address value is unspecified; otherwise, EFalse. 
   545 	*/
   546 	{ return IsUnspecified(); }
   547 
   548 inline TBool TInetAddr::IsClassA() const
   549 	/**
   550 	* Tests if the IP address is Class A.
   551 	*
   552 	* @return ETrue if the IPv4 address value is Class A; otherwise, EFalse
   553 	*
   554 	* @deprecated Works only for IPv4. It assumes the old IPv4 address classes
   555 	* (A, B, C). Applications using this function may not work properly in the
   556 	* current internet environment.
   557 	*/
   558 	{
   559 		return (Family() == KAfInet || IsV4Mapped() || IsV4Compat()) && (Address() & KInetAddrIdMaskA) == KInetAddrIdValA;
   560 	}
   561 
   562 inline TBool TInetAddr::IsClassB() const
   563 	/**
   564 	* Tests if the IP address is Class B.
   565 	*
   566 	* @return ETrue if the IPv4 address value is Class B; otherwise. EFalse
   567 	*
   568 	* @deprecated Works only for IPv4. It assumes the old IPv4 address classes
   569 	* (A, B, C). Applications using this function may not work properly in the
   570 	* current internet environment.
   571 	*/
   572 	{ return (Address() & KInetAddrIdMaskB) == KInetAddrIdValB; }
   573 
   574 inline TBool TInetAddr::IsClassC() const
   575 	/**
   576 	* Tests if the IP address is Class C.
   577 	*
   578 	* @return ETrue if the IPv4 address value is Class C; otherwise, EFalse
   579 	* @deprecated Works only for IPv4. It assumes the old IPv4 address classes
   580 	* (A, B, C). Applications using this function may not work properly in the
   581 	* current internet environment.
   582 	*/
   583 	{ return (Address() & KInetAddrIdMaskC) == KInetAddrIdValC; }
   584 
   585 /**
   586 * @name Send/Recv flags (datagram sockets only)
   587 */
   588 //@{
   589 /** Don't fragment the packet.
   590 *
   591 * If the packet would require fragmentation due to a small
   592 * maximum transmission unit size (MTU), the packet is dropped
   593 * and an ICMP error message is generated: for ICMPv4 type=3 and code=4
   594 * (#KInet4ICMP_Unreachable); and for ICMPv6 type=2 and code=0
   595 * (#KInet6ICMP_PacketTooBig).
   596 *
   597 * Application must enable #KSoInetLastError to detect this situation.
   598 */
   599 const TUint KIpDontFragment		= 0x010000;
   600 /**
   601 * Packet includes IP or IPv6 header.
   602 *
   603 * When reading, the returned buffer starts with the received
   604 * IP header, which can be either IPv6 (TInet6HeaderIP4) or
   605 * IPv4 (TInet6HeaderIP).
   606 *
   607 * When writing buffers, the buffer must start with the IP
   608 * header and it must be complete. The stack does not
   609 * provide any defaults.
   610 *
   611 * @sa	KSoRawMode, KSoHeaderIncluded
   612 */
   613 const TUint KIpHeaderIncluded	= 0x020000;
   614 /**
   615 * Don't route the packet.
   616 *
   617 * Not supported in Symbian 7.0 and 7.0s.
   618 */
   619 const TUint KIpDontRoute		= 0x040000;
   620 //@}
   621 
   622 
   623 /**
   624 * @name Interface control socket options
   625 *
   626 * Level: #KSolInetIfCtrl
   627 *
   628 * Enumerating & Configuring Interfaces using TSoInetInterfaceInfo and TSoInet6InterfaceInfo.
   629 */ 
   630 //@{
   631 /**
   632 * Begin enumeration of network interfaces. 
   633 * 
   634 * This option should be set before enumerating interfaces with #KSoInetNextInterface. 
   635 * 
   636 * This option is for use with RSocket::SetOpt() only.
   637 */
   638 const TInt KSoInetEnumInterfaces = 0x211;
   639 /**
   640 * Return details of the next interface in an enumeration started by setting the 
   641 * option #KSoInetEnumInterfaces.
   642 *
   643 * This option is for use with RSocket::GetOpt() only.
   644 * 
   645 * Option data type is TSoInetInterfaceInfo.
   646 *
   647 * @note
   648 *	If the interface has multiple addresses, then each address
   649 *	is returned as a separate instance of TSoInetInterfaceInfo
   650 *	(only address information is different each time).
   651 * @note
   652 *	If the interface has no addresses, then one entry
   653 *	with unspecified address is returned.
   654 */
   655 const TInt KSoInetNextInterface = 0x212;
   656 
   657 /**
   658 * Configures the interface.
   659 * 
   660 * This option is for use with RSocket::SetOpt() only.
   661 *
   662 * Option data type is TSoInet6InterfaceInfo.
   663 * 
   664 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
   665 * @since 7.0
   666 *
   667 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
   668 * @ref RSocket::SetOpt()
   669 */
   670 const TInt KSoInetConfigInterface = 0x213;
   671 /**
   672 * Deletes the interface.
   673 * 
   674 * This option is for use with RSocket::SetOpt() only.
   675 *
   676 * Option data type is TSoInet6InterfaceInfo.
   677 * 
   678 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
   679 * @since 7.0
   680 *
   681 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
   682 * @ref RSocket::SetOpt()
   683 */
   684 const TUint KSoInetDeleteInterface = 0x214;
   685 /**
   686 * Configure the interface details, if it exists.
   687 * 
   688 * Option data type is TSoInet6InterfaceInfo.
   689 * 
   690 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
   691 *
   692 * @note
   693 *	Unlike KSoInetConfigInterface, never creates a new interface
   694 *	entry, if one does not already exist. KSoInetConfigInterface
   695 *	never fails with interface not found, as it always finds or
   696 *	creates one.
   697 * @since 7.0
   698 *
   699 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
   700 * @ref RSocket::SetOpt()
   701 */
   702 const TUint KSoInetChangeInterface = 0x215;
   703 /**
   704 * Resets interface to initial state.
   705 *
   706 * Delete all configuration (routes and addresses) from the
   707 * interface. Any sockets (flows) currently using this interface,
   708 * are set to holding state (#KSoNoInterfaceError is not required).
   709 *
   710 * The interface reconfigures, if the NIF driver
   711 * calls CProtocolBase::StartSending(), or if
   712 * #KSoInetStartInterface socket option is used.
   713 *
   714 * Option data type is TSoInet6InterfaceInfo.
   715 * 
   716 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
   717 * No other fields are used.
   718 * @since 7.0s
   719 *
   720 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
   721 * @ref RSocket::SetOpt()
   722 */
   723 const TUint KSoInetResetInterface = 0x216;
   724 /**
   725 * Restart interface, auto-reconfigure.
   726 *
   727 * Option data type is TSoInet6InterfaceInfo.
   728 * 
   729 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
   730 * No other fields are used. The selected interface is autoconfigured using the
   731 * information supplied by the attached network driver.
   732 *
   733 * Should normally only be called after #KSoInetResetInterface.
   734 * @since 7.0
   735 *
   736 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
   737 * @ref RSocket::SetOpt()
   738 */
   739 const TUint KSoInetStartInterface = 0x217;
   740 
   741 /**
   742 * Trigger link local creation.
   743 *
   744 * Option data type is TSoInet6InterfaceInfo.
   745 * 
   746 * The interface is specified by setting the TSoInetInterfaceInfo::iName and any state
   747 * change required. Called by a configuration deamon to trigger IPv4 zeroconf and link
   748 * local creation if no address server is found.  Does nothing if
   749 * EV4LLConfigDaemonControlled option is not specified for interface.
   750 *
   751 * @since 9.2
   752 *
   753 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
   754 * @ref RSocket::SetOpt()
   755 */
   756 const TUint KSoInetCreateIPv4LLOnInterface = 0x226;
   757 
   758 /**
   759 * Describes the state of an interface. 
   760 * 
   761 * It is used as a data member of TSoInetInterfaceInfo.
   762 *
   763 * @note
   764 *	This enumeration is supported only because of backward
   765 *	compatibility. The real interface state uses the system
   766 *	error codes directly. The interface is either up
   767 *	(KErrNone) or down because of some error condition (state
   768 *	is one of the system wide error codes indicating the reason
   769 *	for the down state).
   770 *
   771 * @publishedAll
   772 * @released
   773 */
   774 enum TIfStatus
   775 	{
   776 	/** The interface has been initiated, but is not yet available. */
   777 	EIfPending,
   778 	/** The interface is up and available. */
   779 	EIfUp,
   780 	/** The interface is up, but flowed off. */
   781 	EIfBusy,
   782 	/** The interface is down. */
   783 	EIfDown
   784 #ifdef SYMBIAN_TCPIPDHCP_UPDATE
   785 	,
   786     /** The interface is not-configured */
   787     EIfNotConfigured
   788 #endif //SYMBIAN_TCPIPDHCP_UPDATE
   789 	};
   790 
   791 class TSoInetInterfaceInfo
   792 /**
   793 * Used when listing interfaces with socket option.
   794 *
   795 * Used with interface level #KSolInetIfCtrl option #KSoInetNextInterface.
   796 *
   797 * This is also a base class for the TSoInet6InterfaceInfo,
   798 * which is used in modifying the interface configuration.
   799 *
   800 * @publishedAll
   801 * @released
   802 */
   803 	{
   804 public:
   805 	/** Ignored since 7.0. @removed The field exists, but it is ignored. */
   806 	TName iTag;
   807 	/** Interface name */
   808 	TName iName;
   809 	/** Interface state. */
   810 	TIfStatus iState;
   811 	/** Maximum transmission unit (bytes) */
   812 	TInt iMtu;
   813 	/** An approximation of the interface speed in Kbps. */
   814 	TInt iSpeedMetric;
   815 	/**
   816 	* Feature flags. 
   817 	* 
   818 	* Possible values are defined in in_iface.h.
   819 	*/
   820 	TUint iFeatures;
   821 	/** Hardware address. */
   822 	TSockAddr iHwAddr;
   823 	/** Interface IP address. */
   824 	TInetAddr iAddress;
   825 	/** IP netmask. */
   826 	TInetAddr iNetMask;
   827 	/** IP broadcast address. */
   828 	TInetAddr iBrdAddr;
   829 	/** IP default gateway or peer address (if known). */
   830 	TInetAddr iDefGate;
   831 	/** IP primary name server (if any). */
   832 	TInetAddr iNameSer1;
   833 	/** IP secondary name server (if any). */
   834 	TInetAddr iNameSer2;
   835 	};
   836 
   837 class TSoInet6InterfaceInfo : public TSoInetInterfaceInfo
   838 /**
   839 * Extension for TSoInetInterfaceInfo. Available in Symbian OS v7.0 and later.
   840 *
   841 * Used with the following interface level #KSolInetIfCtrl options:
   842 * @li	#KSoInetConfigInterface
   843 * @li	#KSoInetDeleteInterface
   844 * @li	#KSoInetChangeInterface
   845 * @li	#KSoInetResetInterface
   846 * @li	#KSoInetStartInterface
   847 * @li	#KSoInetCreateIPv4LLOnInterface
   848 *
   849 * The following configuration changes are only activated with
   850 * #KSoInetConfigInterface and #KSoInetChangeInterface options.
   851 * For these two, the extension specifies the details of actions
   852 * to be performed. The extension is a collection of control bits,
   853 * which can be grouped as
   854 *
   855 * @li modifiers (#iDelete and #iAlias)
   856 * @li actions: #iDoState, #iDoId (with subactions #iDoAnycast or #iDoProxy) and #iDoPrefix.
   857 *
   858 * The effect of the modifiers depend on the chosen action (in some
   859 * actions modifiers are ignored).
   860 * The iDoState can be combined with any other actions, but for the
   861 * remaining only the following combinations are valid:
   862 *
   863 * @li
   864 *	no address configuration: iDoId=0, iDoPrefix=0 (iDoProxy,
   865 *	iDoAnycast, iDelete and iAlias are ignored).
   866 * @li
   867 *	configure single IPv6 or IPv4 address:
   868 *	iDoid, iAddress has the address, iNetMask unspecified.
   869 * @li
   870 *	configure IPv6 id part: iDoId, iAddress is IPv6 address
   871 *	(<tt>fe80::id</tt>) and iNetMask defined (for 64 bits, use
   872 *	<tt>ffff:ffff:ffff:ffff::</tt>).
   873 * @li
   874 *	configure IPv4 address and netmask:	iDoId, iNetMask defined.
   875 * @li
   876 *	configure IPv6 or IPv4 anycast address: iDoId, iDoAnycast,
   877 *	iAddress has the address (iNetMask ignored).
   878 * @li
   879 *	configure IPv6 or IPv4 proxy address: iDoId, iDoProxy,
   880 *	iAddress has the address (iNetMask ignored).
   881 * @li
   882 *	configure IPv6 prefix and id part: iDoId, iDoPrefix,
   883 *	iAddress is the IPv6 address (prefix::id) and iNetMask defined
   884 *	(for 64 bits, use <tt>ffff:ffff:ffff:ffff::</tt>).
   885 * @li
   886 *	configure IPv6 prefix: iDoPrefix, iAddress is the prefix (prefix::)
   887 *	and iNetMask defined (for 64 bits, use <tt>ffff:ffff:ffff:ffff::</tt>).
   888 *
   889 * The default route is processed if #iDefGate is specified.
   890 * If the gateway address is an IPv4 address, then it defines IPv4
   891 * default route. Additionally, if the iDefGate is same as iAddress, then
   892 * this is interpreted as a request to treat the default route as
   893 * "onlink route" instead of the normal <em>gateway route</em>. #iDelete modifier
   894 * controls whether default route is added or deleted.
   895 *
   896 * The MTU is updated, if #iMtu has non-zero value.
   897 *
   898 * Available in Symbian OS v9.2 and later.
   899 *
   900 * Used with the following interface level #KSolInetIfCtrl option:
   901 * @li	#KSoInetCreateIPv4LLOnInterface
   902 *
   903 * @li actions: #iDoState.
   904 *
   905 * This configuration acts as a notification from a config daemon to the IP stack
   906 * which controls link local behaviour if the llv4linklocal=ELLV4ConfigDeamonControlled
   907 * TCPIP.ini option is specified for the interface:
   908 *
   909 * @li
   910 *	notification from config daemon (e.g., DHCP) that address assignment terminated
   911 *   so a link local should be created if appropriate TCPIP.ini setting is used:
   912 *	iDoState.
   913 *
   914 * @publishedAll
   915 * @released
   916 * @since 7.0 (some functionality only in 7.0s and >=9.3 for config daemon controlled link local creation)
   917 */
   918 	{
   919 public:
   920 	/**
   921 	* Add or delete modifier.
   922 	* 
   923 	* 0 = add, 1 = delete
   924 	*
   925 	* Modifies the actions for address configuration (#iDoId, #iDoPrefix)
   926 	* and iDefGate processing (see detail descripton above).
   927 	*/
   928 	TUint iDelete:1;
   929 	/**
   930 	* Primary or alias modifier.
   931 	* 
   932 	* 0 = primary, 1 = alias.
   933 	*
   934 	* @note
   935 	*	Always use 1 here (this is a relic, that most likely
   936 	*	should be deprecated, and defaulted to 1 always).
   937 	*/
   938 	TUint iAlias:1;
   939 	/**
   940 	* Prefix action (only for IPv6 addresses).
   941 	* 
   942 	* 0 = don't do prefix, 1 = do the prefix.
   943 	*
   944 	* #iAddress must be specified.
   945 	*
   946 	* If set and iNetMask is defined, then #iNetMask and #iAddress
   947 	* define a prefix for the interface (link). If iNetMask is
   948 	* unspecified, then the iDoPrefix is ignored.
   949 	*
   950 	* @li iDelete=0: 
   951 	*	Acts as if an IPv6 Router Advertisement with prefix option A=1
   952 	*	and L=1 has arrived (e.g. this prefix can be used in address
   953 	*	generation and all addresses with this prefix are onlink on
   954 	*	this interface).
   955 	*
   956 	* @li iDelete=1:
   957 	*	The specified prefix is deleted from the interface (if it
   958 	*	existed before).
   959 	*
   960 	* @note
   961 	*	Current IPv6 specification allows only 64 for the number
   962 	*	of prefix bits.
   963 	*/
   964 	TUint iDoPrefix:1;
   965 	/**
   966 	* Address action.
   967 	* 
   968 	* 0 = don't do address, 1= do the address.
   969 	*
   970 	* #iAddress must be specified.
   971 	*
   972 	* @note
   973 	*	If also either #iDoAnycast or #iDoProxy is set, then
   974 	*	the action is special for them (and the following
   975 	*	does not apply).
   976 	*
   977 	* If #iNetMask is unspecified, then #iAddress defines a single
   978 	* address (either IPv4 or IPv6) which is to be added or removed,
   979 	* depending on the state of the #iDelete modifier. #iAlias
   980 	* is ignored.
   981 	*
   982 	* If #iNetMask is specified, then the following applies:
   983 	*
   984 	* @li iDelete=0 and iAddress is IPv4 address:
   985 	*	iAddress and iNetMask are used to configure additional
   986 	*	IPv4 address and netmask for the interface.
   987 	* @li iDelete=0 and iAddress is IPv6 address
   988 	*	The iNetmask and iAddress define a ID part, which can be
   989 	*	combined with any defined prefix to form a full IPv6 address.
   990 	*	If iAlias is set, then a new ID is added; otherwise whatever
   991 	*	happens to be stored in the primary id slot is overwritten
   992 	*	(always use iAlias=1 to avoid confusion).
   993 	*
   994 	* @li iDelete=1:
   995 	*	The previously configured address or ID is deleted.
   996 	*
   997 	* @note
   998 	*	The IPv4 netmask alone cannot be added or deleted. Use #KSolInetRtCtrl
   999 	*	options.
  1000 	*/
  1001 	TUint iDoId:1;
  1002 	/**
  1003 	* Interface state action.
  1004 	* 
  1005 	* 0 = ignore TSoInetInterfaceInfo::iState,
  1006 	*
  1007 	* 1 = set interface state based on
  1008 	* TSoInetInterfaceInfo::iState as follows:
  1009 	* @li EIfDown:
  1010 	*	The interface state is set to KErrNotReady.
  1011 	* @li EIfUp:
  1012 	*	The interface state is set to 0 (KErrNone).
  1013 	* @li
  1014 	*	Attempt to set any other state results failed operation
  1015 	*	with KErrArgument result.
  1016 	*/
  1017 	TUint iDoState:1;
  1018 	/**
  1019 	* Configure address as Anycast.
  1020 	*
  1021 	* The anycast address is defined by #iAddress.
  1022 	*
  1023 	* Anycast address is recognized as own address for incoming
  1024 	* packets, but it cannot be used as a source address for
  1025 	* outgoing packets. IPv6 DAD (or IPv4 ARP duplicate address)
  1026 	* test is not done for anycast addresses. Anycast address is
  1027 	* advertised on the link as an address of this host.
  1028 	*
  1029 	* 1 = configure anycast (#iDoId must also be set, #iDoPrefix is ignored)
  1030 	*
  1031 	* @li iDelete=0:
  1032 	*	Add anycast address.
  1033 	* @li iDelete=1:
  1034 	*	Remove the previously configured anycast address.
  1035 	*
  1036 	* @since 7.0s
  1037 	*/
  1038 	TUint iDoAnycast:1;
  1039 	/**
  1040 	* Confiture address as Proxy.
  1041 	*
  1042 	* The proxy address is defined by #iAddress.
  1043 	*
  1044 	* Proxy address is not recognized as own address for incoming
  1045 	* packets (nor can it be used as own address for outgoing packets).
  1046 	* IPv6 DAD (or IPv4 ARP duplicate address) test is performed for
  1047 	* proxy address. Proxy address is advertised on the link as an
  1048 	* address of this host.
  1049 	*
  1050 	* 1 = configure proxy (#iDoId must also be set, #iDoPrefix is ignored)
  1051 	*
  1052 	* @li iDelete=0:
  1053 	*	Add proxy address.
  1054 	* @li iDelete=1:
  1055 	*	Remove the previously configured proxy address.
  1056 	*
  1057 	* @since 7.0s
  1058 	*/
  1059 	TUint iDoProxy:1;
  1060 	};
  1061 //@}
  1062 
  1063 /**
  1064 * @name Interface query socket options
  1065 *
  1066 * Level: #KSolInetIfQuery
  1067 *
  1068 * Querying information about interfaces using TSoInetIfQuery.
  1069 *
  1070 * @since 7.0 (some additions in 7.0s)
  1071 */
  1072 //@{
  1073 /** Scope Id vector (member of TSoInetIfQuery). @since 7.0s */
  1074 typedef TUint32 TInetScopeIds[16];
  1075 
  1076 class TSoInetIfQuery
  1077 /**
  1078 * Interface query.
  1079 *
  1080 * Used with interface query options:
  1081 * @li	#KSoInetIfQueryByDstAddr
  1082 * @li	#KSoInetIfQueryBySrcAddr
  1083 * @li	#KSoInetIfQueryByIndex
  1084 * @li	#KSoInetIfQueryByName
  1085 *
  1086 * Only GetOption for KSolInetIfQuery is supported. It returns
  1087 * information about the selected interface. The option name
  1088 * determines the input field in the TSoInetIfQuery, which is
  1089 * used as a key for locating the interface.
  1090 *
  1091 * Returns, KErrNotFound, if interface is not found
  1092 *
  1093 * Returns, KErrNone, if interface is located, and fills
  1094 * fields from the interface with following logic
  1095 *
  1096 * @li	iDstAddr: not touched, left as is
  1097 * @li	iSrcAddr is result of the Select Source Address algorithm
  1098 *	    for the interface using the iDstAddr as input. If there
  1099 *		is no valid source address, the value will be KAFUnspec.
  1100 * @li	iIndex is loaded with the interface index of the interface
  1101 * @li	iName is loaded from the name of the interface
  1102 * @li	iIsUp is set 1, if interface has CNifIfBase pointer attached,
  1103 *		and 0 otherwise.
  1104 *
  1105 * For example, if QueryByDstAddr for specified destination address
  1106 * results iIsUp == 1, then there is an interface and route for that
  1107 * destination. iIsUp == 0, means that trying to connect to the address
  1108 * will most likely activate a netdial/interface link startup phase.
  1109 *
  1110 * @publishedAll
  1111 * @released
  1112 */
  1113 	{
  1114 public:
  1115 	/**
  1116 	* Destination address.
  1117 	* @li input:
  1118 	*	If the option is #KSoInetIfQueryByDstAddr, select
  1119 	*	interface by finding a route for this address;
  1120 	*	otherwise, ignored.
  1121 	* @li output: not changed.
  1122 	*
  1123 	* @note
  1124 	*	On returning interface information, regardless of
  1125 	*	the option used, the content of this is used to select
  1126 	*	a matching source address (#iSrcAddr).
  1127 	*/
  1128 	TInetAddr iDstAddr;
  1129 	/**
  1130 	* Source address.
  1131 	* @li input:
  1132 	*	If the option is #KSoInetIfQueryBySrcAddr, select
  1133 	*	interface by source address; otherwise, ignored.
  1134 	* @li output:
  1135 	*	The result of the source address
  1136 	*	selection algorithm based on the content of the
  1137 	*	#iDstAddr.
  1138 	*/
  1139 	TInetAddr iSrcAddr;
  1140 	/**
  1141 	* Interface Index. 
  1142 	*
  1143 	* @li input:
  1144 	*	If the option is #KSoInetIfQueryByIndex, select
  1145 	*	interface by this interface index; otherwise,
  1146 	*	ignored.
  1147 	* @li output:
  1148 	*	The interface index the located interface.
  1149 	*	(always same as iZone[0] in 7.0s).
  1150 	*/
  1151 	TUint32 iIndex;
  1152 	/** Interface name.
  1153 	* @li input:
  1154 	*	If the option is #KSoInetIfQueryByName, select
  1155 	*	interface by this name; otherwise, ignored.
  1156 	* @li output:
  1157 	*	The name of the located interface.
  1158 	*/
  1159 	TName iName;
  1160 	/**
  1161 	* Flag that is set to 1 if the network interface is attached.
  1162 	* @li input: ignored
  1163 	* @li output: set as indicated.
  1164 	*/
  1165 	TUint iIsUp:1;
  1166 	/**
  1167 	* Scope Id Vector (iZone[0] = Interface Index, iZone[1] = IAP ID, iZone[15] = Network ID).
  1168 	* @li input: ignored
  1169 	* @li output: The scope id vector
  1170 	* @since 7.0s
  1171 	*/
  1172 	TInetScopeIds iZone;
  1173 	};
  1174 /**
  1175 * Get information for the interface specified by the destination address (iDstAddr) 
  1176 * field of the passed packaged TSoInetIfQuery.
  1177 * 
  1178 * This allows the caller to find out what interface would be used (without invoking 
  1179 * a dial-up process) for the specified destination. A path for this destination 
  1180 * is open, if GetOpt() returns KErrNone, iSrcAddr is not KAFUnspec, and iIsUp 
  1181 * == 1.
  1182 */
  1183 const TUint KSoInetIfQueryByDstAddr	= 0x1;
  1184 /**
  1185 * Get information for the interface specified by the source address (iSrcAddr) 
  1186 * field of the passed packaged TSoInetIfQuery.
  1187 *
  1188 * If there are multiple interfaces with the same source address, then the first 
  1189 * matching interface is returned. 
  1190 * 
  1191 * @note
  1192 *	The information return phase will overwrite the iSrcAddr based on
  1193 *	whatever happens to be in iDstAddr. It is not necessary to initialize
  1194 *	iDstAddr, if application is not interested in resulting iSrcAddr.
  1195 */
  1196 const TUint KSoInetIfQueryBySrcAddr	= 0x2;
  1197 /**
  1198 * Get information for the interface specified by the Interface Index (iIndex) 
  1199 * field of the passed packaged TSoInetIfQuery.
  1200 */
  1201 const TUint KSoInetIfQueryByIndex	= 0x3;
  1202 /**
  1203 * Get information for the interface specified by the Interface Name (iName) field 
  1204 * of the passed packaged TSoInetIfQuery.
  1205 */
  1206 const TUint KSoInetIfQueryByName	= 0x4;
  1207 
  1208 //@}
  1209 
  1210 /**
  1211 * @name	Route control socket options
  1212 *
  1213 * Level: #KSolInetRtCtrl
  1214 *
  1215 * Enumerating & Configuring Routes using TSoInetRouteInfo.
  1216 */
  1217 //@{
  1218 /**
  1219 * Begin enumeration of routes. 
  1220 *
  1221 * This option can only be used with RSocket::SetOpt().
  1222 * 
  1223 * This option should be set before enumerating routes with #KSoInetNextRoute.
  1224 *
  1225 * @capability NetworkServices
  1226 */
  1227 const TInt KSoInetEnumRoutes  = 0x221;
  1228 /**
  1229 * Return the next route in an enumeration started by setting the option #KSoInetEnumRoutes.
  1230 * 
  1231 * Option data type is TSoInetRouteInfo.
  1232 * 
  1233 * This option can only be used with RSocket::GetOpt().
  1234 *
  1235 * @capability NetworkServices
  1236 */
  1237 const TInt KSoInetNextRoute	  = 0x222;
  1238 /**
  1239 * Adds the specified route to the routing table.
  1240 * 
  1241 * Option data type is TSoInetRouteInfo.
  1242 * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist.
  1243 * 
  1244 * This option can only be used with RSocket::SetOpt().
  1245 *
  1246 * @capability NetworkControl Modifying routes is allowed for authorized apps only.
  1247 * @ref RSocket::SetOpt()
  1248 */
  1249 const TInt KSoInetAddRoute	  = 0x223;
  1250 /**
  1251 * Deletes the specified route from the routing table.
  1252 * 
  1253 * The route is identified by destination, netmask and gateway,
  1254 * These must exactly match the old route to be deleted.
  1255 *
  1256 * Option data type is TSoInetRouteInfo.
  1257 * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist.
  1258 * 
  1259 * This option can only be used with RSocket::SetOpt().
  1260 *
  1261 * @capability NetworkControl Modifying routes is allowed for authorized apps only.
  1262 * @ref RSocket::SetOpt()
  1263 */
  1264 const TInt KSoInetDeleteRoute = 0x224;
  1265 /**
  1266 * Modifies the specified route in the routing table. 
  1267 * 
  1268 * The destination, netmask and gateway settings must be the same
  1269 * in the new route as in the old.
  1270 * 
  1271 * Option data type is TSoInetRouteInfo.
  1272 * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist.
  1273 * 
  1274 * This option can only be used with RSocket::SetOpt().
  1275 *
  1276 * @capability NetworkControl Modifying routes is allowed for authorized apps only.
  1277 * @ref RSocket::SetOpt()
  1278 */
  1279 const TInt KSoInetChangeRoute = 0x225;
  1280 
  1281 /**
  1282 * Identifies the state of a route held in an entry in the IP routing table. 
  1283 * 
  1284 * It is used as a data member of TSoInetRouteInfo.
  1285 *
  1286 * @note
  1287 *	This enumeration is present only because of backward
  1288 *	compatibility. Only two values are used.
  1289 *
  1290 * @since 7.0 (in this form)
  1291 *
  1292 * @publishedAll
  1293 * @released
  1294 */
  1295 enum TRouteState
  1296 	{
  1297 	/** Unused. */
  1298 	ERtNone,
  1299 	/** Route is neighbour cache entry, ARP or Neighbor discovery is in progress. */
  1300 	ERtPending,
  1301 	/** Unused */
  1302 	ERtBusy,
  1303 	/** The interface for the route is up and ready. */
  1304 	ERtReady,
  1305 	/** Unused */
  1306 	ERtDown
  1307 	};
  1308 
  1309 /**
  1310 * Identifies the type of creator of an entry in the IP routing table. 
  1311 * 
  1312 * It is used as a data member of TSoInetRouteInfo.
  1313 *
  1314 * @note
  1315 *	This enumeration is present only because of backward
  1316 *	compatibility. Only two values are used.
  1317 *
  1318 * @since 7.0 (in this form)
  1319 *
  1320 * @publishedAll
  1321 * @released
  1322 */
  1323 enum TRouteType
  1324 	{
  1325 	/** Normal route entry */
  1326 	ERtNormal,
  1327 	/** Unused */
  1328 	ERtUser,
  1329 	/** Route is ARP or neighbor cache entry */
  1330 	ERtIcmpAdd,
  1331 	/** Unused */
  1332 	ERtIcmpDel
  1333 	};
  1334 
  1335 class TLinkAddr : public TSockAddr
  1336 	/**
  1337 	* TLinkAddr
  1338 	*
  1339 	* Link layer address utility.
  1340 	*
  1341 	* Lightweight helper class for handling link layer addresses.
  1342 	*
  1343 	* This class is mainly used to obtain direct access to the raw address
  1344 	* bytes which are inacessible from the TSockAddr interface.
  1345 	*
  1346 	* A link layer address is a binary string of octets.
  1347 	*
  1348 	* The address family of the TLinkAddr is determined by the interface. If
  1349 	* the interface uses link layer addresses, it must support the
  1350 	* #KSoIfHardwareAddr control option, and the returned address family of the
  1351 	* harware address is supposed to represent the family of all link layer addresses
  1352 	* of peers on the interface.
  1353 	*
  1354 	* Link layer addresses can be obtained from e.g. TSoInetRouteInfo structures
  1355 	* using the TSoInetRouteInfo::GetLinkAddr function.  Note: this may fail if the
  1356 	* link layer address of the peer corresponding to the route is not known.
  1357 	*
  1358 	* @publishedAll
  1359 	* @released
  1360 	*/
  1361 	{
  1362 public:
  1363 	IMPORT_C TLinkAddr();
  1364 	IMPORT_C void SetAddress(const TDesC8 &aAddr);
  1365 
  1366 	IMPORT_C TPtrC8 Address() const;
  1367 
  1368 	IMPORT_C const static TLinkAddr& Cast(const TSockAddr& aAddr);
  1369 	IMPORT_C static TLinkAddr& Cast(TSockAddr& aAddr);
  1370 	IMPORT_C const static TLinkAddr* Cast(const TSockAddr* aAddr);
  1371 	IMPORT_C static TLinkAddr* Cast(TSockAddr* aAddr);
  1372 
  1373 	};
  1374 
  1375 class TSoInetRouteInfo
  1376 /**
  1377 * Route information structure.
  1378 *
  1379 * Used with route options:
  1380 *
  1381 * @li	#KSoInetNextRoute
  1382 * @li	#KSoInetAddRoute
  1383 * @li	#KSoInetDeleteRoute
  1384 *
  1385 * IPv4 addresses are returned as IPv4-mapped IPv6 addresses
  1386 * qualified with appropriate scope id (Symbian OS 7.0 and later).
  1387 *
  1388 * @publishedAll
  1389 * @released
  1390 */
  1391 	{
  1392 public:
  1393 	IMPORT_C TInt GetLinkAddr( TLinkAddr &aInfo ) const;
  1394 
  1395 	/** Route type. */
  1396 	TRouteType iType;
  1397 	/** Route state. */
  1398 	TRouteState iState;
  1399 	/** Route preference, with a smaller value indicating a preferred route. */
  1400 	TInt iMetric;
  1401 	/** IP address of the interface used for this route. */
  1402 	TInetAddr iIfAddr;
  1403 	/** IP address of the gateway, or link-layer address for neighbour cache entries */
  1404 	TInetAddr iGateway;
  1405 	/** IP address of the destination network or host. */
  1406 	TInetAddr iDstAddr;
  1407 	/** Destination mask of network. */
  1408 	TInetAddr iNetMask;
  1409 	};
  1410 
  1411 class TSoInetCachedRouteInfo : public TSoInetRouteInfo
  1412 /**
  1413 * Access to route cache TPckgBuf<TSoInetCachedRouteInfo>, set iDstAddr for required address
  1414 * With a level of KSolInetRtCtrl. This API is no longer suported.
  1415 *
  1416 * @removed
  1417 * @since 7.0
  1418 */
  1419 	{
  1420 public:
  1421 	/** Unused */
  1422 	TInt iPathMtu;
  1423 	/** Unused */
  1424 	TUint iPathRtt;
  1425 	};
  1426 
  1427 /** No longer supported. @removed. @since 7.0 */
  1428 const TInt KSoInetCachedRouteByDest = 0x225;
  1429 
  1430 //@}
  1431 
  1432 
  1433 /**
  1434 * @name	DNS definitions
  1435 */
  1436 //@{
  1437 /**
  1438 * Flags returned from DNS records.
  1439 *
  1440 * Provides flag bitmasks that are used to describe properties of results of DNS 
  1441 * queries via RHostResolver.
  1442 * @publishedAll
  1443 * @released
  1444 */
  1445 enum TNameRecordFlags
  1446 	{
  1447 	/** Name is an Alias. */
  1448 	EDnsAlias=0x00000001,
  1449 	/** Answer is authoritive. */
  1450 	EDnsAuthoritive=0x00000002,
  1451 	/** Answer is from hosts file. */
  1452 	EDnsHostsFile=0x00000004,
  1453 	/** Answer is from a DNS server. */
  1454 	EDnsServer=0x00000008,
  1455 	/** Answer is host name for this host. */
  1456 	EDnsHostName=0x00000010,
  1457 	/** Answer is from the resolver cache. */
  1458 	EDnsCache=0x00000020,
  1459 	/** Answer does not have a route set */
  1460 	EDnsNoRoute=0x00000040
  1461 	};
  1462 
  1463 /** No longer supported.
  1464 * @removed
  1465 * @since 7.0 */
  1466 const TUint KSoDnsCacheEnable = 0x600;
  1467 /** No longer supported.
  1468 * @removed
  1469 * @since 7.0 */
  1470 const TUint KSoDnsCacheFlush = 0x601;
  1471 #ifdef SYMBIAN_DNS_PUNYCODE
  1472 /** Enable International Domain Name support 
  1473  * @publishedAll
  1474  * @released
  1475  */
  1476 const TUint KSoDnsEnableIdn = 0x602;
  1477 #endif //SYMBIAN_DNS_PUNYCODE
  1478 //@}
  1479 
  1480 /**
  1481 * @name TCP socket options
  1482 *
  1483 * Level: #KSolInetTcp
  1484 */
  1485 //@{
  1486 /**
  1487 * Complete the ioctl request when the data has been sent.
  1488 */
  1489 const TUint KIoctlTcpNotifyDataSent = 0x300;
  1490 
  1491 /**
  1492 * The maximum number of bytes that can be queued for sending. 
  1493 * 
  1494 * If this option is set when the connection state is not closed,
  1495 * then KErrLocked is returned.
  1496 * 
  1497 * Option data type is TInt.
  1498 * 
  1499 * The default value is 8192.
  1500 */
  1501 const TUint KSoTcpSendWinSize = 0x301;
  1502 /**
  1503 * The maximum number of bytes that can be buffered for receiving. 
  1504 * 
  1505 * If this option is set when the connection state is not closed,
  1506 * then KErrLocked is returned.
  1507 * 
  1508 * Option data type is TInt.
  1509 * 
  1510 * The default value is 8192.
  1511 */
  1512 const TUint KSoTcpRecvWinSize = 0x302;
  1513 /**
  1514 * The maximum TCP segment size (bytes). 
  1515 * 
  1516 * If this option is set when the connection state is not closed,
  1517 * then KErrLocked is returned.
  1518 *
  1519 * Option data type is TInt.
  1520 *
  1521 * The default value is 1460.
  1522 */
  1523 const TUint KSoTcpMaxSegSize = 0x303;
  1524 /**
  1525 * Send data at once if there is an established connection, without
  1526 * waiting for the maximum segment size to be reached. 
  1527 * 
  1528 * The default is disabled.
  1529 * 
  1530 * Option data type is TInt.
  1531 * 
  1532 * Values are: 0 = Disable, 1 = Enable.
  1533 */
  1534 const TUint KSoTcpNoDelay = 0x304;
  1535 /**
  1536 * On the time-out expiring without an acknowledgement being received,
  1537 * send a packet designed to force a response if the peer is up and reachable.
  1538 *
  1539 * The default is disabled.
  1540 * 
  1541 * Option data type is TInt.
  1542 * 
  1543 * Values are: 0 = Disable, 1 = Enable.
  1544 */
  1545 const TUint KSoTcpKeepAlive = 0x305;
  1546 /**
  1547 * If address reuse is allowed, and a connection already exists between
  1548 * the requested local and remote addresses, wait for the address to
  1549 * become available.
  1550 * 
  1551 * The default is disabled.
  1552 * 
  1553 * Option data type is TInt.
  1554 * 
  1555 * Values are: 0 = Disable, 1 = Enable.
  1556 * @removed
  1557 */
  1558 const TUint KSoTcpAsync2MslWait = 0x306;
  1559 /**
  1560 * The number of bytes currently queued for sending.
  1561 * 
  1562 * Option data type is TInt.
  1563 * 
  1564 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
  1565 */
  1566 const TUint KSoTcpSendBytesPending = 0x307;
  1567 /**
  1568 * The number of bytes currently available for reading (the same value as
  1569 * is obtained using KSOReadBytesPending).
  1570 * 
  1571 * Option data type is TInt.
  1572 * 
  1573 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
  1574 */
  1575 const TUint KSoTcpReadBytesPending = 0x308;
  1576 /**
  1577 * The socket has been set to listen (through RSocket::Listen()).
  1578 * 
  1579 * Option data type is TInt.
  1580 * 
  1581 * Values are: 0. Not listening, 1. Listening
  1582 * 
  1583 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
  1584 */
  1585 const TUint KSoTcpListening = 0x309;
  1586 /**
  1587 * The number of current TCP sockets.
  1588 * 
  1589 * Option data type is TInt.
  1590 * 
  1591 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
  1592 */
  1593 const TUint KSoTcpNumSockets = 0x310;
  1594 /**
  1595 * Read out-of-band urgent data.
  1596 * 
  1597 * KErrNotFound is returned if there is no data waiting and no
  1598 * urgent data pointer has been received.
  1599 * 
  1600 * KErrWouldBlock is returned if and urgent is available but data needs to be 
  1601 * read from the current stream to match the urgent data mark.
  1602 * 
  1603 * Option data type is TInt.
  1604 * 
  1605 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
  1606 */
  1607 const TUint KSoTcpReadUrgentData = 0x311;
  1608 /**
  1609 * Peeks for urgent data. The behaviour is the same as KSoTcpReadUrgentData,
  1610 * but the urgent data is not removed.
  1611 * 
  1612 * Option data type is TInt.
  1613 * 
  1614 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
  1615 */
  1616 const TUint KSoTcpPeekUrgentData = 0x312;
  1617 /**
  1618 * True if the data stream has been read up to the point where urgent
  1619 * data is available, otherwise false.
  1620 * 
  1621 * Option data type is TInt.
  1622 * 
  1623 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
  1624 */
  1625 const TUint KSoTcpRcvAtMark = 0x313;
  1626 /**
  1627 * The next send operation will mark the last byte sent as urgent data.
  1628 * 
  1629 * The default is disabled.
  1630 * 
  1631 * Option data type is TInt.
  1632 * 
  1633 * Values are: 0 = Disable, 1 = Enable.
  1634 */
  1635 const TUint KSoTcpNextSendUrgentData = 0x314;
  1636 /**
  1637 * Receive out-of-band data in the normal data stream.
  1638 * 
  1639 * The default is disabled.
  1640 * 
  1641 * Option data type is TInt.
  1642 * 
  1643 * Values are: 0 = Disable, 1 = Enable.
  1644 */
  1645 const TUint KSoTcpOobInline = 0x315;
  1646 
  1647 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
  1648 /**
  1649 * TCP max receive value
  1650 * 
  1651 * Used with SetOpt to set TCP Max recv window size
  1652 */
  1653 const TUint KSoTcpMaxRecvWin = 0x316;
  1654 /**
  1655 * TCP Receive window size for auto tuning
  1656 * 
  1657 * Used with SetOpt to set TCP Max recv window size
  1658 */
  1659 const TUint KSoTcpRecvWinAuto = 0x317;
  1660 
  1661 #endif //SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
  1662 
  1663 
  1664 /** Not supported. @removed */
  1665 const TUint KSOTcpDebugMode = 0x11110000;
  1666 //@}
  1667 
  1668 /**
  1669 * @name IPv6 and IPv4 socket options
  1670 *
  1671 * Level: #KSolInetIp
  1672 *
  1673 */
  1674 //@{
  1675 /**
  1676 * Data to place in IP Options field of sent datagrams. 
  1677 * 
  1678 * Not supported. @removed
  1679 * @since 7.0
  1680 */
  1681 const TUint KSoIpOptions = 0x401;
  1682 /**
  1683 * Include IP header in data returned to client.
  1684 * 
  1685 * IPv4 packets are returned as is with all headers in network byte order (until 
  1686 * v7.0, this returned IPv4 headers in host order). See TInet6HeaderIP4 and
  1687 * TInet6HeaderIP for the header layout.
  1688 * 
  1689 * The default is disabled.
  1690 * 
  1691 * Option data type is TInt.
  1692 * Values are: 0 = Disable, 1 = Enable.
  1693 *
  1694 * @sa	KSoHeaderIncluded, KIpHeaderIncluded
  1695 */
  1696 const TUint KSoRawMode = 0x402;
  1697 /**
  1698 * Assume that the IP header is included in all data written by the client.
  1699 *
  1700 * KSoRawMode must be set before this is allowed.
  1701 *
  1702 * 
  1703 * Option data type is TInt.
  1704 * Values are: 0. Disable; 1. Enable
  1705 * 
  1706 * The default is disabled.
  1707 *
  1708 * @sa	KSoRawMode, KIpHeaderIncluded
  1709 */
  1710 const TUint KSoHeaderIncluded = 0x403;
  1711 /**
  1712 * Type of Service field of outgoing datagrams.
  1713 * 
  1714 * For IPv6, there is no Type of Service field, so this option sets the Traffic Class.
  1715 * 
  1716 * Option data type is TInt.
  1717 * Values are 0-255. Because Explicit Congestion Notification [RFC3168] uses bits 6 & 7
  1718 * in the IP field, modifying the two least significant bits is not allowed with TCP.
  1719 * SetOpt processing silently ignores any modifications on these bits when using TCP socket.
  1720 * 
  1721 * The default value is 0.
  1722 */
  1723 const TUint KSoIpTOS = 0x404;
  1724 /**
  1725 * Time to Live field of outgoing datagrams.
  1726 * 
  1727 * This is same as #KSoIp6UnicastHops.
  1728 * 
  1729 * Option data type is TInt.
  1730 * Values are [-1,,255]. The -1 resets to the configured default value.
  1731 * 
  1732 * There are separate configured default values for the link local and other
  1733 * destinations. Both defaults can be configured by the TCPIP.INI parameters
  1734 * <tt>maxttl</tt>  and <tt>linklocalttl</tt>, The compiled defaults are
  1735 * #KTcpipIni_Maxttl and #KTcpipIni_LinkLocalttl.
  1736 *
  1737 * @note
  1738 *	For the TTL of multicast destinations, @see KSoIp6MulticastHops.
  1739 */
  1740 const TUint KSoIpTTL = 0x405;
  1741 /**
  1742 * Allow a socket to be bound to an local address that is already in use.
  1743 * 
  1744 * Option data type is TInt.
  1745 * Values are: 0 = Disable, 1 = Enable.
  1746 * 
  1747 * The default is disabled.
  1748 * @capability NetworkControl		Required for 'udp' sockets.
  1749 */
  1750 const TUint KSoReuseAddr = 0x406;
  1751 /**
  1752 * Do not set socket into error state if currently connected
  1753 * interface reports an error.
  1754 *
  1755 * For example, this could be enabled for a unconnected datagram
  1756 * socket. Unconnected datagram sockets are connected to the
  1757 * interface of the last sent packet. If multiple interfaces
  1758 * are present, erroring the socket might not be the desired
  1759 * action if just one interface gives an error.
  1760 *
  1761 * Another use case would be a connected socket (TCP), which
  1762 * does not get error even if interface goes down, and comes
  1763 * up with the same source address after a while.
  1764 * 
  1765 * Option data type is TInt.
  1766 * Values are: 0 = Disable, 1 = Enable.
  1767 * 
  1768 * The default can be changed by the TCPIP.INI parameter <tt>noiferror</tt>,
  1769 * and the compiled default is #KTcpipIni_Noiferror..
  1770 * 
  1771 * @since 7.0
  1772 */
  1773 const TUint KSoNoInterfaceError = 0x407;
  1774 /**
  1775 * Modify socket visibility.
  1776 * 
  1777 * Background internet services that have sockets open count as active 
  1778 * user and prevents the TCPIP from shutting down. 
  1779 * By this socket option, such a process can make selected sockets to be
  1780 * excluded from the count.
  1781 * 
  1782 * Option data type is TInt.
  1783 * By setting the value to 0, the socket is not counted as active user. The value 
  1784 * 1 makes it visible again.
  1785 * 
  1786 * The option has no effect if the visibility state already matches the parameter.
  1787 *
  1788 * By default, all sockets are initially visible.
  1789 *
  1790 * @note
  1791 *	This option should only be used by background daemons which are
  1792 *	started by the TCPIP stack.
  1793 * @since 7.0
  1794 */
  1795 const TUint KSoUserSocket = 0x408;
  1796 /**
  1797 * Set or get interface index of the socket.
  1798 *
  1799 * Gets the current interface index of the socket. Returns the
  1800 * value used in the last set.
  1801 *
  1802 * If interface index has not been set by this option, then value is
  1803 * determined as follows:
  1804 *
  1805 * @li
  1806 *	the interface index of the interface which got the last packet
  1807 *	from this socket.
  1808 * @li
  1809 *	zero, if no packets have been sent or interface cannot be
  1810 *	determined.
  1811 *
  1812 * Option data type is TUint32.
  1813 *
  1814 * @since 7.0s
  1815 */
  1816 const TUint KSoInterfaceIndex = 0x409;
  1817 /**
  1818 * Controls whether the interface flow counter is affected by this socket. 
  1819 * 
  1820 * This counter is used in determining when the interface can be brought down.
  1821 * 
  1822 * Option data type is TInt.
  1823 * Values are: 0=Don't count, 1= count flow against 
  1824 * interface flow count.
  1825 *
  1826 * The default can be changed by the TCPIP.INI parameter <tt>keepinterfaceup</tt>,
  1827 * and the compiled default is #KTcpipIni_KeepInterfaceUp.
  1828 *
  1829 * @since 7.0s
  1830 */
  1831 const TUint KSoKeepInterfaceUp = 0x40a;
  1832 /**
  1833 * Enable use of 0 as a source address.
  1834 *
  1835 * When socket is bound to unspecified address (0), the stack will automaticly
  1836 * select the source address for the outgoing packets. When this option is
  1837 * set <b>after bind</b>, the stack will not select a new address.
  1838 *
  1839 * @since 7.0s
  1840 */
  1841 const TUint KSoNoSourceAddressSelect = 0x40b;
  1842 /**
  1843 * Retrieve last error information.
  1844 * 
  1845 * This option is for use with GetOpt() only.
  1846 * 
  1847 * Option data type is TSoInetLastErr.
  1848 */
  1849 const TUint KSoInetLastError = 0x200;
  1850 /**
  1851 * An Ioctl corresponding to the socket option KSoInetLastError.
  1852 */
  1853 const TUint KIoctlInetLastError = 0x200;
  1854 /**
  1855 * Hop limit for outgoing datagrams: same as #KSoIpTTL.
  1856 * 
  1857 * Option data type is TInt.
  1858 * Values are [-1,,255]. The -1 resets to the configured default value.
  1859 * 
  1860 * @see #KSoIpTTL for details.
  1861 *
  1862 * @note
  1863 *	KSoIp6UnicastHops can be used to detect dual IPv4/IPv6 stack from
  1864 *	from the old TCPIP only-IPv4 stack. This option is only implemented
  1865 *	in the dual stack.
  1866 * @since 7.0
  1867 */
  1868 const TUint KSoIp6UnicastHops = 0x465;
  1869 /**
  1870 * Interface for outgoing multicast packets
  1871 * 
  1872 * Unused.
  1873 */
  1874 const TUint KSoIp6MulticastIf = 0x46a;
  1875 /**
  1876 * Hop limit for multicast packets.
  1877 * 
  1878 * Option data type is TInt.
  1879 * Values are [-1..255]. The -1 resets to the configured default value.
  1880 * 
  1881 * The default is 1.
  1882 * @since 7.0
  1883 */
  1884 const TUint KSoIp6MulticastHops	= 0x46b;
  1885 /**
  1886 * Enable/disable loopback of the multicast packets.
  1887 *
  1888 * When enabled, multicast packets sent to this socket are internally
  1889 * looped back (in addition to sending them onto the interface). Another
  1890 * or same application listening the group and port, receives copies of
  1891 * the transmitted packets.
  1892 *
  1893 * When disabled, an application on this host listening the same group
  1894 * and port, does not receive multicast packets originating from this
  1895 * socket (unless the interface or link echoes them back to the TCP/IP
  1896 * stack).
  1897 * 
  1898 * Option data type is TInt.
  1899 * Values are 1=enable; 0=disable. The default is 1.
  1900 * @since 7.0
  1901 */
  1902 const TUint KSoIp6MulticastLoop	= 0x46c;
  1903 /**
  1904 * Join multicast group. 
  1905 *
  1906 * Option data type is TIp6Mreq.
  1907 * @since 7.0
  1908 */
  1909 const TUint KSoIp6JoinGroup	= 0x46d;
  1910 /**
  1911 * Leave multicast group. 
  1912 *
  1913 * Option data type is TIp6Mreq.
  1914 * @since 7.0
  1915 */
  1916 const TUint KSoIp6LeaveGroup = 0x46e;
  1917 /**
  1918 * Hop limit for outgoing datagrams: similar to KSoIp6UnicastHops except
  1919 * any socket option to override the current setting is ignored.  The value
  1920 * returned is either the value of the associated interface or the TCP/IP 6
  1921 * stack default if no interface has been selected yet.
  1922 * 
  1923 * Option data type is TInt.
  1924 * Values are [0..255]. Value cannot be modified, only queried.
  1925 * 
  1926 * @see KSoIp6UnicastHops for details.
  1927 *
  1928 * @since 9.2
  1929 */
  1930 const TUint KSoIp6InterfaceUnicastHops = 0x46f;
  1931 
  1932 
  1933 class TSoInetLastErr
  1934 /**
  1935 * Error information for TCP/IP protocols. 
  1936 * 
  1937 * An object of this class is returned packaged as a TPckgBuf<TSoInetLastErr> 
  1938 * in the option argument of RSocket::GetOpt(), when this function is called 
  1939 * with (KSolInetIp, KSoInetLastError). The data members of this object 
  1940 * are updated whenever a packet carrying an ICMP message is received.
  1941 *
  1942 * @note
  1943 *	This class is originally defined only for the IPv4 environment, and
  1944 *	there is no definite way of knowing whether the fields iErrType and
  1945 *	iErrCode contain ICMPv4 or ICMPv6 codes. A solution that will give
  1946 *	the correct answer in most normal cases, is
  1947 @code
  1948 	TSoInetLastErr p;
  1949 	...
  1950 	if (p.iErrAddr.Family() == KAfInet || p.iErrAddr.IsV4Mapped())
  1951 		// assume ICMPv4 type and code
  1952 	else
  1953 		// assume ICMPv6 type and code
  1954 @endcode
  1955 
  1956 * Alternatively, the error can be interpreted based on the member variable
  1957 * iStatus, if it contains one of the extended error codes. These are are
  1958 * common for both IPv4 and IPv6.
  1959 *
  1960 * @publishedAll
  1961 * @released
  1962 */
  1963 	{
  1964 public:
  1965 	/** The error code returned by the last ESOCK API function called. */
  1966 	TInt iStatus;
  1967 	/** The value of the Type field of the last ICMP message. */
  1968 	TInt iErrType;
  1969 	/** The value of the Code field of the last ICMP message. */
  1970 	TInt iErrCode;
  1971 	/** A TInetAddr with the IP address and port set to the source address and port 
  1972 	* of the failed datagram. */
  1973 	TInetAddr iSrcAddr;
  1974 	/** A TInetAddr with the IP address and port set to the destination address and 
  1975 	* port of the failed datagram. */
  1976 	TInetAddr iDstAddr;
  1977 	/** A TInetAddr with the IP address set to the address of the host that generated 
  1978 	* the error. */
  1979 	TInetAddr iErrAddr;
  1980 	};
  1981 
  1982 class TIp6Mreq
  1983 /**
  1984 * TIp6Mreq.
  1985 *
  1986 * Used by IPv6 or IPv4 multicast join/leave group socket options
  1987 * #KSoIp6JoinGroup and #KSoIp6LeaveGroup.
  1988 *
  1989 * Joining to a multicast group address adds this address to the
  1990 * list of addresses for which incoming packets are accepted.
  1991 * Optionally, if the required support has been installed, some
  1992 * MLD (Multicast Listener Discovery) protocol messages may be
  1993 * generated.
  1994 *
  1995 * The multicast join/leave are always interface specific,
  1996 * and the interface index should be specified in the set option call.
  1997 * If the index value is set to 0, the stack attempts to select
  1998 * some interface.
  1999 *
  2000 * @publishedAll
  2001 * @released
  2002 * @since 7.0
  2003 */
  2004 	{
  2005 public:
  2006 	/** IPv6 or IPv4 multicast address. */
  2007 	TIp6Addr iAddr;
  2008 	/** Interface Index. */
  2009 	TUint iInterface;
  2010 	};
  2011 //@}
  2012 
  2013 /**
  2014 * @name UDP options
  2015 *
  2016 * Level: #KSolInetUdp
  2017 */
  2018 //@{
  2019 /**
  2020 * Inform client of error if ICMP error packets received.
  2021 * 
  2022 * The default is disabled.
  2023 * 
  2024 * Option data type is TInt.
  2025 * Values are: 0 = Disable, 1 = Enable.
  2026 */
  2027 const TUint KSoUdpReceiveICMPError = 0x500;
  2028 
  2029 /**
  2030 Modifies address flag of UDP. Flag is used to control whether the socket is bound to
  2031 IP address or not. Binding to specific address and then clearing this flag makes possible
  2032 to receive packets sent to broadcast address but still to have a specific bound address 
  2033 for outgoing packets.
  2034 */
  2035 const TUint KSoUdpAddressSet = 0x502;
  2036 
  2037 /**
  2038 * Setting this option causes the UDP send operation to block when dynamic interface 
  2039 * setup is in progress, or when local flow control within the stack would otherwise 
  2040 * cause the packet to be dropped.
  2041 * @since 7.0
  2042 */
  2043 const TUint KSoUdpSynchronousSend = 0x560;
  2044 //@}
  2045 
  2046 /**
  2047 * @name TCP/IP specific Socket provider options
  2048 *
  2049 * Level: #KSOLProvider
  2050 */
  2051 //@{
  2052 /**
  2053 * Internal flow option called when the flow is about to be closed.
  2054 *
  2055 * This option is only for the outbound flow hooks, which are
  2056 * attached to the TCIP/IP stack. The stack generates a call, just
  2057 * before the flow context associated with service access point
  2058 * (SAP) provider is about to be closed. If a hook has stored
  2059 * some socket specific state information into the flow context,
  2060 * then this option event may be of some use to it.
  2061 * @since 7.0
  2062 */
  2063 const TUint KSoFlowClosing = 0x600 | KSocketInternalOptionBit;
  2064 //@}
  2065 
  2066 /**  @name Extended error codes */
  2067 //@{
  2068 /** Network could not be reached. */
  2069 const TInt KErrNetUnreach = -190;
  2070 /** Host could not be reached. */
  2071 const TInt KErrHostUnreach = -191;
  2072 /** Protocol could not be reached. */
  2073 const TInt KErrNoProtocolOpt = -192;
  2074 /** Urgent data error. */
  2075 const TInt KErrUrgentData = -193;
  2076 //@}
  2077 
  2078 #endif