1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "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 // IPv6/IPv4 socket library public header
31 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
32 #include <in_sock_internal.h>
36 * @name TCP/IP Protocol and address family
38 * The TCP/IP stack supports two different address formats
39 * in the TInetAddr: KAfInet for plain IPv4 addresses (for
40 * backward compatibility), and KAfInet6 for both IPv6 and
43 * Only the KAfInet is used as a <em>protocol family</em> constant
44 * for the TCP/IP protocol family, when sockets are opened
45 * (RSocket::Open() and RHostResolver::Open() ).
47 * KAfInet6 is only <em>address family</em>, and can only appear
48 * as a family constant in TSockAddr class.
53 /** Identifies the TCP/IP protocol family and v4 address family.
57 const TUint KAfInet = 0x0800;
58 /** Identifies the TCP/IP v6 address family.
63 const TUint KAfInet6 = 0x0806;
67 * @name IP protocol IDs
68 * @ingroup ip_packet_formats
72 * Identifies the ICMP protocol.
74 * @capability NetworkServices Required for opening 'icmp' sockets.
75 * @ref RSocket::Open()
77 const TUint KProtocolInetIcmp = 1;
80 * Identifies the TCP protocol.
82 * @capability NetworkServices Required for opening 'tcp' sockets.
83 * @ref RSocket::Open()
85 const TUint KProtocolInetTcp = 6;
88 * Identifies the UDP protocol.
90 * @capability NetworkServices Required for opening 'udp' sockets.
91 * @ref RSocket::Open()
93 const TUint KProtocolInetUdp = 17;
95 /** IPv6 inside IP (v4 or v6). @since 7.0 */
96 const TUint KProtocolInet6Ipip = 41;
98 /** Identifies the ICMPv6 protocol.
101 * @capability NetworkServices Required for opening 'icmp6' sockets.
102 * @ref RSocket::Open()
104 const TUint KProtocolInet6Icmp = 58;
108 * @name Internal Protocol IDs
109 * Internal protocol id's do not appear in real
110 * packets. An internal id only identifies a protocol
115 * Identifies the IP (v4) protocol module.
117 * @capability NetworkControl Required for opening 'ip' sockets.
118 * @ref RSocket::Open()
120 const TUint KProtocolInetIp = 0x100;
123 * Identifies the IP (v6) protocol module.
126 * @capability NetworkControl Required for opening 'ip6' sockets.
127 * @ref RSocket::Open()
129 const TUint KProtocolInet6Ip = 0xF00;
131 /** Unknown Protocol ID. @deprecated (never use in anything that binds to IP) */
132 const TUint KProtocolUnknown = 0xdead;
136 /** @name Socket option/ioctl levels */
138 /** ICMP socket option level (no options). */
139 const TUint KSolInetIcmp = 0x101;
140 /** TCP socket options level. */
141 const TUint KSolInetTcp = 0x106;
142 /** UDP socket options level. */
143 const TUint KSolInetUdp = 0x111;
144 /** IP socket options level. */
145 const TUint KSolInetIp = 0x100;
146 /** Interface control socket options level. */
147 const TUint KSolInetIfCtrl = 0x201;
148 /** Route control socket options level. */
149 const TUint KSolInetRtCtrl = 0x202;
150 /** DNS control socket options level. @removed */
151 const TUint KSolInetDnsCtrl = 0x204;
152 /** Interface query socket options level. @since 7.0 */
153 const TUint KSolInetIfQuery = 0x206;
154 #ifdef SYMBIAN_DNS_PUNYCODE
155 /** DNS set options level. */
156 /**using a new constant instead of KSolInetDnsCtrl
158 const TUint KSolInetDns = 0x208;
159 #endif //SYMBIAN_DNS_PUNYCODE
162 /** Maximum IPv4 address length (bits). */
163 const TInt KInetAddrMaxBits = 32;
164 /** Maximum IPv6 address length (bits). */
165 const TInt KInet6AddrMaxBits = 128;
167 /** @name Port constants */
169 /** Any port flag (0). */
170 const TUint KInetPortAny = 0x0000;
171 /** No port flag (0). */
172 const TUint KInetPortNone = 0x0000;
173 /** Minimum value of an automatically allocated port. */
174 const TUint KInetMinAutoPort = 32768;
175 /** Maximum value of an automatically allocated port. */
176 const TUint KInetMaxAutoPort = 60999;
179 /** @name IPv4 address constants and definitions */
183 * Forms a 32-bit integer IPv4 address from the normal dotted-decimal representation.
185 * The four arguments are the four parts of the IPv4 address.
190 * const TUint32 KInetAddr = INET_ADDR(194,129,2,54);
191 * addr.SetAddress(KInetAddr);
194 #define INET_ADDR(a,b,c,d) (TUint32)((((TUint32)(a))<<24)|((b)<<16)|((c)<<8)|(d))
196 /** Any address flag (0.0.0.0). */
197 const TUint32 KInetAddrAny = INET_ADDR(0,0,0,0);
198 /** No address flag (0.0.0.0). */
199 const TUint32 KInetAddrNone = INET_ADDR(0,0,0,0);
200 /** All addresses mask (255.255.255.255). */
201 const TUint32 KInetAddrAll = INET_ADDR(255,255,255,255);
202 /** Broadcast address (255.255.255.255). */
203 const TUint32 KInetAddrBroadcast = INET_ADDR(255,255,255,255);
204 /** Loopback address (127.0.0.1). */
205 const TUint32 KInetAddrLoop = INET_ADDR(127,0,0,1);
207 /** Group address range start. */
208 const TUint32 KInetAddrGroupUnspec = INET_ADDR(224,0,0,0);
209 /** All hosts address (224.0.0.1). */
210 const TUint32 KInetAddrGroupAllHosts = INET_ADDR(224,0,0,1);
211 /** Link-local net number. @since 7.0s */
212 const TUint32 KInetAddrLinkLocalNet = INET_ADDR(169,254,0,0);
213 /** Link-local net mask. @since 7.0s */
214 const TUint32 KInetAddrLinkLocalNetMask = INET_ADDR(255,255,0,0);
216 /** All addresses mask (0.0.0.0). */
217 const TUint32 KInetAddrMaskAll = INET_ADDR(0,0,0,0);
218 /** All bits mask (255.255.255.255). */
219 const TUint32 KInetAddrMaskHost = INET_ADDR(255,255,255,255);
221 /** Class A net mask (255.0.0.0). */
222 const TUint32 KInetAddrNetMaskA = INET_ADDR(255,0,0,0);
223 /** Class A host mask (0.255.255.255). */
224 const TUint32 KInetAddrHostMaskA = ~KInetAddrNetMaskA;
225 /** Number of bits to right-shift a Class A address to obtain the network number. */
226 const TInt KInetAddrShiftA = 24;
227 /** Class B net mask (255.255.0.0). */
228 const TUint32 KInetAddrNetMaskB = INET_ADDR(255,255,0,0);
229 /** Class B host mask (0.0.255.255). */
230 const TUint32 KInetAddrHostMaskB = ~KInetAddrNetMaskB;
231 /** Number of bits to right-shift a Class B address to obtain the network number. */
232 const TInt KInetAddrShiftB = 16;
233 /** Class C net mask (255.255.255.0). */
234 const TUint32 KInetAddrNetMaskC = INET_ADDR(255,255,255,0);
235 /** Class C host mask (0.0.0.255). */
236 const TUint32 KInetAddrHostMaskC = ~KInetAddrNetMaskC;
237 /** Number of bits to right-shift a Class C address to obtain the network number. */
238 const TInt KInetAddrShiftC = 8;
241 const TUint32 KInetAddrIdMaskA = 0x80000000;
243 const TUint32 KInetAddrIdValA = 0x00000000;
245 const TUint32 KInetAddrIdMaskB = 0xc0000000;
247 const TUint32 KInetAddrIdValB = 0x80000000;
249 const TUint32 KInetAddrIdMaskC = 0xe0000000;
251 const TUint32 KInetAddrIdValC = 0xc0000000;
253 const TUint32 KInetAddrIdMaskD = 0xf0000000;
255 const TUint32 KInetAddrIdValD = 0xe0000000;
257 const TUint32 KInetAddrIdMaskE = 0xf8000000;
259 const TUint32 KInetAddrIdValE = 0xf0000000;
267 EInetClassUnknown = 0,
273 EInetMulticast = EInetClassD,
274 EInetExperimental = EInetClassE
280 * IPv4 socket address.
282 * This exists for backward compatibility. SInet6Addr is
283 * the preferred format for both IPv4 and IPv6 addresses
290 /** Plain IPv4 address */
297 * The 128 bits of IPv6 or IPv4 address stored in network byte order.
299 * IPv4 addresses are stored in IPv4 mapped format.
307 IMPORT_C TBool IsUnicast() const;
308 IMPORT_C TBool IsMulticast() const;
309 IMPORT_C TBool IsLoopback() const;
310 IMPORT_C TBool IsUnspecified() const;
311 IMPORT_C TBool IsLinkLocal() const;
312 IMPORT_C TBool IsSiteLocal() const;
313 IMPORT_C TBool IsV4Compat() const;
314 IMPORT_C TBool IsV4Mapped() const;
315 IMPORT_C TBool IsEqual(const TIp6Addr &aAddr) const;
316 IMPORT_C TInt Match(const TIp6Addr &aAddr) const;
317 IMPORT_C TInt Scope() const;
328 * IPv4 and IPv6 socket address.
330 * Defines the address information inside the TInetAddr.
339 /** 16 bytes of IP6/IP4 address (128 bits) */
341 /** 4 bytes of Flow Id */
343 /** 4 bytes of Scope Id. */
348 * @name IPv6 address constants..
352 /** Node-local scope level (RFC-2373 2.7). */
353 const TInt KIp6AddrScopeNodeLocal = 0x01;
354 /** Link-local scope level (RFC-2373 2.7). */
355 const TInt KIp6AddrScopeLinkLocal = 0x02;
356 /** Site-local scope level (RFC-2373 2.7). */
357 const TInt KIp6AddrScopeSiteLocal = 0x05;
358 /** Organisation-local scope level (RFC-2373 2.7). */
359 const TInt KIp6AddrScopeOrganization = 0x08;
360 /** Global scope level (RFC-2373 2.7). */
361 const TInt KIp6AddrScopeGlobal = 0x0E;
362 /** Network scope level (non-standard value, used internally) */
363 const TInt KIp6AddrScopeNetwork = 0x10;
365 /** No address (all 0s). */
366 const TIp6Addr KInet6AddrNone = {{{0}}};
367 /** Loopback address (::1). */
368 const TIp6Addr KInet6AddrLoop = {{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}};
369 /** Link-local address (prefix fe80::). */
370 const TIp6Addr KInet6AddrLinkLocal = {{{0xfe, 0x80, }}};
373 class TInetAddr : public TSockAddr
375 * This class specialises the generic socket server address class
376 * TSockAddr for the TCP/IP protocol family. It represents an IP
377 * address and stores either an IPv4 or an IPv6 address in its buffer
378 * after the generic data defined by TSockAddr. The protocol family
379 * field provided by the TSockAddr base class can be set to KAfInet,
380 * KAfInet6 or KAFUnspec.
382 * The address family defines the format of the stored address:
385 * is for plain 32 bits IPv4 address presented as SInetAddr
388 * is for both IPv4 and IPv6 addresses (IPv4 addresses
389 * are in IPv4 mapped format). The content is presented as
390 * SInet6Addr structure, which includes the scope id
391 * and flow label, in addition to the 128 address bits.
393 * does not contain any addresses and works in most
394 * contexts as unspecified address, This is better than
395 * placing explicit IPv4 "0.0.0.0" or IPv6 "::", which
396 * in certain situations may limit the connections to either
397 * IPv4 or IPv6, but not both.
399 * The flow label and scope id fields exist only in KAfInet6
400 * format. However, the access functions TInetAddr::FlowLabel
401 * and TInetAddr::Scope will also work for other address formats
402 * by always returning 0.
404 * Any function which sets or changes the address bits, will
405 * always reset the scope id and flow label to 0 (the
406 * TInetAddr::Init is always called internally). These are
407 * reasonable defaults, and normal application user does not
408 * normally need to worry about flow label or scope id.
410 * When address is returned from the stack, it will often
411 * be in KAfInet6 format, and may contain non-zero values
412 * for flow label and scope id fields. When copying addresses,
413 * the full TInetAddr (or at least SInet6Addr) should be
414 * copied to preserve these fields.
419 * The IPv4 only portion is backward compatible with
420 * older versions. In 7.0s some functions have additional
425 IMPORT_C TInetAddr();
426 IMPORT_C TInetAddr(const TSockAddr& aAddr);
427 IMPORT_C TInetAddr(TUint aPort);
428 IMPORT_C TInetAddr(const TIp6Addr &aAddr, TUint aPort);
429 IMPORT_C TInetAddr(TUint32 aAddr, TUint aPort);
430 IMPORT_C void SetAddress(TUint32 aAddr);
431 IMPORT_C void SetAddress(const TIp6Addr &aAddr);
432 IMPORT_C void SetV4CompatAddress(TUint32 aAddr);
433 IMPORT_C void SetV4MappedAddress(TUint32 aAddr);
434 IMPORT_C void SetFlowLabel(TInt aLabel);
435 IMPORT_C TInt FlowLabel() const;
436 IMPORT_C const TIp6Addr &Ip6Address() const;
437 IMPORT_C void ConvertToV4Compat();
438 IMPORT_C void ConvertToV4Mapped();
439 IMPORT_C void ConvertToV4();
440 IMPORT_C TBool CmpAddr(const TInetAddr& aAddr) const;
441 IMPORT_C TBool Match(const TInetAddr& aHost) const;
442 IMPORT_C TBool Match(const TInetAddr& aNet, const TInetAddr& aMask) const;
443 IMPORT_C TBool Match(const TInetAddr& aNet, TInt aPrefixLen) const;
444 IMPORT_C void PrefixMask(TInt aPrefixLen);
445 IMPORT_C void Prefix(const TInetAddr& aAddr, TInt aPrefixLen);
446 IMPORT_C void Output(TDes &aBuf) const;
447 IMPORT_C TInt Input(const TDesC &aBuf);
448 inline static TInetAddr& Cast(const TSockAddr& aAddr);
449 inline static TInetAddr& Cast(const TSockAddr* aAddr);
451 IMPORT_C TBool IsUnicast() const;
452 IMPORT_C TBool IsMulticast() const;
453 IMPORT_C TBool IsLoopback() const;
454 IMPORT_C TBool IsUnspecified() const;
455 IMPORT_C TBool IsLinkLocal() const;
456 IMPORT_C TBool IsSiteLocal() const;
457 IMPORT_C TBool IsV4Compat() const;
458 IMPORT_C TBool IsV4Mapped() const;
460 IMPORT_C TUint32 Address() const;
461 IMPORT_C void NetMask(const TInetAddr& aAddr);
462 IMPORT_C void Net(const TInetAddr& aAddr);
463 IMPORT_C void NetBroadcast(const TInetAddr& aAddr);
464 IMPORT_C void SubNet(const TInetAddr& aAddr, const TInetAddr& aMask);
465 IMPORT_C void SubNetBroadcast(const TInetAddr& aAddr, const TInetAddr& aMask);
467 inline TBool IsClassA() const;
468 inline TBool IsClassB() const;
469 inline TBool IsClassC() const;
470 inline TBool IsBroadcast() const;
471 inline TBool IsWildAddr() const;
472 inline TBool IsWildPort() const;
474 IMPORT_C void SetScope(TUint32 aScope);
475 IMPORT_C TUint32 Scope() const;
477 IMPORT_C void Init(TUint aFamily);
478 IMPORT_C void OutputWithScope(TDes &aBuf) const;
480 inline SInetAddr *Addr4Ptr() const;
481 inline SInet6Addr *AddrPtr() const;
482 inline static TInt AddrLen();
484 TInt Ipv4Input(const TDesC& aDes);
485 TInt Ipv6Input(const TDesC& aDes);
488 inline SInet6Addr* TInetAddr::AddrPtr() const
489 /** Returns a pointer to #KAfInet6 content format. */
490 { return (SInet6Addr*)UserPtr(); }
492 inline TInt TInetAddr::AddrLen()
493 /** Returns the size of the #KAfInet6 content format. */
494 { return sizeof(SInet6Addr); }
496 inline TInetAddr& TInetAddr::Cast(const TSockAddr& aAddr)
498 * Casts a TSockAddr to a TInetAddr reference.
500 * The cast is only safe if the object being referenced is actually aTInetAddr.
502 * @param aAddr TSockAddr to cast
503 * @return Casted reference to a TInetAddr.
505 { return *((TInetAddr*)&aAddr); }
507 inline TInetAddr& TInetAddr::Cast(const TSockAddr* aAddr)
509 * Casts a TSockAddr to a TInetAddr reference.
511 * The cast is only safe if the object being referenced is actually aTInetAddr.
513 * @param aAddr TSockAddr to cast
514 * @return Casted pointer to a TInetAddr.
516 { return *((TInetAddr*)aAddr); }
518 inline SInetAddr* TInetAddr::Addr4Ptr() const
519 /** Returns a pointer to #KAfInet content format */
520 { return (SInetAddr*)UserPtr(); }
522 inline TBool TInetAddr::IsBroadcast() const
524 * Tests if the IP address is a limited broadcast address (255.255.255.255).
526 * @return ETrue if the IPv4 address value is a limited broadcast address; otherwise, EFalse
528 { return Address() == KInetAddrBroadcast; }
530 inline TBool TInetAddr::IsWildPort() const
532 * Tests if the port is zero.
534 * @return ETrue if the port is zero; otherwise, EFalse.
536 { return Port() == KInetPortNone; }
538 inline TBool TInetAddr::IsWildAddr() const
540 * Tests if the IP address is unspecified.
542 * This is same as IsUnspecified()
544 * @return ETrue if the IP address value is unspecified; otherwise, EFalse.
546 { return IsUnspecified(); }
548 inline TBool TInetAddr::IsClassA() const
550 * Tests if the IP address is Class A.
552 * @return ETrue if the IPv4 address value is Class A; otherwise, EFalse
554 * @deprecated Works only for IPv4. It assumes the old IPv4 address classes
555 * (A, B, C). Applications using this function may not work properly in the
556 * current internet environment.
559 return (Family() == KAfInet || IsV4Mapped() || IsV4Compat()) && (Address() & KInetAddrIdMaskA) == KInetAddrIdValA;
562 inline TBool TInetAddr::IsClassB() const
564 * Tests if the IP address is Class B.
566 * @return ETrue if the IPv4 address value is Class B; otherwise. EFalse
568 * @deprecated Works only for IPv4. It assumes the old IPv4 address classes
569 * (A, B, C). Applications using this function may not work properly in the
570 * current internet environment.
572 { return (Address() & KInetAddrIdMaskB) == KInetAddrIdValB; }
574 inline TBool TInetAddr::IsClassC() const
576 * Tests if the IP address is Class C.
578 * @return ETrue if the IPv4 address value is Class C; otherwise, EFalse
579 * @deprecated Works only for IPv4. It assumes the old IPv4 address classes
580 * (A, B, C). Applications using this function may not work properly in the
581 * current internet environment.
583 { return (Address() & KInetAddrIdMaskC) == KInetAddrIdValC; }
586 * @name Send/Recv flags (datagram sockets only)
589 /** Don't fragment the packet.
591 * If the packet would require fragmentation due to a small
592 * maximum transmission unit size (MTU), the packet is dropped
593 * and an ICMP error message is generated: for ICMPv4 type=3 and code=4
594 * (#KInet4ICMP_Unreachable); and for ICMPv6 type=2 and code=0
595 * (#KInet6ICMP_PacketTooBig).
597 * Application must enable #KSoInetLastError to detect this situation.
599 const TUint KIpDontFragment = 0x010000;
601 * Packet includes IP or IPv6 header.
603 * When reading, the returned buffer starts with the received
604 * IP header, which can be either IPv6 (TInet6HeaderIP4) or
605 * IPv4 (TInet6HeaderIP).
607 * When writing buffers, the buffer must start with the IP
608 * header and it must be complete. The stack does not
609 * provide any defaults.
611 * @sa KSoRawMode, KSoHeaderIncluded
613 const TUint KIpHeaderIncluded = 0x020000;
615 * Don't route the packet.
617 * Not supported in Symbian 7.0 and 7.0s.
619 const TUint KIpDontRoute = 0x040000;
624 * @name Interface control socket options
626 * Level: #KSolInetIfCtrl
628 * Enumerating & Configuring Interfaces using TSoInetInterfaceInfo and TSoInet6InterfaceInfo.
632 * Begin enumeration of network interfaces.
634 * This option should be set before enumerating interfaces with #KSoInetNextInterface.
636 * This option is for use with RSocket::SetOpt() only.
638 const TInt KSoInetEnumInterfaces = 0x211;
640 * Return details of the next interface in an enumeration started by setting the
641 * option #KSoInetEnumInterfaces.
643 * This option is for use with RSocket::GetOpt() only.
645 * Option data type is TSoInetInterfaceInfo.
648 * If the interface has multiple addresses, then each address
649 * is returned as a separate instance of TSoInetInterfaceInfo
650 * (only address information is different each time).
652 * If the interface has no addresses, then one entry
653 * with unspecified address is returned.
655 const TInt KSoInetNextInterface = 0x212;
658 * Configures the interface.
660 * This option is for use with RSocket::SetOpt() only.
662 * Option data type is TSoInet6InterfaceInfo.
664 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
667 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
668 * @ref RSocket::SetOpt()
670 const TInt KSoInetConfigInterface = 0x213;
672 * Deletes the interface.
674 * This option is for use with RSocket::SetOpt() only.
676 * Option data type is TSoInet6InterfaceInfo.
678 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
681 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
682 * @ref RSocket::SetOpt()
684 const TUint KSoInetDeleteInterface = 0x214;
686 * Configure the interface details, if it exists.
688 * Option data type is TSoInet6InterfaceInfo.
690 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
693 * Unlike KSoInetConfigInterface, never creates a new interface
694 * entry, if one does not already exist. KSoInetConfigInterface
695 * never fails with interface not found, as it always finds or
699 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
700 * @ref RSocket::SetOpt()
702 const TUint KSoInetChangeInterface = 0x215;
704 * Resets interface to initial state.
706 * Delete all configuration (routes and addresses) from the
707 * interface. Any sockets (flows) currently using this interface,
708 * are set to holding state (#KSoNoInterfaceError is not required).
710 * The interface reconfigures, if the NIF driver
711 * calls CProtocolBase::StartSending(), or if
712 * #KSoInetStartInterface socket option is used.
714 * Option data type is TSoInet6InterfaceInfo.
716 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
717 * No other fields are used.
720 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
721 * @ref RSocket::SetOpt()
723 const TUint KSoInetResetInterface = 0x216;
725 * Restart interface, auto-reconfigure.
727 * Option data type is TSoInet6InterfaceInfo.
729 * The interface is specified by setting the TSoInetInterfaceInfo::iName,
730 * No other fields are used. The selected interface is autoconfigured using the
731 * information supplied by the attached network driver.
733 * Should normally only be called after #KSoInetResetInterface.
736 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
737 * @ref RSocket::SetOpt()
739 const TUint KSoInetStartInterface = 0x217;
742 * Trigger link local creation.
744 * Option data type is TSoInet6InterfaceInfo.
746 * The interface is specified by setting the TSoInetInterfaceInfo::iName and any state
747 * change required. Called by a configuration deamon to trigger IPv4 zeroconf and link
748 * local creation if no address server is found. Does nothing if
749 * EV4LLConfigDaemonControlled option is not specified for interface.
753 * @capability NetworkControl Modifying interfaces is allowed for authorized apps only.
754 * @ref RSocket::SetOpt()
756 const TUint KSoInetCreateIPv4LLOnInterface = 0x226;
759 * Describes the state of an interface.
761 * It is used as a data member of TSoInetInterfaceInfo.
764 * This enumeration is supported only because of backward
765 * compatibility. The real interface state uses the system
766 * error codes directly. The interface is either up
767 * (KErrNone) or down because of some error condition (state
768 * is one of the system wide error codes indicating the reason
769 * for the down state).
776 /** The interface has been initiated, but is not yet available. */
778 /** The interface is up and available. */
780 /** The interface is up, but flowed off. */
782 /** The interface is down. */
784 #ifdef SYMBIAN_TCPIPDHCP_UPDATE
786 /** The interface is not-configured */
788 #endif //SYMBIAN_TCPIPDHCP_UPDATE
791 class TSoInetInterfaceInfo
793 * Used when listing interfaces with socket option.
795 * Used with interface level #KSolInetIfCtrl option #KSoInetNextInterface.
797 * This is also a base class for the TSoInet6InterfaceInfo,
798 * which is used in modifying the interface configuration.
805 /** Ignored since 7.0. @removed The field exists, but it is ignored. */
807 /** Interface name */
809 /** Interface state. */
811 /** Maximum transmission unit (bytes) */
813 /** An approximation of the interface speed in Kbps. */
818 * Possible values are defined in in_iface.h.
821 /** Hardware address. */
823 /** Interface IP address. */
827 /** IP broadcast address. */
829 /** IP default gateway or peer address (if known). */
831 /** IP primary name server (if any). */
833 /** IP secondary name server (if any). */
837 class TSoInet6InterfaceInfo : public TSoInetInterfaceInfo
839 * Extension for TSoInetInterfaceInfo. Available in Symbian OS v7.0 and later.
841 * Used with the following interface level #KSolInetIfCtrl options:
842 * @li #KSoInetConfigInterface
843 * @li #KSoInetDeleteInterface
844 * @li #KSoInetChangeInterface
845 * @li #KSoInetResetInterface
846 * @li #KSoInetStartInterface
847 * @li #KSoInetCreateIPv4LLOnInterface
849 * The following configuration changes are only activated with
850 * #KSoInetConfigInterface and #KSoInetChangeInterface options.
851 * For these two, the extension specifies the details of actions
852 * to be performed. The extension is a collection of control bits,
853 * which can be grouped as
855 * @li modifiers (#iDelete and #iAlias)
856 * @li actions: #iDoState, #iDoId (with subactions #iDoAnycast or #iDoProxy) and #iDoPrefix.
858 * The effect of the modifiers depend on the chosen action (in some
859 * actions modifiers are ignored).
860 * The iDoState can be combined with any other actions, but for the
861 * remaining only the following combinations are valid:
864 * no address configuration: iDoId=0, iDoPrefix=0 (iDoProxy,
865 * iDoAnycast, iDelete and iAlias are ignored).
867 * configure single IPv6 or IPv4 address:
868 * iDoid, iAddress has the address, iNetMask unspecified.
870 * configure IPv6 id part: iDoId, iAddress is IPv6 address
871 * (<tt>fe80::id</tt>) and iNetMask defined (for 64 bits, use
872 * <tt>ffff:ffff:ffff:ffff::</tt>).
874 * configure IPv4 address and netmask: iDoId, iNetMask defined.
876 * configure IPv6 or IPv4 anycast address: iDoId, iDoAnycast,
877 * iAddress has the address (iNetMask ignored).
879 * configure IPv6 or IPv4 proxy address: iDoId, iDoProxy,
880 * iAddress has the address (iNetMask ignored).
882 * configure IPv6 prefix and id part: iDoId, iDoPrefix,
883 * iAddress is the IPv6 address (prefix::id) and iNetMask defined
884 * (for 64 bits, use <tt>ffff:ffff:ffff:ffff::</tt>).
886 * configure IPv6 prefix: iDoPrefix, iAddress is the prefix (prefix::)
887 * and iNetMask defined (for 64 bits, use <tt>ffff:ffff:ffff:ffff::</tt>).
889 * The default route is processed if #iDefGate is specified.
890 * If the gateway address is an IPv4 address, then it defines IPv4
891 * default route. Additionally, if the iDefGate is same as iAddress, then
892 * this is interpreted as a request to treat the default route as
893 * "onlink route" instead of the normal <em>gateway route</em>. #iDelete modifier
894 * controls whether default route is added or deleted.
896 * The MTU is updated, if #iMtu has non-zero value.
898 * Available in Symbian OS v9.2 and later.
900 * Used with the following interface level #KSolInetIfCtrl option:
901 * @li #KSoInetCreateIPv4LLOnInterface
903 * @li actions: #iDoState.
905 * This configuration acts as a notification from a config daemon to the IP stack
906 * which controls link local behaviour if the llv4linklocal=ELLV4ConfigDeamonControlled
907 * TCPIP.ini option is specified for the interface:
910 * notification from config daemon (e.g., DHCP) that address assignment terminated
911 * so a link local should be created if appropriate TCPIP.ini setting is used:
916 * @since 7.0 (some functionality only in 7.0s and >=9.3 for config daemon controlled link local creation)
921 * Add or delete modifier.
923 * 0 = add, 1 = delete
925 * Modifies the actions for address configuration (#iDoId, #iDoPrefix)
926 * and iDefGate processing (see detail descripton above).
930 * Primary or alias modifier.
932 * 0 = primary, 1 = alias.
935 * Always use 1 here (this is a relic, that most likely
936 * should be deprecated, and defaulted to 1 always).
940 * Prefix action (only for IPv6 addresses).
942 * 0 = don't do prefix, 1 = do the prefix.
944 * #iAddress must be specified.
946 * If set and iNetMask is defined, then #iNetMask and #iAddress
947 * define a prefix for the interface (link). If iNetMask is
948 * unspecified, then the iDoPrefix is ignored.
951 * Acts as if an IPv6 Router Advertisement with prefix option A=1
952 * and L=1 has arrived (e.g. this prefix can be used in address
953 * generation and all addresses with this prefix are onlink on
957 * The specified prefix is deleted from the interface (if it
961 * Current IPv6 specification allows only 64 for the number
968 * 0 = don't do address, 1= do the address.
970 * #iAddress must be specified.
973 * If also either #iDoAnycast or #iDoProxy is set, then
974 * the action is special for them (and the following
977 * If #iNetMask is unspecified, then #iAddress defines a single
978 * address (either IPv4 or IPv6) which is to be added or removed,
979 * depending on the state of the #iDelete modifier. #iAlias
982 * If #iNetMask is specified, then the following applies:
984 * @li iDelete=0 and iAddress is IPv4 address:
985 * iAddress and iNetMask are used to configure additional
986 * IPv4 address and netmask for the interface.
987 * @li iDelete=0 and iAddress is IPv6 address
988 * The iNetmask and iAddress define a ID part, which can be
989 * combined with any defined prefix to form a full IPv6 address.
990 * If iAlias is set, then a new ID is added; otherwise whatever
991 * happens to be stored in the primary id slot is overwritten
992 * (always use iAlias=1 to avoid confusion).
995 * The previously configured address or ID is deleted.
998 * The IPv4 netmask alone cannot be added or deleted. Use #KSolInetRtCtrl
1003 * Interface state action.
1005 * 0 = ignore TSoInetInterfaceInfo::iState,
1007 * 1 = set interface state based on
1008 * TSoInetInterfaceInfo::iState as follows:
1010 * The interface state is set to KErrNotReady.
1012 * The interface state is set to 0 (KErrNone).
1014 * Attempt to set any other state results failed operation
1015 * with KErrArgument result.
1019 * Configure address as Anycast.
1021 * The anycast address is defined by #iAddress.
1023 * Anycast address is recognized as own address for incoming
1024 * packets, but it cannot be used as a source address for
1025 * outgoing packets. IPv6 DAD (or IPv4 ARP duplicate address)
1026 * test is not done for anycast addresses. Anycast address is
1027 * advertised on the link as an address of this host.
1029 * 1 = configure anycast (#iDoId must also be set, #iDoPrefix is ignored)
1032 * Add anycast address.
1034 * Remove the previously configured anycast address.
1040 * Confiture address as Proxy.
1042 * The proxy address is defined by #iAddress.
1044 * Proxy address is not recognized as own address for incoming
1045 * packets (nor can it be used as own address for outgoing packets).
1046 * IPv6 DAD (or IPv4 ARP duplicate address) test is performed for
1047 * proxy address. Proxy address is advertised on the link as an
1048 * address of this host.
1050 * 1 = configure proxy (#iDoId must also be set, #iDoPrefix is ignored)
1053 * Add proxy address.
1055 * Remove the previously configured proxy address.
1064 * @name Interface query socket options
1066 * Level: #KSolInetIfQuery
1068 * Querying information about interfaces using TSoInetIfQuery.
1070 * @since 7.0 (some additions in 7.0s)
1073 /** Scope Id vector (member of TSoInetIfQuery). @since 7.0s */
1074 typedef TUint32 TInetScopeIds[16];
1076 class TSoInetIfQuery
1080 * Used with interface query options:
1081 * @li #KSoInetIfQueryByDstAddr
1082 * @li #KSoInetIfQueryBySrcAddr
1083 * @li #KSoInetIfQueryByIndex
1084 * @li #KSoInetIfQueryByName
1086 * Only GetOption for KSolInetIfQuery is supported. It returns
1087 * information about the selected interface. The option name
1088 * determines the input field in the TSoInetIfQuery, which is
1089 * used as a key for locating the interface.
1091 * Returns, KErrNotFound, if interface is not found
1093 * Returns, KErrNone, if interface is located, and fills
1094 * fields from the interface with following logic
1096 * @li iDstAddr: not touched, left as is
1097 * @li iSrcAddr is result of the Select Source Address algorithm
1098 * for the interface using the iDstAddr as input. If there
1099 * is no valid source address, the value will be KAFUnspec.
1100 * @li iIndex is loaded with the interface index of the interface
1101 * @li iName is loaded from the name of the interface
1102 * @li iIsUp is set 1, if interface has CNifIfBase pointer attached,
1105 * For example, if QueryByDstAddr for specified destination address
1106 * results iIsUp == 1, then there is an interface and route for that
1107 * destination. iIsUp == 0, means that trying to connect to the address
1108 * will most likely activate a netdial/interface link startup phase.
1116 * Destination address.
1118 * If the option is #KSoInetIfQueryByDstAddr, select
1119 * interface by finding a route for this address;
1120 * otherwise, ignored.
1121 * @li output: not changed.
1124 * On returning interface information, regardless of
1125 * the option used, the content of this is used to select
1126 * a matching source address (#iSrcAddr).
1132 * If the option is #KSoInetIfQueryBySrcAddr, select
1133 * interface by source address; otherwise, ignored.
1135 * The result of the source address
1136 * selection algorithm based on the content of the
1144 * If the option is #KSoInetIfQueryByIndex, select
1145 * interface by this interface index; otherwise,
1148 * The interface index the located interface.
1149 * (always same as iZone[0] in 7.0s).
1154 * If the option is #KSoInetIfQueryByName, select
1155 * interface by this name; otherwise, ignored.
1157 * The name of the located interface.
1161 * Flag that is set to 1 if the network interface is attached.
1162 * @li input: ignored
1163 * @li output: set as indicated.
1167 * Scope Id Vector (iZone[0] = Interface Index, iZone[1] = IAP ID, iZone[15] = Network ID).
1168 * @li input: ignored
1169 * @li output: The scope id vector
1172 TInetScopeIds iZone;
1175 * Get information for the interface specified by the destination address (iDstAddr)
1176 * field of the passed packaged TSoInetIfQuery.
1178 * This allows the caller to find out what interface would be used (without invoking
1179 * a dial-up process) for the specified destination. A path for this destination
1180 * is open, if GetOpt() returns KErrNone, iSrcAddr is not KAFUnspec, and iIsUp
1183 const TUint KSoInetIfQueryByDstAddr = 0x1;
1185 * Get information for the interface specified by the source address (iSrcAddr)
1186 * field of the passed packaged TSoInetIfQuery.
1188 * If there are multiple interfaces with the same source address, then the first
1189 * matching interface is returned.
1192 * The information return phase will overwrite the iSrcAddr based on
1193 * whatever happens to be in iDstAddr. It is not necessary to initialize
1194 * iDstAddr, if application is not interested in resulting iSrcAddr.
1196 const TUint KSoInetIfQueryBySrcAddr = 0x2;
1198 * Get information for the interface specified by the Interface Index (iIndex)
1199 * field of the passed packaged TSoInetIfQuery.
1201 const TUint KSoInetIfQueryByIndex = 0x3;
1203 * Get information for the interface specified by the Interface Name (iName) field
1204 * of the passed packaged TSoInetIfQuery.
1206 const TUint KSoInetIfQueryByName = 0x4;
1211 * @name Route control socket options
1213 * Level: #KSolInetRtCtrl
1215 * Enumerating & Configuring Routes using TSoInetRouteInfo.
1219 * Begin enumeration of routes.
1221 * This option can only be used with RSocket::SetOpt().
1223 * This option should be set before enumerating routes with #KSoInetNextRoute.
1225 * @capability NetworkServices
1227 const TInt KSoInetEnumRoutes = 0x221;
1229 * Return the next route in an enumeration started by setting the option #KSoInetEnumRoutes.
1231 * Option data type is TSoInetRouteInfo.
1233 * This option can only be used with RSocket::GetOpt().
1235 * @capability NetworkServices
1237 const TInt KSoInetNextRoute = 0x222;
1239 * Adds the specified route to the routing table.
1241 * Option data type is TSoInetRouteInfo.
1242 * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist.
1244 * This option can only be used with RSocket::SetOpt().
1246 * @capability NetworkControl Modifying routes is allowed for authorized apps only.
1247 * @ref RSocket::SetOpt()
1249 const TInt KSoInetAddRoute = 0x223;
1251 * Deletes the specified route from the routing table.
1253 * The route is identified by destination, netmask and gateway,
1254 * These must exactly match the old route to be deleted.
1256 * Option data type is TSoInetRouteInfo.
1257 * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist.
1259 * This option can only be used with RSocket::SetOpt().
1261 * @capability NetworkControl Modifying routes is allowed for authorized apps only.
1262 * @ref RSocket::SetOpt()
1264 const TInt KSoInetDeleteRoute = 0x224;
1266 * Modifies the specified route in the routing table.
1268 * The destination, netmask and gateway settings must be the same
1269 * in the new route as in the old.
1271 * Option data type is TSoInetRouteInfo.
1272 * The interface is defined by the TSoInetRouteInfo::iIfAddr and must exist.
1274 * This option can only be used with RSocket::SetOpt().
1276 * @capability NetworkControl Modifying routes is allowed for authorized apps only.
1277 * @ref RSocket::SetOpt()
1279 const TInt KSoInetChangeRoute = 0x225;
1282 * Identifies the state of a route held in an entry in the IP routing table.
1284 * It is used as a data member of TSoInetRouteInfo.
1287 * This enumeration is present only because of backward
1288 * compatibility. Only two values are used.
1290 * @since 7.0 (in this form)
1299 /** Route is neighbour cache entry, ARP or Neighbor discovery is in progress. */
1303 /** The interface for the route is up and ready. */
1310 * Identifies the type of creator of an entry in the IP routing table.
1312 * It is used as a data member of TSoInetRouteInfo.
1315 * This enumeration is present only because of backward
1316 * compatibility. Only two values are used.
1318 * @since 7.0 (in this form)
1325 /** Normal route entry */
1329 /** Route is ARP or neighbor cache entry */
1335 class TLinkAddr : public TSockAddr
1339 * Link layer address utility.
1341 * Lightweight helper class for handling link layer addresses.
1343 * This class is mainly used to obtain direct access to the raw address
1344 * bytes which are inacessible from the TSockAddr interface.
1346 * A link layer address is a binary string of octets.
1348 * The address family of the TLinkAddr is determined by the interface. If
1349 * the interface uses link layer addresses, it must support the
1350 * #KSoIfHardwareAddr control option, and the returned address family of the
1351 * harware address is supposed to represent the family of all link layer addresses
1352 * of peers on the interface.
1354 * Link layer addresses can be obtained from e.g. TSoInetRouteInfo structures
1355 * using the TSoInetRouteInfo::GetLinkAddr function. Note: this may fail if the
1356 * link layer address of the peer corresponding to the route is not known.
1363 IMPORT_C TLinkAddr();
1364 IMPORT_C void SetAddress(const TDesC8 &aAddr);
1366 IMPORT_C TPtrC8 Address() const;
1368 IMPORT_C const static TLinkAddr& Cast(const TSockAddr& aAddr);
1369 IMPORT_C static TLinkAddr& Cast(TSockAddr& aAddr);
1370 IMPORT_C const static TLinkAddr* Cast(const TSockAddr* aAddr);
1371 IMPORT_C static TLinkAddr* Cast(TSockAddr* aAddr);
1375 class TSoInetRouteInfo
1377 * Route information structure.
1379 * Used with route options:
1381 * @li #KSoInetNextRoute
1382 * @li #KSoInetAddRoute
1383 * @li #KSoInetDeleteRoute
1385 * IPv4 addresses are returned as IPv4-mapped IPv6 addresses
1386 * qualified with appropriate scope id (Symbian OS 7.0 and later).
1393 IMPORT_C TInt GetLinkAddr( TLinkAddr &aInfo ) const;
1399 /** Route preference, with a smaller value indicating a preferred route. */
1401 /** IP address of the interface used for this route. */
1403 /** IP address of the gateway, or link-layer address for neighbour cache entries */
1405 /** IP address of the destination network or host. */
1407 /** Destination mask of network. */
1411 class TSoInetCachedRouteInfo : public TSoInetRouteInfo
1413 * Access to route cache TPckgBuf<TSoInetCachedRouteInfo>, set iDstAddr for required address
1414 * With a level of KSolInetRtCtrl. This API is no longer suported.
1427 /** No longer supported. @removed. @since 7.0 */
1428 const TInt KSoInetCachedRouteByDest = 0x225;
1434 * @name DNS definitions
1438 * Flags returned from DNS records.
1440 * Provides flag bitmasks that are used to describe properties of results of DNS
1441 * queries via RHostResolver.
1445 enum TNameRecordFlags
1447 /** Name is an Alias. */
1448 EDnsAlias=0x00000001,
1449 /** Answer is authoritive. */
1450 EDnsAuthoritive=0x00000002,
1451 /** Answer is from hosts file. */
1452 EDnsHostsFile=0x00000004,
1453 /** Answer is from a DNS server. */
1454 EDnsServer=0x00000008,
1455 /** Answer is host name for this host. */
1456 EDnsHostName=0x00000010,
1457 /** Answer is from the resolver cache. */
1458 EDnsCache=0x00000020,
1459 /** Answer does not have a route set */
1460 EDnsNoRoute=0x00000040
1463 /** No longer supported.
1466 const TUint KSoDnsCacheEnable = 0x600;
1467 /** No longer supported.
1470 const TUint KSoDnsCacheFlush = 0x601;
1471 #ifdef SYMBIAN_DNS_PUNYCODE
1472 /** Enable International Domain Name support
1476 const TUint KSoDnsEnableIdn = 0x602;
1477 #endif //SYMBIAN_DNS_PUNYCODE
1481 * @name TCP socket options
1483 * Level: #KSolInetTcp
1487 * Complete the ioctl request when the data has been sent.
1489 const TUint KIoctlTcpNotifyDataSent = 0x300;
1492 * The maximum number of bytes that can be queued for sending.
1494 * If this option is set when the connection state is not closed,
1495 * then KErrLocked is returned.
1497 * Option data type is TInt.
1499 * The default value is 8192.
1501 const TUint KSoTcpSendWinSize = 0x301;
1503 * The maximum number of bytes that can be buffered for receiving.
1505 * If this option is set when the connection state is not closed,
1506 * then KErrLocked is returned.
1508 * Option data type is TInt.
1510 * The default value is 8192.
1512 const TUint KSoTcpRecvWinSize = 0x302;
1514 * The maximum TCP segment size (bytes).
1516 * If this option is set when the connection state is not closed,
1517 * then KErrLocked is returned.
1519 * Option data type is TInt.
1521 * The default value is 1460.
1523 const TUint KSoTcpMaxSegSize = 0x303;
1525 * Send data at once if there is an established connection, without
1526 * waiting for the maximum segment size to be reached.
1528 * The default is disabled.
1530 * Option data type is TInt.
1532 * Values are: 0 = Disable, 1 = Enable.
1534 const TUint KSoTcpNoDelay = 0x304;
1536 * On the time-out expiring without an acknowledgement being received,
1537 * send a packet designed to force a response if the peer is up and reachable.
1539 * The default is disabled.
1541 * Option data type is TInt.
1543 * Values are: 0 = Disable, 1 = Enable.
1545 const TUint KSoTcpKeepAlive = 0x305;
1547 * If address reuse is allowed, and a connection already exists between
1548 * the requested local and remote addresses, wait for the address to
1551 * The default is disabled.
1553 * Option data type is TInt.
1555 * Values are: 0 = Disable, 1 = Enable.
1558 const TUint KSoTcpAsync2MslWait = 0x306;
1560 * The number of bytes currently queued for sending.
1562 * Option data type is TInt.
1564 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
1566 const TUint KSoTcpSendBytesPending = 0x307;
1568 * The number of bytes currently available for reading (the same value as
1569 * is obtained using KSOReadBytesPending).
1571 * Option data type is TInt.
1573 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
1575 const TUint KSoTcpReadBytesPending = 0x308;
1577 * The socket has been set to listen (through RSocket::Listen()).
1579 * Option data type is TInt.
1581 * Values are: 0. Not listening, 1. Listening
1583 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
1585 const TUint KSoTcpListening = 0x309;
1587 * The number of current TCP sockets.
1589 * Option data type is TInt.
1591 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
1593 const TUint KSoTcpNumSockets = 0x310;
1595 * Read out-of-band urgent data.
1597 * KErrNotFound is returned if there is no data waiting and no
1598 * urgent data pointer has been received.
1600 * KErrWouldBlock is returned if and urgent is available but data needs to be
1601 * read from the current stream to match the urgent data mark.
1603 * Option data type is TInt.
1605 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
1607 const TUint KSoTcpReadUrgentData = 0x311;
1609 * Peeks for urgent data. The behaviour is the same as KSoTcpReadUrgentData,
1610 * but the urgent data is not removed.
1612 * Option data type is TInt.
1614 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
1616 const TUint KSoTcpPeekUrgentData = 0x312;
1618 * True if the data stream has been read up to the point where urgent
1619 * data is available, otherwise false.
1621 * Option data type is TInt.
1623 * This option can only be used with RSocket::GetOpt(), not RSocket::SetOpt().
1625 const TUint KSoTcpRcvAtMark = 0x313;
1627 * The next send operation will mark the last byte sent as urgent data.
1629 * The default is disabled.
1631 * Option data type is TInt.
1633 * Values are: 0 = Disable, 1 = Enable.
1635 const TUint KSoTcpNextSendUrgentData = 0x314;
1637 * Receive out-of-band data in the normal data stream.
1639 * The default is disabled.
1641 * Option data type is TInt.
1643 * Values are: 0 = Disable, 1 = Enable.
1645 const TUint KSoTcpOobInline = 0x315;
1647 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
1649 * TCP max receive value
1651 * Used with SetOpt to set TCP Max recv window size
1653 const TUint KSoTcpMaxRecvWin = 0x316;
1655 * TCP Receive window size for auto tuning
1657 * Used with SetOpt to set TCP Max recv window size
1659 const TUint KSoTcpRecvWinAuto = 0x317;
1661 #endif //SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
1664 /** Not supported. @removed */
1665 const TUint KSOTcpDebugMode = 0x11110000;
1669 * @name IPv6 and IPv4 socket options
1671 * Level: #KSolInetIp
1676 * Data to place in IP Options field of sent datagrams.
1678 * Not supported. @removed
1681 const TUint KSoIpOptions = 0x401;
1683 * Include IP header in data returned to client.
1685 * IPv4 packets are returned as is with all headers in network byte order (until
1686 * v7.0, this returned IPv4 headers in host order). See TInet6HeaderIP4 and
1687 * TInet6HeaderIP for the header layout.
1689 * The default is disabled.
1691 * Option data type is TInt.
1692 * Values are: 0 = Disable, 1 = Enable.
1694 * @sa KSoHeaderIncluded, KIpHeaderIncluded
1696 const TUint KSoRawMode = 0x402;
1698 * Assume that the IP header is included in all data written by the client.
1700 * KSoRawMode must be set before this is allowed.
1703 * Option data type is TInt.
1704 * Values are: 0. Disable; 1. Enable
1706 * The default is disabled.
1708 * @sa KSoRawMode, KIpHeaderIncluded
1710 const TUint KSoHeaderIncluded = 0x403;
1712 * Type of Service field of outgoing datagrams.
1714 * For IPv6, there is no Type of Service field, so this option sets the Traffic Class.
1716 * Option data type is TInt.
1717 * Values are 0-255. Because Explicit Congestion Notification [RFC3168] uses bits 6 & 7
1718 * in the IP field, modifying the two least significant bits is not allowed with TCP.
1719 * SetOpt processing silently ignores any modifications on these bits when using TCP socket.
1721 * The default value is 0.
1723 const TUint KSoIpTOS = 0x404;
1725 * Time to Live field of outgoing datagrams.
1727 * This is same as #KSoIp6UnicastHops.
1729 * Option data type is TInt.
1730 * Values are [-1,,255]. The -1 resets to the configured default value.
1732 * There are separate configured default values for the link local and other
1733 * destinations. Both defaults can be configured by the TCPIP.INI parameters
1734 * <tt>maxttl</tt> and <tt>linklocalttl</tt>, The compiled defaults are
1735 * #KTcpipIni_Maxttl and #KTcpipIni_LinkLocalttl.
1738 * For the TTL of multicast destinations, @see KSoIp6MulticastHops.
1740 const TUint KSoIpTTL = 0x405;
1742 * Allow a socket to be bound to an local address that is already in use.
1744 * Option data type is TInt.
1745 * Values are: 0 = Disable, 1 = Enable.
1747 * The default is disabled.
1748 * @capability NetworkControl Required for 'udp' sockets.
1750 const TUint KSoReuseAddr = 0x406;
1752 * Do not set socket into error state if currently connected
1753 * interface reports an error.
1755 * For example, this could be enabled for a unconnected datagram
1756 * socket. Unconnected datagram sockets are connected to the
1757 * interface of the last sent packet. If multiple interfaces
1758 * are present, erroring the socket might not be the desired
1759 * action if just one interface gives an error.
1761 * Another use case would be a connected socket (TCP), which
1762 * does not get error even if interface goes down, and comes
1763 * up with the same source address after a while.
1765 * Option data type is TInt.
1766 * Values are: 0 = Disable, 1 = Enable.
1768 * The default can be changed by the TCPIP.INI parameter <tt>noiferror</tt>,
1769 * and the compiled default is #KTcpipIni_Noiferror..
1773 const TUint KSoNoInterfaceError = 0x407;
1775 * Modify socket visibility.
1777 * Background internet services that have sockets open count as active
1778 * user and prevents the TCPIP from shutting down.
1779 * By this socket option, such a process can make selected sockets to be
1780 * excluded from the count.
1782 * Option data type is TInt.
1783 * By setting the value to 0, the socket is not counted as active user. The value
1784 * 1 makes it visible again.
1786 * The option has no effect if the visibility state already matches the parameter.
1788 * By default, all sockets are initially visible.
1791 * This option should only be used by background daemons which are
1792 * started by the TCPIP stack.
1795 const TUint KSoUserSocket = 0x408;
1797 * Set or get interface index of the socket.
1799 * Gets the current interface index of the socket. Returns the
1800 * value used in the last set.
1802 * If interface index has not been set by this option, then value is
1803 * determined as follows:
1806 * the interface index of the interface which got the last packet
1809 * zero, if no packets have been sent or interface cannot be
1812 * Option data type is TUint32.
1816 const TUint KSoInterfaceIndex = 0x409;
1818 * Controls whether the interface flow counter is affected by this socket.
1820 * This counter is used in determining when the interface can be brought down.
1822 * Option data type is TInt.
1823 * Values are: 0=Don't count, 1= count flow against
1824 * interface flow count.
1826 * The default can be changed by the TCPIP.INI parameter <tt>keepinterfaceup</tt>,
1827 * and the compiled default is #KTcpipIni_KeepInterfaceUp.
1831 const TUint KSoKeepInterfaceUp = 0x40a;
1833 * Enable use of 0 as a source address.
1835 * When socket is bound to unspecified address (0), the stack will automaticly
1836 * select the source address for the outgoing packets. When this option is
1837 * set <b>after bind</b>, the stack will not select a new address.
1841 const TUint KSoNoSourceAddressSelect = 0x40b;
1843 * Retrieve last error information.
1845 * This option is for use with GetOpt() only.
1847 * Option data type is TSoInetLastErr.
1849 const TUint KSoInetLastError = 0x200;
1851 * An Ioctl corresponding to the socket option KSoInetLastError.
1853 const TUint KIoctlInetLastError = 0x200;
1855 * Hop limit for outgoing datagrams: same as #KSoIpTTL.
1857 * Option data type is TInt.
1858 * Values are [-1,,255]. The -1 resets to the configured default value.
1860 * @see #KSoIpTTL for details.
1863 * KSoIp6UnicastHops can be used to detect dual IPv4/IPv6 stack from
1864 * from the old TCPIP only-IPv4 stack. This option is only implemented
1865 * in the dual stack.
1868 const TUint KSoIp6UnicastHops = 0x465;
1870 * Interface for outgoing multicast packets
1874 const TUint KSoIp6MulticastIf = 0x46a;
1876 * Hop limit for multicast packets.
1878 * Option data type is TInt.
1879 * Values are [-1..255]. The -1 resets to the configured default value.
1884 const TUint KSoIp6MulticastHops = 0x46b;
1886 * Enable/disable loopback of the multicast packets.
1888 * When enabled, multicast packets sent to this socket are internally
1889 * looped back (in addition to sending them onto the interface). Another
1890 * or same application listening the group and port, receives copies of
1891 * the transmitted packets.
1893 * When disabled, an application on this host listening the same group
1894 * and port, does not receive multicast packets originating from this
1895 * socket (unless the interface or link echoes them back to the TCP/IP
1898 * Option data type is TInt.
1899 * Values are 1=enable; 0=disable. The default is 1.
1902 const TUint KSoIp6MulticastLoop = 0x46c;
1904 * Join multicast group.
1906 * Option data type is TIp6Mreq.
1909 const TUint KSoIp6JoinGroup = 0x46d;
1911 * Leave multicast group.
1913 * Option data type is TIp6Mreq.
1916 const TUint KSoIp6LeaveGroup = 0x46e;
1918 * Hop limit for outgoing datagrams: similar to KSoIp6UnicastHops except
1919 * any socket option to override the current setting is ignored. The value
1920 * returned is either the value of the associated interface or the TCP/IP 6
1921 * stack default if no interface has been selected yet.
1923 * Option data type is TInt.
1924 * Values are [0..255]. Value cannot be modified, only queried.
1926 * @see KSoIp6UnicastHops for details.
1930 const TUint KSoIp6InterfaceUnicastHops = 0x46f;
1933 class TSoInetLastErr
1935 * Error information for TCP/IP protocols.
1937 * An object of this class is returned packaged as a TPckgBuf<TSoInetLastErr>
1938 * in the option argument of RSocket::GetOpt(), when this function is called
1939 * with (KSolInetIp, KSoInetLastError). The data members of this object
1940 * are updated whenever a packet carrying an ICMP message is received.
1943 * This class is originally defined only for the IPv4 environment, and
1944 * there is no definite way of knowing whether the fields iErrType and
1945 * iErrCode contain ICMPv4 or ICMPv6 codes. A solution that will give
1946 * the correct answer in most normal cases, is
1950 if (p.iErrAddr.Family() == KAfInet || p.iErrAddr.IsV4Mapped())
1951 // assume ICMPv4 type and code
1953 // assume ICMPv6 type and code
1956 * Alternatively, the error can be interpreted based on the member variable
1957 * iStatus, if it contains one of the extended error codes. These are are
1958 * common for both IPv4 and IPv6.
1965 /** The error code returned by the last ESOCK API function called. */
1967 /** The value of the Type field of the last ICMP message. */
1969 /** The value of the Code field of the last ICMP message. */
1971 /** A TInetAddr with the IP address and port set to the source address and port
1972 * of the failed datagram. */
1974 /** A TInetAddr with the IP address and port set to the destination address and
1975 * port of the failed datagram. */
1977 /** A TInetAddr with the IP address set to the address of the host that generated
1986 * Used by IPv6 or IPv4 multicast join/leave group socket options
1987 * #KSoIp6JoinGroup and #KSoIp6LeaveGroup.
1989 * Joining to a multicast group address adds this address to the
1990 * list of addresses for which incoming packets are accepted.
1991 * Optionally, if the required support has been installed, some
1992 * MLD (Multicast Listener Discovery) protocol messages may be
1995 * The multicast join/leave are always interface specific,
1996 * and the interface index should be specified in the set option call.
1997 * If the index value is set to 0, the stack attempts to select
2006 /** IPv6 or IPv4 multicast address. */
2008 /** Interface Index. */
2016 * Level: #KSolInetUdp
2020 * Inform client of error if ICMP error packets received.
2022 * The default is disabled.
2024 * Option data type is TInt.
2025 * Values are: 0 = Disable, 1 = Enable.
2027 const TUint KSoUdpReceiveICMPError = 0x500;
2030 Modifies address flag of UDP. Flag is used to control whether the socket is bound to
2031 IP address or not. Binding to specific address and then clearing this flag makes possible
2032 to receive packets sent to broadcast address but still to have a specific bound address
2033 for outgoing packets.
2035 const TUint KSoUdpAddressSet = 0x502;
2038 * Setting this option causes the UDP send operation to block when dynamic interface
2039 * setup is in progress, or when local flow control within the stack would otherwise
2040 * cause the packet to be dropped.
2043 const TUint KSoUdpSynchronousSend = 0x560;
2047 * @name TCP/IP specific Socket provider options
2049 * Level: #KSOLProvider
2053 * Internal flow option called when the flow is about to be closed.
2055 * This option is only for the outbound flow hooks, which are
2056 * attached to the TCIP/IP stack. The stack generates a call, just
2057 * before the flow context associated with service access point
2058 * (SAP) provider is about to be closed. If a hook has stored
2059 * some socket specific state information into the flow context,
2060 * then this option event may be of some use to it.
2063 const TUint KSoFlowClosing = 0x600 | KSocketInternalOptionBit;
2066 /** @name Extended error codes */
2068 /** Network could not be reached. */
2069 const TInt KErrNetUnreach = -190;
2070 /** Host could not be reached. */
2071 const TInt KErrHostUnreach = -191;
2072 /** Protocol could not be reached. */
2073 const TInt KErrNoProtocolOpt = -192;
2074 /** Urgent data error. */
2075 const TInt KErrUrgentData = -193;