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