tcpiputils/dnd/include/llmnrconflict.h
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2005-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 // llmnrconflict.h - Interface definitions LLMNR name conflict notification
       
    15 // Interface definitions for the LLMNR name conflict notification
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file llmnrconflict.h
       
    22  @publishedPartner
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __LLMNRCONFLICT_H__
       
    27 #define __LLMNRCONFLICT_H__
       
    28 
       
    29 #include <es_sock.h>
       
    30 
       
    31 /**
       
    32 * The notification UID
       
    33 */
       
    34 TInt KLlmnrConflictNotifyUid = 0x101F6D23;
       
    35 
       
    36 class TLlmnrConflictName
       
    37 	{
       
    38 public:
       
    39 	inline TBool IsSafe() const;
       
    40 	THostName	iName;				//< The host name.
       
    41 	};
       
    42 
       
    43 class TLlmnrConflictNotify : public TLlmnrConflictName
       
    44 	/**
       
    45 	* Conflict notification message format.
       
    46 	*
       
    47 	* The base iName contains the link local name which is conflict
       
    48 	* with some other host on some interface assotiated with the
       
    49 	* indicated IAP (iIAPId).
       
    50 	*/
       
    51 	{
       
    52 public:
       
    53 
       
    54 	TUint32		iIAPId;				//< ID of selected IAP
       
    55 	TUint32		iNetworkId;			//< ID of Network to which IAP belongs
       
    56 	};
       
    57 	
       
    58 /**
       
    59 * The reply from notifier only has the replacement host name.
       
    60 *
       
    61 * The the nofitier completes with KErrNone, the reply message can contain
       
    62 * a the new name. If this new name is also colliding with someone, another
       
    63 * notify is issued.
       
    64 *
       
    65 * If the notifier does not want LLMNR to try an alternate name, it should
       
    66 * either complete with some error (KErrCancel for example), or KErrNone
       
    67 * with empty replacement name (iName.Length() == 0).
       
    68 */
       
    69 typedef TLlmnrConflictName TLlmnrConflictReply;
       
    70 
       
    71 
       
    72 TBool TLlmnrConflictName::IsSafe() const
       
    73 	/**
       
    74 	* Test if iName really is a TBuf derived descriptor.
       
    75 	*/
       
    76 	{
       
    77 	// This test is defined, because this structure is passed as a parameter,
       
    78 	// and any sender of the message can crash the receiver by placing tailored "garbage"
       
    79 	// on TBuf descriptor. The receiver has no official way of validating that TBuf
       
    80 	// descriptor is correct, and the garbage can be such that any reference to the
       
    81 	// content of TBuf will cause panic (for example place into iTypeLength field a
       
    82 	// value that implies TPtr and NULL into actual buffer address).
       
    83 	//
       
    84 	// This method gives some (but not 100%) confidence that accessing the iName
       
    85 	// does not cause a panic. This test works on assumtion that first TInt of
       
    86 	// the descriptor holds "type length" information, and that type of a TBuf is
       
    87 	// 0.
       
    88 	//
       
    89 	// Something like this sbould be provided by the descriptor class itself!
       
    90 	//
       
    91 	return ((iName.Length() | 0x30000000) == (TInt &)iName &&	// ... is really a TBuf?
       
    92 			iName.Length() <= iName.MaxLength() &&				// ... length & maxlength seem reasonable
       
    93 			iName.MaxSize() >= (sizeof(THostName) - 2*sizeof(TInt)));
       
    94 	}
       
    95 
       
    96 #endif