epoc32/include/es_sock.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @publishedAll
    19  @released
    20 */
    21 
    22 #if !defined(__ES_SOCK_H__)
    23 #define __ES_SOCK_H__
    24 
    25 
    26 #include <e32base.h>
    27 #include <nifvar.h>
    28 
    29 #undef	_DEBUG_SOCKET_FUNCTIONS
    30 #if defined(_DEBUG)
    31 #define	_DEBUG_SOCKET_FUNCTIONS
    32 #endif
    33 
    34 #include <comms-infras/metacontainer.h>
    35 #include <elements/sd_errors.h>
    36 #include <comms-infras/es_parameterset.h>
    37 
    38 #include <comms-infras/es_event.h>
    39 
    40 using Meta::STypeId;
    41 using Meta::SMetaDataECom;
    42 using Meta::RMetaDataEComContainer;
    43 
    44 
    45 // Forward declaration of CCommsDataObjectBase
    46 namespace ESock
    47 {
    48 	class CCommsDataObjectBase;
    49 }
    50 
    51 /**
    52 Canonical names for the core ESOCKSVR modules
    53 */
    54 _LIT8(SOCKET_SERVER_MAIN_MODULE_NAME, "ESock_Main");		// Worker 0
    55 _LIT8(SOCKET_SERVER_IP_MODULE_NAME, "ESock_IP");			// Worker 1
    56 _LIT8(SOCKET_SERVER_BT_MODULE_NAME, "ESock_Bt");			// Worker 2
    57 _LIT8(SOCKET_SERVER_IR_MODULE_NAME, "ESock_Ir");			// Worker 3
    58 _LIT8(SOCKET_SERVER_SMSWAP_MODULE_NAME, "ESock_SmsWap");	// Worker 4
    59 
    60 
    61 /**
    62 Progress Notification to inform clients Connection is up
    63 This event has the same numerical values as 
    64 KLinkLayerOpen which is deprecated
    65 @publishedAll
    66 @released
    67 */
    68 
    69 const TUint KConnectionUp    = 7000;    
    70 /**
    71 Progress Notification to inform clients Connection is up
    72 This event has the same numerical values as 
    73 KLinkLayerClosed which is deprecated 
    74 
    75 @publishedAll
    76 @released
    77 */
    78 
    79 const TUint KConnectionDown  = 8000;  
    80 
    81       
    82 
    83 /**
    84 Default number of message slots.
    85 @publishedAll
    86 @released
    87 */
    88 const TUint KESockDefaultMessageSlots=8;
    89 
    90 
    91 /**
    92 Size of Maximum SubConnection event
    93 
    94 @publishedAll
    95 @released
    96 @note If you allocate this on the heap, remember to delete through the pointer to the buffer and not any pointers to the events held inside it
    97 if you change this value, you will alter the function signature and break the .def file
    98 */
    99 const TUint KMaxSubConnectionEventSize = 512;
   100 
   101 /**
   102 SubConnection Unique Id
   103 
   104 THIS API IS TO BE DEPRECATED
   105 
   106 @publishedPartner
   107 @released
   108 */
   109 typedef TUint TSubConnectionUniqueId;
   110 
   111 /**
   112 Buffer for  notification of any change in the state of  SubConnection.
   113 
   114 THIS API IS TO BE DEPRECATED
   115 
   116 @publishedPartner
   117 @released
   118 */
   119 typedef TBuf8<KMaxSubConnectionEventSize> TSubConnectionNotificationBuf;
   120 //
   121 const TUint KUseEmbeddedUniqueId = 0; //< Used by RConnection to identify cases where the subconnection id is embedded in the data structure
   122 
   123 const TUint KConnProgressDefault = 0; //< Default Connection Progress
   124 
   125 class TSessionPref
   126 /**
   127 Hint to the Socket Server on what will be the principal usage of the connection.
   128 It is by no means a restriction but may result in better performance for the session.
   129 
   130 @publishedAll
   131 @released
   132 */
   133 	{
   134 public:
   135     IMPORT_C TSessionPref();
   136 public:
   137 	/** The protocol's address family. For example, for TCP/IP protocols, KAfInet. */
   138 	TUint iAddrFamily;
   139 	/** The protocol type. */
   140 	TUint iProtocol;
   141 	/** Reserved. */
   142 	TUint iReserved;
   143 	/** Reserved. */
   144 	TUint iReserved1;
   145 	/** Reserved. */
   146 	TUint iReserved2;
   147 	/** Reserved. */
   148 	TUint iReserved3;
   149 	/** Reserved. */
   150 	TUint iReserved4;
   151 	};
   152 
   153 class TNifProgress
   154 /**
   155 Contains progress information on a dial-up connection
   156 
   157 @publishedAll
   158 @released
   159 */
   160 	{
   161 public:
   162 	inline TNifProgress();
   163 	inline TNifProgress(TInt aStage, TInt aError);
   164 	inline TBool operator==(const TNifProgress& aRHS) const;
   165 	TInt iStage;
   166 	TInt iError;
   167 	};
   168 
   169 class TNifAgentInfo
   170 /**
   171 Contains information describing an agent
   172 
   173 @publishedAll
   174 @released
   175 */
   176 	{
   177 public:
   178 	/**	This class Contains version information	*/
   179 	TVersion iVersion;
   180 
   181 	/**	This class Defines a modifiable buffer descriptor that can contain the name of a reference counting object	*/
   182 	TName iName;
   183 	};
   184 
   185 /**
   186 Buffer for Network Interface Progress
   187 
   188 @publishedAll
   189 @released
   190 */
   191 typedef TPckgBuf<TNifProgress> TNifProgressBuf;
   192 
   193 /**
   194 Socket address offsets.
   195 
   196 @publishedAll
   197 @released
   198 */
   199 struct SSockAddr
   200 /** Socket address offsets.
   201 
   202 This class defines the internal offsets of data members for the TSockAddr
   203 class. */
   204 	{
   205 	/** Address family of socket address */
   206 	TUint iFamily;
   207 	/** Port (or equivilent) number */
   208 	TUint iPort;
   209 	};
   210 
   211 /**
   212 Maximum sockets address size.
   213 @publishedAll
   214 @released
   215 */
   216 const TUint KMaxSockAddrSize=0x20;
   217 
   218 class TSockAddr : public TBuf8<KMaxSockAddrSize>
   219 /** Represents an end point address.
   220 
   221 Protocols interpret the class within the socket server to route packets and
   222 form connections. It can be used on its own or as derived by protocols. The
   223 SSockAddr class acts as an offset map for the TSockAddr class which has a
   224 family field and a port field. The family field may be used by protocols to
   225 "up-cast" the base-class to the correct derived class. The port field is provided
   226 because it is a common practice for protocols to use port equivalents in addressing.
   227 
   228 Writing derived classes:
   229 
   230 The two protected member functions allow further data members to be defined
   231 past the area of the base SSockAddr. In any derived constructor the length
   232 of the descriptor should be set to the length of the valid data contained
   233 in the address. Subsequent member function calls should also adjust the length
   234 if it affects valid data.
   235 @publishedAll
   236 @released */
   237 	{
   238 public:
   239 	IMPORT_C TSockAddr();
   240 	IMPORT_C TSockAddr(TUint aFamily);
   241 	IMPORT_C TUint Family() const;
   242 	IMPORT_C void SetFamily(TUint aFamily);
   243 	IMPORT_C TUint Port() const;
   244 	IMPORT_C void SetPort(TUint aPort);
   245 	IMPORT_C TBool CmpPort(const TSockAddr& anAddr) const;
   246 	IMPORT_C TInt GetUserLen();
   247 protected:
   248 	IMPORT_C void SetUserLen(TInt aLen);
   249 	inline TUint8* UserPtr() const;
   250 private:
   251 	inline SSockAddr* BasePtr() const;
   252 	};
   253 
   254 // Address families (based upon protocol IDs used by ARP/REVARP)
   255 /** Default (unspecified) protocol module.
   256 @publishedAll
   257 @released */
   258 const TUint KAFUnspec=0;
   259 
   260 // Socket types
   261 /** Stream socket.
   262 @publishedAll
   263 @released */
   264 const TUint KSockStream=1;
   265 /** Datagram socket. */
   266 const TUint KSockDatagram=2;
   267 /** Datagrams with sequence numbers. */
   268 const TUint KSockSeqPacket=3;
   269 /** Raw socket. */
   270 const TUint KSockRaw=4;
   271 
   272 // constants for various socket calls - can't be enums cos they're largely defined by protocols
   273 // The following constants are used to define level parameters for RSocket::Ioctl(), RSocket::GetOpt()
   274 // and RSocket::SetOpt().
   275 /** Generic socket options/commands.
   276 @publishedAll
   277 @released */
   278 const TInt KSOLSocket=1;
   279 /** Unspecified level. */
   280 const TInt KLevelUnspecified=0;
   281 
   282 // Socket options defined by the server.
   283 // Used through RSocket::SetOpt(), and RSocket::GetOpt() with anOptionLevel set
   284 // to KSOLSocket. Options can be both get and set unless otherwise.
   285 // stated.
   286 // Notes:
   287 // Setting the send and receive buffer sizes explicitly can help to reduce
   288 // the memory requirements if many data sockets are used in an application. If a
   289 // socket is datagram-oriented and its receive/send buffer size is set
   290 // to KSocketBufSizeUndefined, then the initial buffer size will
   291 // be KSocketDefaultBufferSize and buffers will grow to accommodate
   292 // larger sends/receives. If the buffer size is set explicitly for
   293 // datagram-oriented sockets, sends which exceed the set size will fail
   294 // with KErrTooBig and receives will be truncated. For stream based
   295 // sockets there should be no noticeable effect on client reads, unless the buffer
   296 // size is set to a prohibitively low value.
   297 /** Debugging enabled or disabled . Values are:
   298 
   299 (TInt)0. Disabled
   300 
   301 (TInt)1. Enabled
   302 @publishedAll
   303 @released */
   304 const TUint KSODebug=1;
   305 /** Socket receive buffer size. Values are:
   306 
   307 KSocketBufSizeUndefined
   308 
   309 1 to KMaxTUint: explicit buffer size, supplied as a TPckgBuf<TUint> */
   310 const TUint KSORecvBuf=2;
   311 /** Socket send buffer size. Values are:
   312 
   313 KSocketBufSizeUndefined
   314 
   315 1 to KMaxTUint: explicit buffer size, supplied as a TPckgBuf<TUint> */
   316 const TUint KSOSendBuf=3;
   317 /** Socket nonblocking mode. To set, no option values are required. For getting,
   318 values are:
   319 
   320 (TInt)0. Disabled
   321 
   322 (TInt)1. Enabled */
   323 const TUint KSONonBlockingIO=4;
   324 /** Socket blocking mode. To set, no values are required. For getting, values are:
   325 
   326 (TInt)0. Disabled
   327 
   328 (TInt)1. Enabled */
   329 const TUint KSOBlockingIO=5;
   330 /** Getting only: gets a bitmask of flags describing the read/write/exception status
   331 of the socket. Value is a TInt containing a bitmask of socket status (KSockSelectExcept
   332 etc.) constants. */
   333 const TUint KSOSelectPoll=6;
   334 /** Getting only: retrieve the number of bytes currently available for reading.
   335 Value is a TInt. */
   336 const TUint KSOReadBytesPending=7;
   337 /** Getting only: retrieve the urgent data offset (only for stream protocols that
   338 support urgent data).
   339 Value is a TInt. */
   340 const TUint KSOUrgentDataOffset=8;
   341 /** 
   342 Getting only: retrieves the last error. 
   343 Errors are normally reported by the called method and behaviour is protocol dependent.
   344 KSOSelectLastError does not return such errors.
   345 Value is a TInt. */
   346 const TUint KSOSelectLastError=9;
   347 
   348 
   349 /**
   350 Setting only. Enables socket to be transferred to the process with given capabilities.
   351 The capabilities set should be supplied as TPckgBuf<TSecurityPolicy>.
   352 Each RSocket::Transfer() call must be enabled by setting this option.
   353 @publishedAll
   354 @released */
   355 const TUint KSOEnableTransfer = 10;
   356 
   357 /** Setting only. Disables a socket's possibility to be transferred. No option required.
   358 @publishedAll
   359 @released */
   360 
   361 const TUint KSODisableTransfer = 11;
   362 
   363 // The following constants relating to buffer sizes are defined
   364 
   365 /** Use default buffer size. */
   366 const TInt  KSocketBufSizeUndefined=0;
   367 /** Default buffer size. */
   368 const TInt  KSocketDefaultBufferSize=4096;
   369 
   370 //internal
   371 const TUint KSocketInternalOptionBit=0x80000000;	//< Must not be set for client requests
   372 
   373 
   374 /** The aDesc parameter of RSocket::Ioctl() specifies a TUint containing a bitmask
   375 of Socket status constants. The completion status will be the subset of those
   376 conditions which is now true for the socket.
   377 
   378 Used through RSocket::Ioctl(), with aLevel set to KSOLSocket.
   379 
   380 @see KSOSelectPoll parameter to RSocket::GetOpt(), which allows the
   381 current select state of the socket to be read synchronously, and KSOSelectLastError,
   382 which returns the error code. */
   383 const TUint KIOctlSelect=1;
   384 
   385 // Select ioctl states
   386 // Socket status. See also KSOSelectLastError and KSOSelectPoll.
   387 /** Data is available to be read; for listening sockets, a connect is pending.
   388 @publishedAll
   389 @released */
   390 const TUint KSockSelectRead   =0x00000001;
   391 /** Writing to the socket is not currently blocked by flow-control. */
   392 const TUint KSockSelectWrite  =0x00000002;
   393 /** An error has occurred. */
   394 const TUint KSockSelectExcept =0x00000004;
   395 /** Include tail of prior read datagram as available data (ie indicates next read will be with read continuation) */
   396 const TUint KSockSelectReadContinuation = 0x01000000;
   397 
   398 // Socket write flags
   399 /** The data to be sent is urgent and is given a higher priority than ordinary data in the send queue.
   400 KSockWriteUrgent may only be provided as a flag to Send() if the protocol's information flag is marked with
   401 KSIUrgentData, otherwise Send() will return with KErrNotSupported. AKA: Out of band or unit data.
   402 @publishedAll
   403 @released */
   404 const TUint KSockWriteUrgent=0x00000001;
   405 /** Must not be set for client requests. */
   406 const TUint KSocketInternalWriteBit=0x80000000;
   407 /** The top 8 bits are reserved for system purposes; protocols must not define these bits. */
   408 const TUint KSockWriteSystemMask=0xFF000000;
   409 
   410 // Socket read flags
   411 /** Read data without consuming it, data remains in the receive queue. KSockReadPeek may only be provided
   412 as a flag to Recv() if the protocol's information flag is marked with KSIPeekData, otherwise Recv() will
   413 return with KErrNotSupported.
   414 @publishedAll
   415 @released
   416 */
   417 const TUint KSockReadPeek=0x00000001;
   418 /** Must not be set for client requests. */
   419 const TUint KSocketInternalReadBit=0x80000000;
   420 /** Read from datagram in a stream-like fashion (not discarding tails). */
   421 const TUint KSockReadContinuation = 0x01000000;
   422 // Types
   423 
   424 /** Used in structure TProtocolDesc to describes the endianness of a protocol.
   425 @publishedAll
   426 @released */
   427 enum TByteOrder
   428 	{
   429 	/** Big endian */
   430 	EBigEndian,
   431 	/** Little endian */
   432 	ELittleEndian,
   433 	/** Other byte order */
   434 	EOtherByteOrder,
   435 	};
   436 
   437 //
   438 // Protocol Service information bitmasks.
   439 // The following constants are defined for
   440 // TServerProtocolDesc and TProtocolDesc
   441 //
   442 /** The protocol is connectionless.
   443 @publishedAll
   444 @released */
   445 const TUint KSIConnectionLess=0x00000001;
   446 /** The protocol is reliable. */
   447 const TUint KSIReliable=0x00000002;
   448 /** The protocol guarantees in-order delivery. */
   449 const TUint KSIInOrder=0x00000004;
   450 /** The protocol is message based. */
   451 const TUint KSIMessageBased=0x00000008;
   452 /** The same as message based. */
   453 const TUint KSIDatagram=KSIMessageBased;
   454 /** The protocol is stream based. */
   455 const TUint KSIStreamBased=0x00000010;
   456 /** The protocol supports a stream like interface but maintains datagram boundaries. */
   457 const TUint KSIPseudoStream=0x00000020;
   458 /** The protocol offers an expedited data service. */
   459 const TUint KSIUrgentData=0x00000040;
   460 /** The protocol can send user data on a connection request. */
   461 const TUint KSIConnectData=0x00000080;
   462 /** The protocol can send user data on a disconnect request. */
   463 const TUint KSIDisconnectData=0x00000100;
   464 /** The protocol supports broadcast addresses. */
   465 const TUint KSIBroadcast=0x00000200;
   466 /** The protocol supports point to multi-point connections. */
   467 const TUint KSIMultiPoint=0x00000400;
   468 /** The protocol supports a quality of service metric. */
   469 const TUint KSIQOS=0x00000800;
   470 /** The protocol is write only. */
   471 const TUint KSIWriteOnly=0x00001000;
   472 /** The protocol is read only. */
   473 const TUint KSIReadOnly=0x00002000;
   474 /** The protocol supports graceful close. */
   475 const TUint KSIGracefulClose=0x00004000;
   476 /** The same socket can be reconnected if it disconnects (for whatever reason). */
   477 const TUint KSICanReconnect=0x00008000;
   478 /** Protocol supports peeking (looking at the data without removing it from the
   479 protocol). */
   480 const TUint KSIPeekData=0x00010000;
   481 /** Protocol is to be informed of the identity of the client (i.e. process ID,
   482 thread ID and UID) of each SAP (i.e. Socket Service Provider) created.
   483 Note that this value has no meaningful interpretation on the client side.
   484 @see KSoOwnerInfo and TSoOwnerInfo */
   485 const TUint KSIRequiresOwnerInfo=0x00020000;	// SetOption(KSoOwnerInfo) invoked on each SAP
   486 /** @internalTechnology */
   487 const TUint KSIReserved=0xFFFC0000;
   488 
   489 //
   490 // Naming service constants
   491 // The following constants are defined for
   492 // TServerProtocolDesc and TProtocolDesc
   493 //
   494 /** Protocol supports resolving human readable entity names into network addresses
   495 (like DNS).
   496 @publishedAll
   497 @released */
   498 const TUint KNSNameResolution=0x00000001;
   499 /** Network naming is hierarchical. */
   500 const TUint KNSHierarchicalNaming=0x00000002;
   501 /** @deprecated Use KNSHierarchicalNaming instead. */
   502 const TUint KNSHeirarchicalNaming=KNSHierarchicalNaming;
   503 /** Addressing is dynamic and should be attempted every time before connecting
   504 (like IrDA). */
   505 const TUint KNSRemoteDiscovery=0x00000004;
   506 /** Protocol supports service name to port number resolution. (For example, you
   507 can look up TCP to get port 48.) */
   508 const TUint KNSServiceResolution=0x00000008;
   509 /** Protocol supports additions to the name database. */
   510 const TUint KNSNameRegistration=0x00000010;
   511 /** Protocol supports additions to the service database. */
   512 const TUint KNSServiceRegistration=0x00000020;
   513 /** Addressing is dynamic - i.e. name to address mapping may change (like IrDA
   514 which randomly chooses machine addresses.) */
   515 const TUint KNSDynamicAddressing=0x00000040;
   516 /** Protocol has another database which is defined by the protocol. */
   517 const TUint KNSInfoDatabase=0x00000080;
   518 /** Protocol may request Socket Server to startup a connection on its behalf (via
   519 the KErrCompletion error code)
   520 Note that this value has no meaningful interpretation on the client side.
   521 */
   522 const TUint KNSRequiresConnectionStartup=0x00000100;
   523 /** @internalTechnology */
   524 const TUint KNSReserved=0xFFFFFE00;
   525 
   526 // Security Schemes
   527 // The following constants are defined for
   528 // TServerProtocolDesc and TProtocolDesc
   529 /** No security
   530 @publishedAll
   531 @released */
   532 const TUint KSocketNoSecurity=0x00000000;
   533 /** Secure Sockets Layer.
   534 
   535 @see CSecureSocket */
   536 const TUint KSecureSockets=0x00000001;
   537 
   538 // Special message sizes
   539 // The following constants are defined for
   540 // TServerProtocolDesc and TProtocolDesc
   541 /** Reads and writes can be of any size: the data is treated as a stream.
   542 @publishedAll
   543 @released */
   544 const TInt KSocketMessageSizeIsStream=0;
   545 /** Depends on lower layer or is dynamic. */
   546 const TInt KSocketMessageSizeUndefined=1;
   547 /** Data is packet-oriented but packets can be of any size (i.e. the remote end
   548 must specify a Read of the same size as your Write, but there is no limit
   549 on this size.) */
   550 const TInt KSocketMessageSizeNoLimit=-1;
   551 
   552 
   553 /** Undefined socket type.
   554 @publishedAll
   555 @released */
   556 const TUint KUndefinedSockType=0xFFFFFFFF;
   557 
   558 
   559 /** Undefined socket type.
   560 Undefined Protocol
   561 @released */
   562 const TUint KUndefinedProtocol=0xFFFFFFFE;
   563 
   564 /** Undefined address family
   565 @publishedPartner
   566 @released
   567  */
   568 const TUint KUndefinedAddressFamily = 0;
   569 
   570 /** Contains the name of a protocol in structure TProtocolDesc.
   571 @publishedAll
   572 @released */
   573 typedef TBuf<0x20> TProtocolName;
   574 /** Defines a descriptor to hold a service name string. */
   575 typedef TBuf<0x20> TServiceName;
   576 /** Defines a descriptor to hold a host name string. */
   577 typedef TBuf<0x100> THostName;
   578 
   579 /**
   580 Socket protocol information for use by clients
   581 
   582 @publishedAll
   583 @released
   584 */
   585 struct TProtocolDesc
   586 /** Socket protocol information for use by clients. */
   587 	{
   588 public:
   589 	/** The name of the protocol
   590 
   591 	@see TProtocolName */
   592 	TProtocolName iName;
   593 	/** An integer identifying the protocol's address family. For example, for TCP/IP
   594 	protocols, KAfInet. */
   595 	TUint iAddrFamily;
   596 	/** An integer specifying the socket type. For example, for TCP, KSockStream. */
   597 	TUint iSockType;
   598 	/** An integer specifying the specific protocol. For example, for TCP, KProtocolInetTcp. */
   599 	TUint iProtocol;
   600 	/** The version of the protocol
   601 
   602 	@see TVersion */
   603 	TVersion iVersion;
   604 	/** The byte order that the protocol uses
   605 
   606 	@see TByteOrder */
   607 	TByteOrder iByteOrder;
   608 	/** A bit mask of service information flags.
   609 
   610 	@see KSockStream etc. */
   611 	TUint iServiceInfo;
   612 	/** A bit mask indicating if the protocol supports name resolution, service resolution,
   613 	or database access services.
   614 
   615 	@see KNSNameResolution etc. */
   616 	TUint iNamingServices;
   617 	/** A bitmask of security flags.
   618 
   619 	@see KSocketNoSecurity etc. */
   620 	TUint iSecurity;
   621 	/** The message size of datagram protocols.
   622 
   623 	@see KSocketMessageSizeIsStream etc. */
   624 	TInt iMessageSize;
   625 	};
   626 
   627 // socket errors
   628 /** This error is returned from operations on non-blocking sockets that cannot
   629 be completed immediately, for example receive when no data is queued for reading.
   630 It is a non-fatal error, and the operation should be retried later.
   631 @publishedAll
   632 @released */
   633 const TInt KErrWouldBlock=-1000;
   634 
   635 /**
   636 socket errors
   637 
   638 The value -17210 is taken from the range allocated for Esock (beginning at -17200)
   639 A gap has been left between the currently existing vals and this one.
   640 
   641 @publishedAll
   642 @released
   643 */
   644 const TInt KErrConnectionTerminated=-17210;
   645 
   646 const TInt KErrCannotFindProtocol = Den::KErrPlayerNotFound;
   647 const TInt KErrTierNotFound = -17212;
   648 const TInt KErrConnectionContention = -17213;
   649 
   650 /**
   651 The protocol requested for the socket was recognised but was not able to be used.
   652 This can happen with protocols that require specific settings to have been prepared
   653 prior to the socket being opened.
   654 
   655 @publishedAll
   656 @released
   657 */ 
   658 const TInt KErrProtocolNotReady = -17214;
   659 
   660 // -17215 used for non published error. Do not use here.
   661 
   662 
   663 /** Used in RSocket read and write calls to pass the length of data read and written.
   664 @publishedAll
   665 @released */
   666 typedef TPckgBuf<TInt> TSockXfrLength;
   667 
   668 
   669 
   670 namespace ESockDebug
   671 	{
   672 	class TControlMsg;
   673 	}
   674 
   675 class RSocket;
   676 class RConnection;
   677 
   678 NONSHARABLE_CLASS(RCommsSession) : public RSessionBase
   679 	{
   680 	friend class RCommsApiExtensionBase;
   681 	friend class CCommsSessionApiExtProvider;
   682 	};
   683 
   684 class RSocketServ : public RCommsSession
   685 /** Provides the Connect() function to create an IPC communication channel to the
   686 socket server. To close the channel RHandleBase provides a RHandleBase::Close()
   687 function.
   688 
   689 The prime use for instances of RSocketServ is to establish subsession communications
   690 for RSocket, RHostResolver, RNetDatabase and RConnection.  Any of the resources
   691 which are open using the session are automatically closed when the session is
   692 terminated, however it is more appropriate to issue a Close() on each subsession object
   693 before closing the session.
   694 
   695 The following operations are also provided:
   696 
   697 NumProtocols() - enumerates the number of protocols of which the socket server
   698 is currently aware.
   699 
   700 GetProtocolInfo()/FindProtocol() - return information about a specific protocol.
   701 
   702 StartProtocol() - loads a protocol asynchronously.
   703 
   704 @note This class is not intended for user derivation.
   705 @publishedAll
   706 @released  */
   707 	{
   708 public:
   709     IMPORT_C RSocketServ();
   710 	IMPORT_C TInt Connect(TUint aMessageSlots=KESockDefaultMessageSlots);
   711 	IMPORT_C TInt Connect(const TSessionPref& aPref, TUint aMessageSlots=KESockDefaultMessageSlots);
   712 	IMPORT_C TVersion Version() const;
   713 	IMPORT_C TInt NumProtocols(TUint& aCount);
   714 	IMPORT_C TInt GetProtocolInfo(TUint anIndex,TProtocolDesc& aProtocol);
   715 	IMPORT_C TInt FindProtocol(const TProtocolName& aName,TProtocolDesc& aProtocol);
   716 	IMPORT_C void StartProtocol(TUint anAddrFamily,TUint aSockType,TUint aProtocol,TRequestStatus& aStatus);
   717 	IMPORT_C void StopProtocol(TUint anAddrFamily,TUint aSockType,TUint aProtocol,TRequestStatus& aStatus);
   718 	IMPORT_C TInt InstallExtension(const TDesC& aDllName, const TDesC& aArgs=TPtrC());
   719 	IMPORT_C void SetExclusiveMode(TRequestStatus& aStatus);
   720 	IMPORT_C void ClearExclusiveMode();
   721 	IMPORT_C TInt __DbgMarkHeap();
   722 	IMPORT_C TInt __DbgCheckHeap(TInt aCount);
   723 	IMPORT_C TInt __DbgMarkEnd(TInt aCount);
   724 	IMPORT_C TInt __DbgFailNext(TInt aCount);
   725 	IMPORT_C TBool __DbgCheckFailNext() const;
   726 	IMPORT_C TInt __DbgFailNextMbuf(TInt aCount);
   727 	IMPORT_C TInt __DbgSetMbufPoolLimit(TInt asize);
   728 	IMPORT_C TInt __DbgCheckMbuf(TInt asize);
   729 	IMPORT_C TInt __DbgMbufFreeSpace();
   730 	IMPORT_C TInt __DbgMbufTotalSpace();
   731 	IMPORT_C TInt __DbgControl(const ESockDebug::TControlMsg& aRequestMsg);
   732 	};
   733 
   734 NONSHARABLE_CLASS(RCommsSubSession) : public RSubSessionBase
   735 	{
   736 	friend class RCommsApiExtensionBase;
   737 	friend class CCommsSubSessionApiExtProvider;
   738 	};
   739 
   740 class RSubConnection;
   741 class RSocket : public RCommsSubSession
   742 /** Provides a client endpoint to a protocol. It provides functions for socket
   743 creation, reading, writing, passive connection, active connection, setting
   744 addresses and querying addresses. Use this class as an endpoint for network
   745 type communications. It provides the following services:
   746 
   747 reading from and writing to protocol
   748 
   749 binding to addresses
   750 
   751 active connecting
   752 
   753 passive connection through the listen/accept model
   754 
   755 Before using any of these services, a connection to a socket server session
   756 must have been made and the socket must be open.
   757 
   758 @publishedAll
   759 @released Since v5.0*/
   760 	{
   761 friend class RSocketServ;
   762 public:
   763 	/** Argument to RSocket::Shutdown() specifying how abruptly the shutdown occurs.
   764 	*/
   765 	enum TShutdown
   766 		{
   767 		/** Complete when socket output/input stopped. */
   768 		ENormal,
   769 		/** Stop socket input and complete when output is stopped. */
   770 		EStopInput,
   771 		/** Stop socket output and complete when input is stopped. */
   772 		EStopOutput,
   773 		/** Stop socket input/output and complete (abortive close). */
   774 		EImmediate
   775 		};
   776 public:
   777 	IMPORT_C RSocket();
   778 
   779 	IMPORT_C TInt Open(RSocketServ& aServer,TUint addrFamily,TUint sockType,TUint protocol);
   780 	IMPORT_C TInt Open(RSocketServ& aServer,TUint addrFamily,TUint sockType,TUint protocol, RConnection& aConnection);
   781 	IMPORT_C TInt Open(RSocketServ& aServer,TUint addrFamily,TUint sockType,TUint protocol, RSubConnection& aSubConnection);
   782 	IMPORT_C TInt Open(RSocketServ &aServer,const TDesC& aName);
   783 	IMPORT_C TInt Open(RSocketServ& aServer);
   784 	IMPORT_C void Send(const TDesC8& aDesc,TUint someFlags,TRequestStatus& aStatus);
   785 
   786 	IMPORT_C void Send(const TDesC8& aDesc,TUint someFlags,TRequestStatus& aStatus,TSockXfrLength& aLen);
   787 	IMPORT_C void CancelSend();
   788 
   789 	IMPORT_C void Recv(TDes8& aDesc,TUint flags,TRequestStatus& aStatus);
   790 
   791 	IMPORT_C void Recv(TDes8& aDesc,TUint flags,TRequestStatus& aStatus,TSockXfrLength& aLen);
   792 
   793 	IMPORT_C void RecvOneOrMore(TDes8& aDesc,TUint flags,TRequestStatus& aStatus,TSockXfrLength& aLen);
   794 	IMPORT_C void RecvOneOrMore(TDes8& aDesc,TUint flags,TRequestStatus& aStatus);
   795 	IMPORT_C void CancelRecv();
   796 
   797 	IMPORT_C void Read(TDes8& aDesc,TRequestStatus& aStatus);
   798 	IMPORT_C void CancelRead();
   799 
   800 	IMPORT_C void Write(const TDesC8& aDesc,TRequestStatus& aStatus);
   801 	IMPORT_C void CancelWrite();
   802 	IMPORT_C void SendTo(const TDesC8& aDesc,TSockAddr& anAddr,TUint flags,TRequestStatus& aStatus);
   803 
   804 	IMPORT_C void SendTo(const TDesC8& aDesc,TSockAddr& anAddr,TUint flags,TRequestStatus& aStatus,TSockXfrLength& aLen);
   805 
   806 	IMPORT_C void RecvFrom(TDes8& aDesc,TSockAddr& anAddr,TUint flags,TRequestStatus& aStatus);
   807 
   808 	IMPORT_C void RecvFrom(TDes8& aDesc,TSockAddr& anAddr,TUint flags,TRequestStatus& aStatus,TSockXfrLength& aLen);
   809 	IMPORT_C void Connect(TSockAddr& anAddr,TRequestStatus& aStatus);
   810 	IMPORT_C void Connect(TSockAddr& anAddr,const TDesC8& aConnectDataOut,TDes8& aConnectDataIn,TRequestStatus& aStatus);
   811 	IMPORT_C void CancelConnect();
   812 	IMPORT_C TInt Bind(TSockAddr& anAddr);
   813 	IMPORT_C TInt SetLocalPort(TInt aPort);
   814 	IMPORT_C void Accept(RSocket& aBlankSocket,TRequestStatus& aStatus);
   815 	IMPORT_C void Accept(RSocket& aBlankSocket,TDes8& aConnectData,TRequestStatus& aStatus);
   816 	IMPORT_C void CancelAccept();
   817 	IMPORT_C TInt Listen(TUint qSize);
   818 	IMPORT_C TInt Listen(TUint qSize,const TDesC8& aConnectData);
   819 	IMPORT_C TInt SetOpt(TUint anOptionName,TUint anOptionLevel,const TDesC8& anOption=TPtrC8(NULL,0));
   820 	IMPORT_C TInt SetOpt(TUint anOptionName,TUint anOptionLevel,TInt anOption);
   821 	IMPORT_C TInt GetOpt(TUint anOptionName,TUint anOptionLevel,TDes8& anOption);
   822 	IMPORT_C TInt GetOpt(TUint anOptionName,TUint anOptionLevel,TInt& anOption);
   823 	IMPORT_C void Ioctl(TUint aCommand,TRequestStatus& aStatus,TDes8* aDesc=NULL,TUint aLevel=KLevelUnspecified);
   824 	IMPORT_C void CancelIoctl();
   825 	IMPORT_C TInt GetDisconnectData(TDes8& aDesc);
   826 	IMPORT_C void LocalName(TSockAddr& anAddr);
   827 	IMPORT_C TUint LocalPort();
   828 	IMPORT_C void RemoteName(TSockAddr& anAddr);
   829 	IMPORT_C void Close();
   830 	IMPORT_C void Shutdown(TShutdown aHow,TRequestStatus& aStatus);
   831 	IMPORT_C void Shutdown(TShutdown aHow,const TDesC8& aDisconnectDataOut,TDes8& aDisconnectDataIn,TRequestStatus& aStatus);
   832 	IMPORT_C void CancelAll();
   833 	IMPORT_C TInt Info(TProtocolDesc& aProtocol);
   834 	IMPORT_C TInt Name(TName& aName);
   835 	IMPORT_C TInt Transfer(RSocketServ& aServer, const TDesC& aName);
   836 	};
   837 
   838 class TNameRecord
   839 /** Contains the results of name queries.
   840 @publishedAll
   841 @released */
   842 	{
   843 public:
   844 	inline TNameRecord();
   845 
   846 	enum
   847 	{
   848 	EAlias=0x00000001,
   849 	EPartial=0x00000002, 	/*!< Indicates a partial (truncated) host name. */
   850 	
   851 	};
   852 	/** A host name
   853 
   854 	@see THostName */
   855 	THostName iName;
   856 	/** An address
   857 
   858 	@see TSockAddr */
   859 	TSockAddr iAddr;
   860 	/** Flags indicating some attribute about the name, i.e. EAlias */
   861 	TInt iFlags;
   862 	};
   863 
   864 /** Packages the TNameRecord class so that it can be passed between a client and
   865 the socket server.
   866 @publishedAll
   867 @released  */
   868 typedef TPckgBuf<TNameRecord> TNameEntry;
   869 
   870 class RHostResolver : public RSubSessionBase
   871 /** Provides an interface to host name resolution services, such as DNS, that may
   872 be provided by particular protocol modules.
   873 
   874 The interface provides functions to access the following facilities:
   875 
   876 Obtaining names from addresses.
   877 
   878 Obtaining addresses from names.
   879 
   880 Getting and setting local host name.
   881 
   882 Not all actual services provide all these facilities. You should also consult
   883 the documentation on the protocol you are intending to use. Functions return
   884 KErrNotSupported if the protocol does not support a given operation. Note
   885 that a description of the protocol family name resolution capabilities is
   886 available at run-time from TProtocolDesc::iNamingServices.
   887 
   888 Before using any service, a connection to a socket server session must be
   889 made.
   890 
   891 Each function is available in both synchronous and asynchronous versions.
   892 
   893 A single RHostResolver can only perform one request of any type at once. A
   894 client is panicked if it makes two requests.
   895 @publishedAll
   896 @released */
   897 	{
   898 public:
   899 	IMPORT_C TInt Open(RSocketServ& aSocketServer,TUint anAddrFamily,TUint aProtocol);
   900 	IMPORT_C TInt Open(RSocketServ& aSocketServer,TUint anAddrFamily,TUint aProtocol, RConnection& aConnection);
   901 	IMPORT_C void GetByName(const TDesC& aName,TNameEntry& aResult,TRequestStatus& aStatus);
   902 	IMPORT_C TInt GetByName(const TDesC& aName,TNameEntry& aResult);
   903 	IMPORT_C void Next(TNameEntry& aResult,TRequestStatus& aStatus);
   904 	IMPORT_C TInt Next(TNameEntry& aResult);
   905 	IMPORT_C void GetByAddress(const TSockAddr& anAddr,TNameEntry& aResult,TRequestStatus& aStatus);
   906 	IMPORT_C TInt GetByAddress(const TSockAddr& anAddr,TNameEntry& aResult);
   907 	IMPORT_C TInt GetHostName(TDes& aName);
   908 	IMPORT_C void GetHostName(TDes& aName,TRequestStatus& aStatus);
   909 	IMPORT_C TInt SetHostName(const TDesC& aName);
   910 	IMPORT_C void Close();
   911 	IMPORT_C void Cancel();
   912 
   913     IMPORT_C void Query(const TDesC8& aQuery, TDes8& aResult, TRequestStatus& aStatus);
   914     IMPORT_C TInt Query(const TDesC8& aQuery, TDes8& aResult);
   915     IMPORT_C void QueryGetNext(TDes8& aResult, TRequestStatus& aStatus);
   916     IMPORT_C TInt QueryGetNext(TDes8& aResult);
   917     IMPORT_C TInt SetOpt(TUint anOptionName,TUint anOptionLevel,const TDesC8& anOption=TPtrC8(NULL,0));
   918 
   919 private:
   920 	};
   921 
   922 /**
   923 Port number on service
   924 
   925 @publishedAll
   926 @released
   927 */
   928 typedef TPckgBuf<TInt> TPortNum;
   929 
   930 class RServiceResolver : public RSubSessionBase
   931 /** Provides an interface to resolver service names and ports.
   932 @publishedAll
   933 @released */
   934 	{
   935 public:
   936 	IMPORT_C TInt Open(RSocketServ& aSocketServer,TUint anAddrFamily,TUint sockType,TUint aProtocol);
   937 	IMPORT_C void GetByName(const TDesC& aName,TPortNum& aPort,TRequestStatus& aStatus);
   938 	IMPORT_C TInt GetByName(const TDesC& aName,TPortNum& aPort);
   939 	IMPORT_C void GetByNumber(const TUint aPort,TDes& aName,TRequestStatus& aStatus);
   940 	IMPORT_C TInt GetByNumber(const TUint aPort,TDes& aName);
   941 	IMPORT_C void RegisterService(const TDesC& aName,const TUint& aPort,TRequestStatus& aStatus);
   942 	IMPORT_C TInt RegisterService(const TDesC& aName,const TUint& aPort);
   943 	IMPORT_C void RemoveService(const TDesC& aName,const TUint& aPort,TRequestStatus& aStatus);
   944 	IMPORT_C TInt RemoveService(const TDesC& aName,const TUint& aPort);
   945 	IMPORT_C void Close();
   946 	IMPORT_C void Cancel();
   947 private:
   948 	};
   949 
   950 class RNetDatabase: public RSubSessionBase
   951 /** Provides an interface to network databases, such as LM-IAS with IrDA, that
   952 may be provided by particular protocol modules.
   953 
   954 Before making any queries, a connection to a socket server session must be
   955 made.
   956 
   957 Each function is available in both synchronous and asynchronous versions.
   958 
   959 A single RNetDatabase can only perform one request of any type at once. A
   960 client is panicked if it makes two requests.
   961 
   962 Particular database access services will specify the format of queries and
   963 of responses.
   964 @publishedAll
   965 @released */
   966 	{
   967 public:
   968 	IMPORT_C TInt Open(RSocketServ& aSocketServer,TUint anAddrFamily,TUint aProtocol);
   969 	IMPORT_C void Query(const TDesC8& aQuery,TDes8& aResult,TRequestStatus& aStat);
   970 	IMPORT_C TInt Query(const TDesC8& aQuery,TDes8& aResult);
   971 	IMPORT_C void Add(const TDesC8& anItem,TRequestStatus& aStat);
   972 	IMPORT_C TInt Add(const TDesC8& anItem);
   973 	IMPORT_C void Remove(const TDesC8& anItem,TRequestStatus& aStat);
   974 	IMPORT_C TInt Remove(const TDesC8& anItem);
   975 	IMPORT_C void Close();
   976 	IMPORT_C void Cancel();
   977 private:
   978 	};
   979 
   980 
   981 /**
   982 Default connection type
   983 @publishedAll
   984 @released
   985 */
   986 const TUint KConnectionTypeDefault = 0x0800;		// KAfInet is the default connection type
   987 
   988 
   989 class TConnPref;
   990 class TSubConnectionInfo;
   991 class TSubConnectionEvent;
   992 
   993 class RConnection : public RCommsSubSession
   994 /**
   995 
   996 The management interface for a network connection or subconnection.
   997 
   998 Provides clients with the following functionality:
   999 
  1000 Opening and closing the connection
  1001 
  1002 Starting a connection, which means associating it with a new underlying interface
  1003 
  1004 Attaching the RConnection instance to an existing interface
  1005 
  1006 Stopping the connection, which means disassociating it from the underlying
  1007 interface
  1008 
  1009 Obtaining progress information and notification during connection start-up
  1010 
  1011 Notifying when subconnections come up and go down
  1012 
  1013 Notifying when there is a service change for the connection
  1014 
  1015 Notifying when a given amount of data has been sent or received on a connection
  1016 or subconnection
  1017 
  1018 Reading CommDB fields specific to an active connection
  1019 
  1020 Collecting statistical information on the network connection and subconnections.
  1021 A UI component can display the collected statistical information in order
  1022 to allow the user to examine the status of connections. The information that
  1023 can be gathered is the following:
  1024 
  1025 All available internet access point names and internet access point 'friendly'
  1026 names as appropriate for each network (GPRS/UMTS) connection
  1027 
  1028 Enumerating the currently active connections and subconnections
  1029 
  1030 The current status of all network connections e.g. active/suspended
  1031 
  1032 The amount of data (in bytes) transferred uplink and downlink by the network
  1033 connection and subconnections
  1034 
  1035 The amount of time each network connection has been active (in seconds)
  1036 
  1037 The current status of the connection and subconnections with respect to data
  1038 transfer, i.e. active/inactive
  1039 
  1040 The Quality of Service profile associated with each Packet Data Protocol (GPRS/UMTS)
  1041 context, e.g. low/medium/high
  1042 
  1043 Note that several of the new functions are asynchronous. It is essential for
  1044 these calls that the client ensures that the parameters they pass to the RConnection
  1045 API remain in scope for the duration of the asynchronous call.
  1046 @publishedAll
  1047 @released since v7.0s */
  1048 	{
  1049 public:
  1050 	/** Identifies the intended use of the connection. */
  1051 	enum TConnAttachType
  1052 		{
  1053 		/** The application wishes to use the connection for normal data transfer, and
  1054 		the idle timers will take that into account. */
  1055 		EAttachTypeNormal,
  1056 		/** The system control type of application wishes to monitor the state of the connection
  1057 		without otherwise affecting it. In particular, the interface idle timers will
  1058 		not be affected. */
  1059 		EAttachTypeMonitor
  1060 		};
  1061 	/** Identifies the type of requirement for stopping the connection. */
  1062 	enum TConnStopType
  1063 		{
  1064 		/** Any sockets or host/service resolvers associated with this interface will be
  1065 		errored with KErrCancel. */
  1066 
  1067 		EStopNormal,
  1068 
  1069 		/** Any sockets or host/service resolvers associated with this interface will be
  1070 		errored with KErrConnectionTerminated and should clean up quietly without
  1071 		prompting the user. */
  1072 
  1073 		EStopAuthoritative
  1074 		};
  1075 
  1076 	/**
  1077 	Connection Management Interface
  1078 	*/
  1079 	IMPORT_C RConnection();
  1080 	IMPORT_C virtual ~RConnection();
  1081 	IMPORT_C TInt Open(RSocketServ& aSocketServer, TUint aConnectionType = KConnectionTypeDefault);
  1082 	IMPORT_C TInt Open(RSocketServ& aSocketServer, TName& aName);
  1083 	IMPORT_C void Close();
  1084 
  1085 	IMPORT_C void Start(TRequestStatus& aStatus);
  1086 	IMPORT_C void Start(TConnPref& aPref, TRequestStatus& aStatus);
  1087 	IMPORT_C TInt Start();
  1088 	IMPORT_C TInt Start(TConnPref& aPref);
  1089 	IMPORT_C TInt Stop();
  1090 	IMPORT_C TInt Stop(TConnStopType aStopType);
  1091 	IMPORT_C TInt Stop(TSubConnectionUniqueId aSubConnectionUniqueId);
  1092 	IMPORT_C TInt Stop(TSubConnectionUniqueId aSubConnectionUniqueId, TConnStopType aStopType);
  1093 
  1094 	IMPORT_C void WaitForIncoming(RSubConnection& aIncomingSubConnection, TRequestStatus& aStatus);
  1095 	IMPORT_C TInt WaitForIncoming(RSubConnection& aIncomingSubConnection);
  1096 	IMPORT_C void CancelWaitForIncoming();
  1097 
  1098 	IMPORT_C void ProgressNotification(TNifProgressBuf& aProgress, TRequestStatus& aStatus, TUint aSelectedProgress = KConnProgressDefault);
  1099 	IMPORT_C void ProgressNotification(TSubConnectionUniqueId aSubConnectionUniqueId, TNifProgressBuf& aProgress, TRequestStatus& aStatus, TUint aSelectedProgress = KConnProgressDefault);
  1100 	IMPORT_C void CancelProgressNotification();
  1101 	IMPORT_C void CancelProgressNotification(TSubConnectionUniqueId aSubConnectionUniqueId);
  1102 	IMPORT_C TInt Progress(TNifProgress& aProgress);
  1103 	IMPORT_C TInt Progress(TSubConnectionUniqueId aSubConnectionUniqueId, TNifProgress& aProgress);
  1104 	IMPORT_C TInt LastProgressError(TNifProgress& aProgress);
  1105 	IMPORT_C void ServiceChangeNotification(TUint32& aNewISPId, TDes& aNewServiceType, TRequestStatus& aStatus);
  1106 	IMPORT_C void CancelServiceChangeNotification();
  1107 
  1108 	
  1109 	/**
  1110 	@deprecated Since SymbianOS v9.5
  1111 	*/
  1112 	IMPORT_C TInt GetIntSetting(const TDesC& aSettingName, TUint32& aValue);
  1113 
  1114 	/**
  1115 	@deprecated Since SymbianOS v9.5
  1116 	*/
  1117 	IMPORT_C TInt GetBoolSetting(const TDesC& aSettingName, TBool& aValue);
  1118 
  1119 	/**
  1120 	@deprecated Since SymbianOS v9.5
  1121 	*/
  1122 	IMPORT_C TInt GetDesSetting(const TDesC& aSettingName, TDes8& aValue);
  1123 
  1124 	/**
  1125 	@deprecated Since SymbianOS v9.5
  1126 	*/
  1127 	IMPORT_C TInt GetDesSetting(const TDesC& aSettingName, TDes16& aValue);
  1128 
  1129 	/**
  1130 	@deprecated Since SymbianOS v9.5
  1131 	*/
  1132 	IMPORT_C TInt GetLongDesSetting(const TDesC& aSettingName, TDes& aValue);
  1133 
  1134 
  1135 	IMPORT_C TInt GetParameters(ESock::CCommsDataObjectBase& aDataObject);
  1136 	IMPORT_C TInt SetParameters(ESock::CCommsDataObjectBase& aDataObject);
  1137 
  1138 	IMPORT_C TInt Name(TName& aName);
  1139 
  1140 	IMPORT_C TInt EnumerateConnections(TUint& aCount);
  1141 	IMPORT_C TInt GetConnectionInfo(TUint aIndex, TDes8& aConnectionInfo);
  1142 
  1143 	IMPORT_C void AllInterfaceNotification(TDes8& aNotification, TRequestStatus& aStatus);
  1144 	IMPORT_C void CancelAllInterfaceNotification();
  1145 
  1146 	IMPORT_C void Ioctl(TUint aOptionLevel, TUint aOptionName, TRequestStatus& aStatus, TDes8* aDesc);
  1147 	IMPORT_C void Ioctl(TUint aOptionLevel, TUint aOptionName, TRequestStatus& aStatus);
  1148 	IMPORT_C void CancelIoctl();
  1149 	IMPORT_C TInt Control(TUint aOptionLevel, TUint aOptionName, TDes8& aOption);
  1150 	IMPORT_C TInt GetOpt(TUint aOptionLevel, TUint aOptionName, TInt& aOption);
  1151 	IMPORT_C TInt SetOpt(TUint aOptionLevel, TUint aOptionName, TInt aOption = 0);
  1152 
  1153 	IMPORT_C TInt Attach(const TDesC8& aConnectionInfo, TConnAttachType aAttachType);
  1154 
  1155 	IMPORT_C TInt EnumerateSubConnections(TUint& aCount);
  1156 	IMPORT_C TInt GetSubConnectionInfo(TDes8& aSubConnectionInfo);
  1157 	IMPORT_C TInt GetSubConnectionInfo(TUint aIndex, TDes8& aSubConnectionInfo);
  1158 	IMPORT_C void AllSubConnectionNotification(TSubConnectionNotificationBuf& aSubConnectionEvent, TRequestStatus& aStatus);
  1159 	IMPORT_C void CancelAllSubConnectionNotification();
  1160 
  1161 	IMPORT_C void DataTransferredRequest(TPckg<TUint>& aUplinkVolume, TPckg<TUint>& aDownlinkVolume, TRequestStatus& aStatus);
  1162 	IMPORT_C void DataTransferredRequest(TSubConnectionUniqueId aSubConnectionUniqueId, TPckg<TUint>& aUplinkVolume, TPckg<TUint>& aDownlinkVolume, TRequestStatus& aStatus);
  1163 	IMPORT_C void DataTransferredCancel();
  1164 	IMPORT_C void DataTransferredCancel(TSubConnectionUniqueId aSubConnectionUniqueId);
  1165 	IMPORT_C void DataSentNotificationRequest(TUint aThreshold, TPckg<TUint>& aUplinkVolume, TRequestStatus& aStatus);
  1166 	IMPORT_C void DataSentNotificationRequest(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aThreshold, TPckg<TUint>& aUplinkVolume, TRequestStatus& aStatus);
  1167 	IMPORT_C void DataSentNotificationCancel();
  1168 	IMPORT_C void DataSentNotificationCancel(TSubConnectionUniqueId aSubConnectionUniqueId);
  1169 	IMPORT_C void DataReceivedNotificationRequest(TUint aThreshold, TPckg<TUint>& aDownlinkVolume, TRequestStatus& aStatus);
  1170 	IMPORT_C void DataReceivedNotificationRequest(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aThreshold, TPckg<TUint>& aDownlinkVolume, TRequestStatus& aStatus);
  1171 	IMPORT_C void DataReceivedNotificationCancel();
  1172 	IMPORT_C void DataReceivedNotificationCancel(TSubConnectionUniqueId aSubConnectionUniqueId);
  1173 	IMPORT_C void IsConnectionActiveRequest(TUint aSecs, TPckg<TBool>& aState, TRequestStatus& aStatus);
  1174 	IMPORT_C void IsConnectionActiveCancel();
  1175 	IMPORT_C void IsSubConnectionActiveRequest(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aSecs, TPckg<TBool>& aState, TRequestStatus& aStatus);
  1176 	IMPORT_C void IsSubConnectionActiveCancel(TSubConnectionUniqueId aSubConnectionUniqueId);
  1177 
  1178 	TBool SameSession(TInt aSessionHandle);
  1179 private:
  1180 	TPckg<TUint32> iNewISPId;
  1181 	TUint32 iReserved[4];
  1182 	};
  1183 
  1184 class CSubConParameterSet : public XParameterSetBase
  1185 /** Base class for all RSubConnection parameter sets.
  1186 
  1187 THIS API IS DEPRECATED IN FAVOUR OF XParameterSet
  1188 
  1189 @publishedAll
  1190 @deprecated since v9.6 */
  1191 	{
  1192 public:
  1193 	IMPORT_C static CSubConParameterSet* NewL(const STypeId& aTypeId);
  1194 	virtual ~CSubConParameterSet();
  1195 
  1196 protected:
  1197 	CSubConParameterSet();
  1198 	};
  1199 
  1200 
  1201 class CSubConGenericParameterSet : public CSubConParameterSet
  1202 /** Base class for generic RSubConnection parameter sets.
  1203 
  1204 THIS API IS DEPRECATED IN FAVOUR OF XParameterSet
  1205 
  1206 @publishedAll
  1207 @deprecated since v9.6 */
  1208 	{
  1209 public:
  1210 	IMPORT_C ~CSubConGenericParameterSet();
  1211 
  1212 protected:
  1213 	IMPORT_C CSubConGenericParameterSet();
  1214 	};
  1215 
  1216 class CSubConExtensionParameterSet : public CSubConParameterSet
  1217 /** Base class for extended RSubConnection parameter sets.
  1218 
  1219 THIS API IS DEPRECATED IN FAVOUR OF XParameterSet
  1220 
  1221 @publishedAll
  1222 @deprecated since v9.6 */
  1223 	{
  1224 public:
  1225 	IMPORT_C ~CSubConExtensionParameterSet();
  1226 
  1227 protected:
  1228 	IMPORT_C CSubConExtensionParameterSet();
  1229 	};
  1230 
  1231 class RSubConParameterBundle;
  1232 class CSubConParameterBundle;
  1233 
  1234 const TInt32 KSubConnParamsInterfaceUid = 0x10204303;
  1235 const TInt32 KSubConnEventInterfaceUid = 0x10204305;
  1236 
  1237 const TInt32 KSubConnGenericParamsImplUid  = 0x10204304;
  1238 const TInt32 KSubConnGenericEventsImplUid  = 0x10204306;
  1239 
  1240 const TUint32 KSubConGlobalFamily 				= 0;
  1241 const TUint32 KSubConQoSFamily 					= 1;
  1242 const TUint32 KSubConAuthorisationFamily 		= 2;
  1243 const TUint32 KSubConnCallDescrParamsFamily 	= 3;
  1244 const TUint32 KSubConnContextDescrParamsFamily 	= 4;
  1245 
  1246 const TUint32 KSubConIPAddressInfoFamily 		= 5;
  1247 
  1248 const TInt32 KProtocolExtensionFamily 		= 6;
  1249 const TInt32 KFlowParametersFamily 		= 7;
  1250 class RParameterFamily;
  1251 
  1252 class CSubConParameterFamily : public CBase
  1253 /** Container of RSubConnection parameter sets.
  1254 
  1255 For each Parameter Type (Requested, Acceptable and Granted) it
  1256 contains one generic and 0..N extended parameter sets.
  1257 
  1258 Note:
  1259 a CSubConParameterBundle or RSubConParameterBundle object can take ownership of a 
  1260 CSubConParameterFamily object, in this case, when the bundle is destroyed, this 
  1261 family object will also be destroyed  (along with any parameter sets that are owned 
  1262 by the family).
  1263 
  1264 THIS API IS DEPRECATED IN FAVOUR OF RParameterFamily
  1265 
  1266 @publishedAll
  1267 @deprecated since v9.6 */
  1268 	{
  1269 public:
  1270 
  1271 	enum TParameterSetType
  1272          {
  1273          ERequested = 0,
  1274          EAcceptable = 1,
  1275 		 EGranted = 2,
  1276 		 ENumValues = 3 // The number of values in this enum
  1277          };
  1278 
  1279 public:
  1280 	IMPORT_C static CSubConParameterFamily* NewL(RSubConParameterBundle& aBundle, TUint32 aFamilyId);
  1281 	IMPORT_C static CSubConParameterFamily* LoadL(RSubConParameterBundle& aBundle, TPtrC8& aBuffer);
  1282 	IMPORT_C static CSubConParameterFamily* NewL(CSubConParameterBundle& aBundle, TUint32 aFamilyId);
  1283 	IMPORT_C static CSubConParameterFamily* LoadL(CSubConParameterBundle& aBundle, TPtrC8& aBuffer);
  1284 
  1285 public:
  1286 	IMPORT_C virtual ~CSubConParameterFamily();
  1287 	IMPORT_C void SetGenericSetL(CSubConGenericParameterSet& aGenericSet, TParameterSetType aType);
  1288 	IMPORT_C void AddExtensionSetL(CSubConExtensionParameterSet& aExtensionSet, TParameterSetType aType);
  1289 
  1290 	IMPORT_C CSubConExtensionParameterSet* FindExtensionSet(TUid aSetId, TParameterSetType aType);
  1291 	IMPORT_C CSubConExtensionParameterSet* FindExtensionSet(STypeId aSetId, TParameterSetType aType);
  1292 	IMPORT_C CSubConGenericParameterSet* GetGenericSet(TParameterSetType aType);
  1293 
  1294 	inline TUint32 Id();
  1295 
  1296 	IMPORT_C TUint Length() const;
  1297 	IMPORT_C TInt Load(TPtrC8& aDes);
  1298 	IMPORT_C TInt Store(TDes8& aDes) const;
  1299 	IMPORT_C void ClearAllParameters(TParameterSetType aType);
  1300 
  1301 	/**
  1302 	Copy the parameters of this CSubConParameterFamily to a RParameterFamily.
  1303 	@param aDest RParameterFamily object to copy to
  1304 	*/
  1305 	void CopyToFamilyL(RParameterFamily& aDest) const;
  1306 
  1307     /**
  1308 	Copy the parameters of this CSubConParameterFamily from a RParameterFamily.
  1309 	@param aSrc RParameterFamily object to copy from
  1310 	*/
  1311 	void CopyFromFamilyL(RParameterFamily& aSrc);
  1312 protected:
  1313 	IMPORT_C explicit CSubConParameterFamily(TUint32 aFamilyId);
  1314 	IMPORT_C void ConstructL(RSubConParameterBundle& aBundle);
  1315 	IMPORT_C void ConstructL(CSubConParameterBundle& aBundle);
  1316 
  1317 	IMPORT_C static TInt32 ExtractFamilyAndCreateBufferL(TPtrC8& aBuffer, TPtrC8& aContainerBuffer);
  1318 
  1319 private:
  1320 	const TUint32 iFamilyId;   // This member variable is accessed by an inline function ( Id () ).
  1321 	RMetaDataEComContainer iGenericSets;
  1322 protected:
  1323 	RMetaDataEComContainer iExtensionSets[ENumValues];
  1324 
  1325 	};
  1326 
  1327 class RParameterFamilyBundle;
  1328 class RSubConParameterBundle
  1329 /** Container for (bundle of) SubConnection parameter families.
  1330 
  1331 May contain and 0..N SubConnection parameter families.
  1332 
  1333 Note:
  1334 If the RSubConParameterBundle object takes ownership of any CSubConParameterFamily object, 
  1335 then when the bundle object is destroyed, any family owned by this object will also be 
  1336 destroyed.
  1337 
  1338 THIS API IS DEPRECATED IN FAVOUR OF RParameterFamilyBundle
  1339 
  1340 @publishedAll
  1341 @deprecated since v9.6 */
  1342 	{
  1343 public:
  1344 	IMPORT_C RSubConParameterBundle();
  1345 	IMPORT_C void Close();
  1346 
  1347 	IMPORT_C TUint Length() const;
  1348 	IMPORT_C TInt Load(const TDesC8& aDes);
  1349 	IMPORT_C TInt Store(TDes8& aDes) const;
  1350 	IMPORT_C void AddFamilyL(CSubConParameterFamily* aFamily);
  1351 	IMPORT_C CSubConParameterFamily* FindFamily(TUint32 aFamilyId);
  1352 	IMPORT_C void ClearAllParameters(CSubConParameterFamily::TParameterSetType aType);
  1353 
  1354     /**
  1355     Copy the contents of this parameter bundle to a RParameterFamilyBundle.
  1356 	@param aDest RParameterFamilyBundle to copy parameters to
  1357 	*/
  1358 	void CopyToFamilyBundleL(RParameterFamilyBundle& aDest) const;
  1359 
  1360 	/**
  1361 	Copy the contents of an RParameterFamilyBundle to this RSubConParameterBundle
  1362 	@param aSrc RParameterFamilyBundle to copy contents from
  1363 	*/
  1364 	void CopyFromFamilyBundleL(RParameterFamilyBundle& aSrc);
  1365 
  1366 protected:
  1367 	TInt CheckBundle() const;
  1368 private:
  1369 	RSubConParameterBundle(const RSubConParameterBundle& aBundle);
  1370 	RSubConParameterBundle& operator=(const RSubConParameterBundle& aBundle);
  1371 
  1372 private:
  1373 	mutable CSubConParameterBundle* iBundle;
  1374 	};
  1375 
  1376 
  1377 const TInt KNotificationEventMaxSize = 2048;
  1378 class TNotificationEventBuf : public TBuf8<KNotificationEventMaxSize>
  1379 /**
  1380 Buffer for Sub-connection event notiifcation
  1381 
  1382 @publishedAll
  1383 @released
  1384 */
  1385 	{
  1386 public:
  1387 	IMPORT_C TNotificationEventBuf();
  1388 	IMPORT_C ~TNotificationEventBuf();
  1389 
  1390 	IMPORT_C TBool IsGeneric() const;
  1391 	IMPORT_C TInt32 GroupId() const;
  1392 	IMPORT_C TUint32 Id() const;
  1393 	};
  1394 
  1395 #ifndef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
  1396 class CSubConNotificationEvent : public SMetaDataECom
  1397 #else
  1398 class CSubConNotificationEvent : public ESock::XEventBase
  1399 #endif // SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
  1400 	{
  1401 public:
  1402 	IMPORT_C static CSubConNotificationEvent* NewL(const STypeId& aTypeId);
  1403 	IMPORT_C static CSubConNotificationEvent* NewL(const TNotificationEventBuf& aEventBuffer);
  1404 
  1405 	IMPORT_C TBool IsGeneric() const;
  1406 	IMPORT_C TInt32 GroupId() const;
  1407 	IMPORT_C TUint32 Id() const;
  1408 
  1409 private:
  1410 	};
  1411 
  1412 class TSubConnOpen
  1413 /** @internalComponent */
  1414 	{
  1415 public:
  1416 	/** Defines the type of a subconnection	*/
  1417 	enum TSubConnType
  1418 		{
  1419 		EAttachToDefault, 	// will attach to the default sub connection
  1420 		ECreateNew, 		// will create a new sub connection
  1421 
  1422 		//private extension to subconnection openning modes below:
  1423 		EWaitForIncoming
  1424 		};
  1425 
  1426 	TSubConnType iType;
  1427 	TInt  iHandle;
  1428 	TInt  iReserved;
  1429 	};
  1430 
  1431 class RSubConnection : public RCommsSubSession
  1432 /** A Sub-Connection, a channel within a Connection. A representation of a channel between this device and remote devices with which we are communicating. This channel will be used by one or more sockets.
  1433  Depending on the state of the channel, it may not be possible to bind arbitary sockets into it.  Attempts to bind sockets from different protocol families to a single channel is an error, as each channel can only be used by one protocol family.
  1434  @note The sub-connection can represent a end-to-end channel and/or a channel from this device to an intermediate device (e.g an access server such as a GGSN which using UMTS and PDP contexts. Properties can be specified simultaneously on protocol and link level.)
  1435 
  1436 Before using any of these services, a connection to a socket server session
  1437 must have been made and the connection must be open.
  1438 
  1439 @publishedAll
  1440 @released Since v9.0*/
  1441 	{
  1442 public:
  1443     friend class RConnection;
  1444 
  1445 	enum TSubConnType
  1446 		{
  1447 		EAttachToDefault,
  1448 		ECreateNew,
  1449 		EWaitIncoming
  1450 		};
  1451 
  1452 	struct TEventFilter
  1453 		{
  1454 		inline TEventFilter(TInt32 aEventGroupId = KSubConnGenericEventsImplUid, TUint32 aEventMask = 0xffffffff);
  1455 		TInt32  iEventGroupUid;
  1456 		TUint32 iEventMask;
  1457 		};
  1458 
  1459 public:
  1460 	// Sub Connection Management
  1461 	IMPORT_C RSubConnection();
  1462 	IMPORT_C TInt Open(RSocketServ& aServer, TSubConnType aSubConnType, RConnection& aConnection);
  1463 	IMPORT_C void Close();
  1464 	IMPORT_C void Start(TRequestStatus& aStatus);
  1465 	IMPORT_C TInt Start();
  1466 	IMPORT_C TInt Stop();		
  1467 
  1468 	// Socket Management
  1469 	IMPORT_C void Add(RSocket& aSocket, TRequestStatus& aStatus);
  1470 	IMPORT_C void Remove(RSocket& aSocket, TRequestStatus& aStatus);
  1471 
  1472 	// QoS Properties (legacy bundles - to be deprecated)
  1473 	IMPORT_C TInt SetParameters(const RSubConParameterBundle& aParametersSet);
  1474 	IMPORT_C TInt GetParameters(RSubConParameterBundle& aParametersSet);
  1475 
  1476 	// QoS Properties (new prototype bundles)
  1477 	IMPORT_C TInt SetParameters(const RParameterFamilyBundle& aParametersSet);
  1478 	IMPORT_C TInt GetParameters(RParameterFamilyBundle& aParametersSet);
  1479 
  1480 	// Event Notification
  1481 	IMPORT_C void EventNotification(TNotificationEventBuf& aEventBuffer, TBool aGenericEventsOnly, TRequestStatus& aStatus);
  1482 	IMPORT_C void EventNotification(TNotificationEventBuf& aEventBuffer, TEventFilter aEventFilterList[], TUint aEventListLength, TRequestStatus& aStatus);
  1483 	IMPORT_C void CancelEventNotification();
  1484 
  1485 	// Generic Control
  1486 	IMPORT_C TInt Control(TUint aOptionLevel, TUint aOptionName, TDes8& aOption);
  1487 		
  1488 	//
  1489 	// IMPORT_C TInt Stop(TConnStopType aStopType);
  1490 	// IMPORT_C void ProgressNotification(TNifProgressBuf& aProgress, TRequestStatus& aStatus, TUint aSelectedProgress = KConnProgressDefault);
  1491 	// IMPORT_C void CancelProgressNotification();
  1492 	// IMPORT_C TInt Progress(TNifProgress& aProgress);
  1493 	// IMPORT_C void IsSubConnectionActiveRequest(TUint aSecs, TPckg<TBool>& aState, TRequestStatus& aStatus);
  1494 	// IMPORT_C void IsSubConnectionActiveCancel();	
  1495 	//	
  1496 
  1497 	TBool SameSession(TInt aSessionHandle);
  1498 
  1499 private:
  1500 	IMPORT_C TInt Open(RSocketServ& aServer, TSubConnOpen::TSubConnType aSubConnType, RConnection& aConnection);
  1501 
  1502 	//Note : Not used anywhere else in the code, kept in order to avoid the BC Break
  1503 	TInt iSpare;
  1504 };
  1505 
  1506 
  1507 class ByteOrder
  1508 /** Reverses the byte order in 16 and 32-bit values.
  1509 @publishedAll
  1510 @released */
  1511 	{
  1512 public:
  1513 	IMPORT_C static TUint32 Swap32(TUint32 aVal);
  1514 	IMPORT_C static TUint16 Swap16(TUint16 aVal);
  1515 	inline static TUint16 Swap16(TUint aVal);
  1516 	};
  1517 
  1518 class BigEndian
  1519 /** Inserts and extracts integers in big-endian format.
  1520 @publishedAll
  1521 @released */
  1522 	{
  1523 public:
  1524 	IMPORT_C static TUint32 Get32(const TUint8* aPtr);
  1525 	IMPORT_C static TUint16 Get16(const TUint8* aPtr);
  1526 	IMPORT_C static void Put32(TUint8* aPtr, TUint32 aVal);
  1527 	IMPORT_C static void Put16(TUint8* aPtr, TUint16 aVal);
  1528 	};
  1529 
  1530 class LittleEndian
  1531 /** Inserts and extracts integers in little-endian format.
  1532 @publishedAll
  1533 @released */
  1534 	{
  1535 public:
  1536 	IMPORT_C static TUint32 Get32(const TUint8* aPtr);
  1537 	IMPORT_C static TUint16 Get16(const TUint8* aPtr);
  1538 	IMPORT_C static void Put32(TUint8* aPtr, TUint32 aVal);
  1539 	IMPORT_C static void Put16(TUint8* aPtr, TUint16 aVal);
  1540 	};
  1541 
  1542 class TAccessPointInfo
  1543 /** Stores Access Point information.
  1544 @publishedAll
  1545 @released
  1546 */
  1547 	{
  1548 public:
  1549 	TAccessPointInfo(TUint aApId = 0);
  1550 
  1551 	TUint AccessPoint() const;
  1552 	void SetAccessPoint(TUint aAccessPoint);
  1553 
  1554 	TBool operator== (const TAccessPointInfo& aRhs) const;
  1555 private:
  1556 	TUint iAccessPointId;
  1557 	};
  1558 
  1559 
  1560 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
  1561 #include <es_sock_internal.h>
  1562 #include <es_sock_partner.h>
  1563 #endif
  1564 
  1565 #include <es_sock.inl>
  1566 
  1567 #endif	//__ES_SOCK_H__
  1568