williamr@2: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // in6_opt.h - new socket options and MEventService data e.g. williamr@2: // for accessing the network interface and route williamr@2: // information. williamr@2: // New socket options and MEventService data e.g. for accessing the network interface williamr@2: // and route information. williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file in6_opt.h williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: #ifndef __INSOCK_IN6_ROUTE_H__ williamr@2: #define __INSOCK_IN6_ROUTE_H__ williamr@2: williamr@2: #include williamr@2: williamr@2: williamr@2: // PS: I'm declaring the following rule: williamr@2: // ** Use socket option names above 0x1000 for all options defined in this file ** williamr@2: // (don't want to accidentally collide with in_sock.h, even though the probability is williamr@2: // small considering the number of different sockopt levels) williamr@2: williamr@2: williamr@2: // -- Socket option level: KSolInetIp -- williamr@2: williamr@2: /** williamr@2: Controls the use of Explicit Congestion Notification. Values: williamr@2: @li 0 = ECN disabled williamr@2: @li 1 = ECN enabled with ECT(1) williamr@2: @li 2 = ECN enabled with ECT(0) (recommended over ECT(1), because some implementations may williamr@2: not implement ECT(1)) williamr@2: williamr@2: See RFC 3168 for more information. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: const TUint KSoIpEcn = 0x1010; williamr@2: williamr@2: /** williamr@2: Next hop route selection. williamr@2: williamr@2: Set forces the next hop route selection on the flow. williamr@2: The option parameter is not used in set. williamr@2: williamr@2: Get returns information about the current next hop williamr@2: selection. The option parameter is TInetRouteInfo. williamr@2: williamr@2: If the link layer is using addresses, the information williamr@2: refers to neighbor cache entry. If the interface is not williamr@2: using link layer addresses, the returned information just williamr@2: describes the currently attached route entry. williamr@2: williamr@2: To be successful, the flow must be assigned to the williamr@2: interface and the source address must be set at the williamr@2: time of the call. williamr@2: williamr@2: This option is provided for hook implementations, for williamr@2: example ISATAP tunneling hook can use this¨to force williamr@2: next hop selection on the virtual interface to find the williamr@2: actual link layer address (= outer IPv4 address). williamr@2: */ williamr@2: const TUint KSoNextHop = 0x1011; williamr@2: williamr@2: williamr@2: // -- Socket option level: KSolInetTcp -- williamr@2: /** williamr@2: If set, only full-sized TCP segments are sent before closing the connection. This is like williamr@2: Nagle, but stricter. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: const TUint KSoTcpCork = 0x1020; williamr@2: williamr@2: /** williamr@2: Send only full-sized TCP segments. Separate option in addition to KSoTcpCork is needed for williamr@2: BSD compatibility. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: const TUint KSoTcpNoPush = 0x1021; williamr@2: williamr@2: /** williamr@2: Do not return from close immediately, but linger for given maximum time to wait that the williamr@2: send buffers are emptied. Socket option parameter is TSoTcpLingerOpt struct. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: const TUint KSoTcpLinger = 0x1022; williamr@2: williamr@2: williamr@2: /** williamr@2: Parameter struct for KSoTcpLinger socket option. The following combinations are possible: williamr@2: williamr@2: @li iOnOff == 0: Close() call returns immediately, but TCP still williamr@2: tries to transmit the data remaining in its send buffers. williamr@2: @li iOnOff == 1, iLinger == 0: Close() returns immediately, and the TCP sender discards williamr@2: all data in its send buffers. TCP RST is sent to the other end. Note: the TCP sender williamr@2: avoids the TIME_WAIT state. williamr@2: @li iOnOff == 1, iLinger > 0: Close() call blocks until the data in TCP send buffers williamr@2: is succesfully transmitted and the connection is graciously terminated. williamr@2: If the sender cannot transmit all data before the linger time expires, williamr@2: the Close() call wakes up, but the stack continues towards terminating the williamr@2: connection as usual. williamr@2: williamr@2: A similar structure is used in BSD Unix sockets, hence porting Unix apps using linger option williamr@2: should be straight forward. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: class TSoTcpLingerOpt williamr@2: { williamr@2: public: williamr@4: TInt iOnOff; //< 0=Linger off; nonzero=Linger on. williamr@4: TInt iLinger; //< Linger time in seconds. williamr@2: }; williamr@2: williamr@2: williamr@2: // -- Socket option level: KSolInetIfQuery -- williamr@2: williamr@2: // The options below are on KSolInetIfQuery level, although they use different option format williamr@2: // than the rest of the options. williamr@2: // There are no incoming parameters for these queries williamr@2: williamr@2: /** williamr@2: Return array of TInetInterfaceInfo objects as the response of GetOptions call. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: const TUint KSoInetInterfaceInfo = 0x1001; williamr@2: williamr@2: /** williamr@2: Return array of TInetAddressInfo objects as the response of GetOptions call. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: const TUint KSoInetAddressInfo = 0x1002; williamr@2: williamr@2: /** williamr@2: Return array of TInetRouteInfo objects as the response of GetOptions call. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: const TUint KSoInetRouteInfo = 0x1003; williamr@2: williamr@2: /** williamr@2: Information of an address attached to interface. williamr@2: Used by the event service (EClassAddress events) and KSoInetAddressInfo socket option. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: class TInetAddressInfo williamr@2: { williamr@2: public: williamr@4: TUint32 iInterface; //< Network interface index to which this address is bound. williamr@4: TIp6Addr iAddress; //< Prefix or Id part of the address described. williamr@4: TUint8 iPrefixLen; //< Length of the prefix part in bits. williamr@4: TUint32 iScopeId; //< ScopeId of this address. williamr@4: TUint32 iPrefLifetime; //< Remaining Preferred lifetime of this address. williamr@4: TUint32 iValidLifetime; //< Remaining Valid lifetime of this address. williamr@4: TUint iFlags; //< Is address entry for prefix or id, etc. See enum TFlags williamr@4: TUint iState; //< Address state, copied from TIp6AddressInfo, see enum TAddressState williamr@4: TUint iType; //< Address type copied from TIp6AddressInfo, see enum TAddressType williamr@4: TUint iGenerations; //< Number of times the address Id is generated (or randomly re-generated) williamr@4: TUint iNS; //< Number of neighbour solicitations sent for DAD. williamr@2: williamr@4: // Values used in iFlags field. williamr@2: enum TFlags williamr@2: { williamr@4: EF_Prefix = 0x1, //< This address entry specifies prefix williamr@4: EF_Id = 0x2, //< This address entry specifies id part of the address williamr@4: EF_Deprecated = 0x4 //< Address is deprecated williamr@2: }; williamr@2: williamr@4: // Values used in iState field. The field is directly copied from iface.cpp. williamr@2: enum TAddressState williamr@2: { williamr@4: ENoAddress = 0, //< 0 0 - unassigned initial state (no address present) williamr@4: EDuplicate = 1, //< 0 1 - address is duplicate williamr@4: EAssigned = 2, //< 1 0 - address fully available williamr@4: ETentative = 3 //< 1 1 - address is tentative (DAD in progress) williamr@2: }; williamr@2: williamr@4: // Values used in iType field. The field is directly copied from iface.cpp. williamr@2: enum TAddressType williamr@2: { williamr@4: EProxy = 2, //< Do DAD, is not for me (forward) williamr@4: EAnycast = 1, //< Don't do DAD, is for me address williamr@4: ENormal = 0 //< Do DAD, is for me williamr@2: }; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Information of a network interface. williamr@2: Used by event service (EClassInterface events) and KSoInetInterfaceInfo socket option. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: class TInetInterfaceInfo williamr@2: { williamr@2: public: williamr@2: TUint32 iIndex; williamr@4: TName iName; //< Interface name williamr@4: TInt iState; //< State williamr@4: TInt iSMtu; //< Maximum transmit unit size williamr@4: TInt iRMtu; //< Maximum receive unit size williamr@4: TInt iSpeedMetric; //< Metric - bigger is better williamr@4: TUint iFeatures; //< Feature flags williamr@4: TSockAddr iHwAddr; //< Hardware address williamr@2: williamr@4: // Possible interface states. williamr@4: // Can also have negative values when on error state. williamr@2: enum williamr@2: { williamr@4: IfState_READY = 0, //< Ready to receive data from protocol williamr@4: IfState_PENDING = 1, //< Not ready for data yet williamr@2: IfState_HOLD = 2 williamr@2: }; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Information of a route entry in IP stack. williamr@2: Used by event service (EClassRoute events) and KSoInetRouteInfo socket option. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: class TInetRouteInfo williamr@2: { williamr@2: public: williamr@4: TUint32 iIndex; //< Route index williamr@4: TUint iType; //< Type of route (kernel generated have 0 at the present) williamr@4: TUint iState; //< State of route (copied from iState in CIp6Route) williamr@4: TInt iMetric; //< Smaller is better (less hops and/or faster link) williamr@4: TUint32 iInterface; //< Network interface index of the route williamr@4: TIp6Addr iGateway; //< IP address of gateway (might be the interface) williamr@4: TIp6Addr iDstAddr; //< Destination network or host williamr@4: TUint8 iPrefixLen; //< Length of the route prefix in bits williamr@4: TUint32 iScopeId; //< Scope Id of this route williamr@4: TUint32 iLifetime; //< Route lifetime in seconds williamr@2: williamr@2: enum williamr@2: { williamr@4: EDeprecated = 0x80000000 //< This bit is set in iType if the route is deprecated williamr@2: }; williamr@2: williamr@4: // Values used in iState field williamr@2: enum TState williamr@2: { williamr@2: EIncomplete = 0, williamr@2: ELoopback = 1, williamr@2: EOnlink = 2, williamr@2: EGateway = 3, williamr@2: EAnycast = 5, williamr@2: ERedirect = 7, williamr@2: EReachable = 8, williamr@2: EStale = 16 williamr@2: }; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Information on a neighbour cache entry in the IP stack. williamr@2: Used by event service (EClassNeighbour events). williamr@4: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TInetNeighbourInfo williamr@2: { williamr@2: public: williamr@4: TUint32 iIndex; //< Route index. williamr@4: TIp6Addr iDstAddr; //< Neighbour's IP address. williamr@4: TUint iState; //< State of neigbour entry. @see TInetRouteInfo::TState. williamr@4: TInt iMetric; //< Smaller is better (less hops and/or faster link). williamr@4: TUint32 iInterface; //< Network interface index of the route. williamr@4: TUint32 iScopeId; //< Scope Id of this neighbour. williamr@4: TUint32 iLifetime; //< Cache entry lifetime in seconds. williamr@2: williamr@4: // Hardware address (e.g. Ethernet MAC). williamr@2: TBuf8 iHwAddr; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: For building an array on top of TDes8. This is like casting a TDes8 data pointer to an array, but williamr@2: it provides protection against array boundary violations, and some small helpful utilities. williamr@2: The motivation of this class is to help in handling the information accessed by MNetworkInfo williamr@2: interface. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: template class TOverlayArray williamr@2: { williamr@2: public: williamr@2: inline TOverlayArray(TDes8& aDes) : iDes(aDes) williamr@2: { } williamr@2: williamr@2: /** williamr@2: * Returns pointer to the given element location in the array. If the index exceeds the williamr@2: * maximum length of the array, NULL is returned. williamr@2: */ williamr@2: inline T* IndexPtr(TInt aIndex) williamr@2: { if (aIndex >= MaxLength()) return NULL; else return &((T*)iDes.Ptr())[aIndex]; } williamr@2: williamr@2: /** williamr@2: * Return the given element of the array. No boundary checking. williamr@2: */ williamr@2: inline T& operator[](TInt aIndex) williamr@2: { return ((T*)iDes.Ptr())[aIndex]; } williamr@2: williamr@2: /** williamr@2: * Returns the maximum length of the array in the number of array elements. williamr@2: */ williamr@2: inline TInt MaxLength() williamr@2: { return (iDes.MaxLength() / sizeof(T)); } williamr@2: williamr@2: /** williamr@2: * Returns the current length of the array in the number of array elements. williamr@2: * The length information is based williamr@2: * on the current underlaying descriptor length, which may not always be the desired result. williamr@2: */ williamr@2: inline TInt Length() williamr@2: { return (iDes.Length() / sizeof(T)); } williamr@2: williamr@2: /** williamr@2: * Set the length of the underlaying descriptor. The parameter is given in the number of array williamr@2: * elements, which is then multiplied by a length of one element to determine the needed williamr@2: * descriptor length. williamr@2: */ williamr@2: inline void SetLength(TInt aLength) williamr@2: { iDes.SetLength(aLength * sizeof(T)); } williamr@2: williamr@2: private: williamr@2: TDes8& iDes; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Information of a multicast group joined by the IP stack. This class is not currently williamr@2: used by socket options, only EClassMulticast events. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: class TInetMulticastInfo williamr@2: { williamr@2: public: williamr@4: TIp6Addr iMulticastGroup; //< IP address of the multicast group. williamr@4: TUint32 iInterface; //< Interface index of the group. williamr@4: TUint32 iLifetime; //< Lifetime of the group in seconds. williamr@2: }; williamr@2: williamr@2: williamr@2: // -- Socket option level: KSolInetIfCtrl -- williamr@2: williamr@2: /** williamr@2: Control the use of link-local addresses per interface. williamr@2: Argument: TSoInetIpv4LinkLocalInfo (SetOpt only). williamr@2: @publishedAll williamr@4: @released williamr@2: williamr@2: @capability ECapabilityNetworkControl Configuring IPv4 Link-local addresses is restricted. williamr@2: @ref RSocket::SetOpt() williamr@2: */ williamr@2: const TUint KSoIpv4LinkLocal = 0x1001; williamr@2: williamr@2: /** williamr@2: Used as a parameter in KSoIpv4LinkLocal. williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: class TSoInetIpv4LinkLocalInfo williamr@2: { williamr@2: public: williamr@4: TUint iInterface; //< Interface index to be affected. williamr@4: TUint iFlag; //< Indicates whether IPv4 link locals are used (0='no'; 1='yes'). williamr@2: }; williamr@2: williamr@2: #endif // __INSOCK_IN6_ROUTE_H__