natfw/natfwclient/tsrc/ut_natfwclient/inc/natfwportstore.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 25 May 2010 13:07:26 +0300
branchRCL_3
changeset 18 91f50911ea81
parent 0 1bce908db942
permissions -rw-r--r--
Revision: 201019 Kit: 2010121

/*
* Copyright (c) 2006-2007 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:    Class for reserving ports on specific range
*
*/




#ifndef NATFWPORTSTORE_H
#define NATFWPORTSTORE_H

#include <e32base.h>

/**
 *  Class for reserving ports on specific range
 *
 *  @lib connectionmux.lib
 *  @since S60 v3.2
 */
class CNATFWPortStore : public CBase
    {

public:

    /**
     * Two-phased constructor
     *
     * @param   aStartPort     Port range start for session
     * @param   aStopPort      Port range stop for session
     */
    static CNATFWPortStore* NewL( TUint aStartPort, TUint aStopPort );

    /**
     * Two-phased constructor
     *
     * @param   aStartPort     Port range start for session
     * @param   aStopPort      Port range stop for session
     */
    static CNATFWPortStore* NewLC( TUint aStartPort, TUint aStopPort );

    /**
     * Destructor
     */
    virtual ~CNATFWPortStore();

    /**
     * Retrives a free port for usage
     *
     * @since   S60 v3.2
     * @return  Usable port, or zero on error
     */
    IMPORT_C TUint Port();

    /**
     * Frees reserved port
     *
     * @since S60 v3.2
     * @param aPort         Port to be freed
     */
    IMPORT_C void FreePort( TUint aPort );

private:

    CNATFWPortStore( TUint aStartPort, TUint aStopPort );

private: // data

    /**
     * Reserved ports are stored here
     */
    RArray<TUint> iReservedPorts;

    /**
     * First port on range
     */
    TUint iStartPort;

    /**
     * Last port on range
     */
    TUint iStopPort;

    };


#endif // NATFWPORTSTORE_H