natfw/natfwclient/tsrc/ut_natfwclient/inc/cncmportstore.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:    Class for reserving ports on specific range
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef NATFWPORTSTORE_H
       
    22 #define NATFWPORTSTORE_H
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 /**
       
    27  *  Class for reserving ports on specific range
       
    28  *
       
    29  *  @lib connectionmux.lib
       
    30  *  @since S60 v3.2
       
    31  */
       
    32 class CNcmPortStore : public CBase
       
    33     {
       
    34 
       
    35 public:
       
    36 
       
    37     /**
       
    38      * Two-phased constructor
       
    39      *
       
    40      * @param   aStartPort     Port range start for session
       
    41      * @param   aStopPort      Port range stop for session
       
    42      */
       
    43     static CNcmPortStore* NewL( TUint aStartPort, TUint aStopPort );
       
    44 
       
    45     /**
       
    46      * Two-phased constructor
       
    47      *
       
    48      * @param   aStartPort     Port range start for session
       
    49      * @param   aStopPort      Port range stop for session
       
    50      */
       
    51     static CNcmPortStore* NewLC( TUint aStartPort, TUint aStopPort );
       
    52 
       
    53     /**
       
    54      * Destructor
       
    55      */
       
    56     virtual ~CNcmPortStore();
       
    57 
       
    58     /**
       
    59      * Retrives a free port for usage
       
    60      *
       
    61      * @since   S60 v3.2
       
    62      * @return  Usable port, or zero on error
       
    63      */
       
    64     IMPORT_C TUint Port();
       
    65 
       
    66     /**
       
    67      * Frees reserved port
       
    68      *
       
    69      * @since S60 v3.2
       
    70      * @param aPort         Port to be freed
       
    71      */
       
    72     IMPORT_C void FreePort( TUint aPort );
       
    73 
       
    74 private:
       
    75 
       
    76     CNcmPortStore( TUint aStartPort, TUint aStopPort );
       
    77 
       
    78 private: // data
       
    79 
       
    80     /**
       
    81      * Reserved ports are stored here
       
    82      */
       
    83     RArray<TUint> iReservedPorts;
       
    84 
       
    85     /**
       
    86      * First port on range
       
    87      */
       
    88     TUint iStartPort;
       
    89 
       
    90     /**
       
    91      * Last port on range
       
    92      */
       
    93     TUint iStopPort;
       
    94 
       
    95     };
       
    96 
       
    97 
       
    98 #endif // NATFWPORTSTORE_H