zeroconf/dnsparser/inc/cdnspacket.h
changeset 14 da856f45b798
equal deleted inserted replaced
12:78fbd574edf4 14:da856f45b798
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CDNSPACKET_H__
       
    21 #define __CDNSPACKET_H__
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <es_sock.h>
       
    25 #include <in_sock.h>
       
    26 
       
    27 #include "tdnsheader.h"
       
    28 
       
    29 #define __OOB(aIndex,aDataLength)     {if(aIndex >= aDataLength)  User::Leave(KErrCorrupt);}
       
    30 	
       
    31 _LIT8(KDot,".");
       
    32 
       
    33 class CDnsPacket : public CBase
       
    34 	{
       
    35 public:
       
    36     ~CDnsPacket();
       
    37 	static CDnsPacket* NewL(const TDes8& aPacketPtr);
       
    38 	TUint8  GetCharL();
       
    39 	TUint16 GetInt16L();
       
    40 	TUint32 GetInt32L();
       
    41 	const TDnsHeader& GetHeaderL();
       
    42 	void GetDomainNameL(TDes8& aName);
       
    43 	void GetRdDomainNameL(TDes8& aDomainName,TUint aLength);
       
    44 	void GetStringL(TDes8& aString, TUint16 aLength);			
       
    45 	
       
    46 private:
       
    47 	void ConstructL();
       
    48 	CDnsPacket(const TDes8& aPacketPtr);
       
    49 	void GetStringAtIndexL(TDes8& aLabel, TUint aOffset);
       
    50 	void GetDomainNameAtIndexL(TDes8& aDomainName, TUint aOffset);
       
    51 	
       
    52 private:
       
    53 	TDnsHeader iHeader;	
       
    54 	const TUint8* iPtr;
       
    55 	TUint iIndex;
       
    56 	TUint iDataLength;
       
    57 	TUint iMaxLength;
       
    58 	};
       
    59 
       
    60 #endif  //__CDNSPACKET_H__