1 // Copyright (c) 2004-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // in6_opt.h - new socket options and MEventService data e.g.
15 // for accessing the network interface and route
17 // New socket options and MEventService data e.g. for accessing the network interface
18 // and route information.
29 #ifndef __INSOCK_IN6_ROUTE_H__
30 #define __INSOCK_IN6_ROUTE_H__
35 // PS: I'm declaring the following rule:
36 // ** Use socket option names above 0x1000 for all options defined in this file **
37 // (don't want to accidentally collide with in_sock.h, even though the probability is
38 // small considering the number of different sockopt levels)
41 // -- Socket option level: KSolInetIp --
44 Controls the use of Explicit Congestion Notification. Values:
46 @li 1 = ECN enabled with ECT(1)
47 @li 2 = ECN enabled with ECT(0) (recommended over ECT(1), because some implementations may
50 See RFC 3168 for more information.
54 const TUint KSoIpEcn = 0x1010;
57 Next hop route selection.
59 Set forces the next hop route selection on the flow.
60 The option parameter is not used in set.
62 Get returns information about the current next hop
63 selection. The option parameter is TInetRouteInfo.
65 If the link layer is using addresses, the information
66 refers to neighbor cache entry. If the interface is not
67 using link layer addresses, the returned information just
68 describes the currently attached route entry.
70 To be successful, the flow must be assigned to the
71 interface and the source address must be set at the
74 This option is provided for hook implementations, for
75 example ISATAP tunneling hook can use this¨to force
76 next hop selection on the virtual interface to find the
77 actual link layer address (= outer IPv4 address).
79 const TUint KSoNextHop = 0x1011;
82 // -- Socket option level: KSolInetTcp --
84 If set, only full-sized TCP segments are sent before closing the connection. This is like
89 const TUint KSoTcpCork = 0x1020;
92 Send only full-sized TCP segments. Separate option in addition to KSoTcpCork is needed for
97 const TUint KSoTcpNoPush = 0x1021;
100 Do not return from close immediately, but linger for given maximum time to wait that the
101 send buffers are emptied. Socket option parameter is TSoTcpLingerOpt struct.
105 const TUint KSoTcpLinger = 0x1022;
109 Parameter struct for KSoTcpLinger socket option. The following combinations are possible:
111 @li <b>iOnOff == 0</b>: Close() call returns immediately, but TCP still
112 tries to transmit the data remaining in its send buffers.
113 @li <b>iOnOff == 1, iLinger == 0</b>: Close() returns immediately, and the TCP sender discards
114 all data in its send buffers. TCP RST is sent to the other end. Note: the TCP sender
115 avoids the TIME_WAIT state.
116 @li <b>iOnOff == 1, iLinger > 0</b>: Close() call blocks until the data in TCP send buffers
117 is succesfully transmitted and the connection is graciously terminated.
118 If the sender cannot transmit all data before the linger time expires,
119 the Close() call wakes up, but the stack continues towards terminating the
122 A similar structure is used in BSD Unix sockets, hence porting Unix apps using linger option
123 should be straight forward.
127 class TSoTcpLingerOpt
130 TInt iOnOff; //< 0=Linger off; nonzero=Linger on.
131 TInt iLinger; //< Linger time in seconds.
135 // -- Socket option level: KSolInetIfQuery --
137 // The options below are on KSolInetIfQuery level, although they use different option format
138 // than the rest of the options.
139 // There are no incoming parameters for these queries
142 Return array of TInetInterfaceInfo objects as the response of GetOptions call.
146 const TUint KSoInetInterfaceInfo = 0x1001;
149 Return array of TInetAddressInfo objects as the response of GetOptions call.
153 const TUint KSoInetAddressInfo = 0x1002;
156 Return array of TInetRouteInfo objects as the response of GetOptions call.
160 const TUint KSoInetRouteInfo = 0x1003;
163 Information of an address attached to interface.
164 Used by the event service (EClassAddress events) and KSoInetAddressInfo socket option.
168 class TInetAddressInfo
171 TUint32 iInterface; //< Network interface index to which this address is bound.
172 TIp6Addr iAddress; //< Prefix or Id part of the address described.
173 TUint8 iPrefixLen; //< Length of the prefix part in bits.
174 TUint32 iScopeId; //< ScopeId of this address.
175 TUint32 iPrefLifetime; //< Remaining Preferred lifetime of this address.
176 TUint32 iValidLifetime; //< Remaining Valid lifetime of this address.
177 TUint iFlags; //< Is address entry for prefix or id, etc. See enum TFlags
178 TUint iState; //< Address state, copied from TIp6AddressInfo, see enum TAddressState
179 TUint iType; //< Address type copied from TIp6AddressInfo, see enum TAddressType
180 TUint iGenerations; //< Number of times the address Id is generated (or randomly re-generated)
181 TUint iNS; //< Number of neighbour solicitations sent for DAD.
183 // Values used in iFlags field.
186 EF_Prefix = 0x1, //< This address entry specifies prefix
187 EF_Id = 0x2, //< This address entry specifies id part of the address
188 EF_Deprecated = 0x4 //< Address is deprecated
191 // Values used in iState field. The field is directly copied from iface.cpp.
194 ENoAddress = 0, //< 0 0 - unassigned initial state (no address present)
195 EDuplicate = 1, //< 0 1 - address is duplicate
196 EAssigned = 2, //< 1 0 - address fully available
197 ETentative = 3 //< 1 1 - address is tentative (DAD in progress)
200 // Values used in iType field. The field is directly copied from iface.cpp.
203 EProxy = 2, //< Do DAD, is not for me (forward)
204 EAnycast = 1, //< Don't do DAD, is for me address
205 ENormal = 0 //< Do DAD, is for me
211 Information of a network interface.
212 Used by event service (EClassInterface events) and KSoInetInterfaceInfo socket option.
216 class TInetInterfaceInfo
220 TName iName; //< Interface name
221 TInt iState; //< State
222 TInt iSMtu; //< Maximum transmit unit size
223 TInt iRMtu; //< Maximum receive unit size
224 TInt iSpeedMetric; //< Metric - bigger is better
225 TUint iFeatures; //< Feature flags
226 TSockAddr iHwAddr; //< Hardware address
228 // Possible interface states.
229 // Can also have negative values when on error state.
232 IfState_READY = 0, //< Ready to receive data from protocol
233 IfState_PENDING = 1, //< Not ready for data yet
240 Information of a route entry in IP stack.
241 Used by event service (EClassRoute events) and KSoInetRouteInfo socket option.
248 TUint32 iIndex; //< Route index
249 TUint iType; //< Type of route (kernel generated have 0 at the present)
250 TUint iState; //< State of route (copied from iState in CIp6Route)
251 TInt iMetric; //< Smaller is better (less hops and/or faster link)
252 TUint32 iInterface; //< Network interface index of the route
253 TIp6Addr iGateway; //< IP address of gateway (might be the interface)
254 TIp6Addr iDstAddr; //< Destination network or host
255 TUint8 iPrefixLen; //< Length of the route prefix in bits
256 TUint32 iScopeId; //< Scope Id of this route
257 TUint32 iLifetime; //< Route lifetime in seconds
261 EDeprecated = 0x80000000 //< This bit is set in iType if the route is deprecated
264 // Values used in iState field
280 Information on a neighbour cache entry in the IP stack.
281 Used by event service (EClassNeighbour events).
285 class TInetNeighbourInfo
288 TUint32 iIndex; //< Route index.
289 TIp6Addr iDstAddr; //< Neighbour's IP address.
290 TUint iState; //< State of neigbour entry. @see TInetRouteInfo::TState.
291 TInt iMetric; //< Smaller is better (less hops and/or faster link).
292 TUint32 iInterface; //< Network interface index of the route.
293 TUint32 iScopeId; //< Scope Id of this neighbour.
294 TUint32 iLifetime; //< Cache entry lifetime in seconds.
296 // Hardware address (e.g. Ethernet MAC).
297 TBuf8<KMaxSockAddrSize> iHwAddr;
302 For building an array on top of TDes8. This is like casting a TDes8 data pointer to an array, but
303 it provides protection against array boundary violations, and some small helpful utilities.
304 The motivation of this class is to help in handling the information accessed by MNetworkInfo
309 template<class T> class TOverlayArray
312 inline TOverlayArray(TDes8& aDes) : iDes(aDes)
316 * Returns pointer to the given element location in the array. If the index exceeds the
317 * maximum length of the array, NULL is returned.
319 inline T* IndexPtr(TInt aIndex)
320 { if (aIndex >= MaxLength()) return NULL; else return &((T*)iDes.Ptr())[aIndex]; }
323 * Return the given element of the array. No boundary checking.
325 inline T& operator[](TInt aIndex)
326 { return ((T*)iDes.Ptr())[aIndex]; }
329 * Returns the maximum length of the array in the number of array elements.
331 inline TInt MaxLength()
332 { return (iDes.MaxLength() / sizeof(T)); }
335 * Returns the current length of the array in the number of array elements.
336 * The length information is based
337 * on the current underlaying descriptor length, which may not always be the desired result.
340 { return (iDes.Length() / sizeof(T)); }
343 * Set the length of the underlaying descriptor. The parameter is given in the number of array
344 * elements, which is then multiplied by a length of one element to determine the needed
347 inline void SetLength(TInt aLength)
348 { iDes.SetLength(aLength * sizeof(T)); }
356 Information of a multicast group joined by the IP stack. This class is not currently
357 used by socket options, only EClassMulticast events.
361 class TInetMulticastInfo
364 TIp6Addr iMulticastGroup; //< IP address of the multicast group.
365 TUint32 iInterface; //< Interface index of the group.
366 TUint32 iLifetime; //< Lifetime of the group in seconds.
370 // -- Socket option level: KSolInetIfCtrl --
373 Control the use of link-local addresses per interface.
374 Argument: TSoInetIpv4LinkLocalInfo (SetOpt only).
378 @capability ECapabilityNetworkControl Configuring IPv4 Link-local addresses is restricted.
379 @ref RSocket::SetOpt()
381 const TUint KSoIpv4LinkLocal = 0x1001;
384 Used as a parameter in KSoIpv4LinkLocal.
388 class TSoInetIpv4LinkLocalInfo
391 TUint iInterface; //< Interface index to be affected.
392 TUint iFlag; //< Indicates whether IPv4 link locals are used (0='no'; 1='yes').
395 #endif // __INSOCK_IN6_ROUTE_H__