diff -r 78fbd574edf4 -r da856f45b798 zeroconf/dnsparser/src/cdnsmessage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zeroconf/dnsparser/src/cdnsmessage.cpp Thu Jun 24 19:09:47 2010 +0530 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "cdnsmessage.h" + + +CDnsMessage::CDnsMessage(TUint16 aId, TBool aQuery) + { + iHeader.SetId(aId); + iHeader.SetQuery(aQuery); + } + +EXPORT_C CDnsMessage* CDnsMessage::NewL(TUint16 aId, TBool aQuery) + { + return ( new(ELeave)CDnsMessage(aId, aQuery) ); + } + +CDnsMessage::~CDnsMessage() + { + iQueries.ResetAndDestroy(); + iQueries.Close(); + iAnswers.ResetAndDestroy(); + iAnswers.Close(); + iAuthorities.ResetAndDestroy(); + iAuthorities.Close(); + iAdditional.ResetAndDestroy(); + iAdditional.Close(); + } + +EXPORT_C void CDnsMessage::SetHeader(const TDnsHeader& aHeader) + { + iHeader = aHeader; + } + +EXPORT_C void CDnsMessage::AppendQueryL(const CDnsQuestion* aQuery) + { + iQueries.AppendL(aQuery); + iHeader.SetQueryCount(iQueries.Count()); + } + +EXPORT_C void CDnsMessage::AppendAnswerL(const CDnsResourceData* aAnswer) + { + iAnswers.AppendL(aAnswer); + iHeader.SetAnswerCount(iAnswers.Count()); + } + +EXPORT_C void CDnsMessage::AppendAuthorityL(const CDnsResourceData* aAuthority) + { + iAuthorities.AppendL(aAuthority); + iHeader.SetAuthorityNSCount(iAuthorities.Count()); + } + +EXPORT_C void CDnsMessage::AppendAdditionalL(const CDnsResourceData* aAdditional) + { + iAdditional.AppendL(aAdditional); + iHeader.SetAdditionalRCount(iAdditional.Count()); + } + +EXPORT_C const RPointerArray& CDnsMessage::Queries()const + { + return iQueries; + } + +EXPORT_C const RPointerArray& CDnsMessage::Answers()const + { + return iAnswers; + } + +EXPORT_C const RPointerArray& CDnsMessage::Authorities()const + { + return iAuthorities; + } + +EXPORT_C const RPointerArray& CDnsMessage::Additional()const + { + return iAdditional; + } + +EXPORT_C const TDnsHeader& CDnsMessage::Header()const + { + return iHeader; + } + +//Calculates the size of the dns message +EXPORT_C TUint16 CDnsMessage::Size()const + { + TUint16 size =0; + size += sizeof(iHeader); + + TInt i; + + for ( i=0; iSize(); + } + + for ( i=0; iSize(); + } + + for ( i=0; iSize(); + } + + for ( i=0; iSize(); + } + return size ; + } + +