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