|
1 /* |
|
2 * Copyright (c) 2005-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 * CInterfaceAlias |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __CINTERFACEALIAS_H__ |
|
22 #define __CINTERFACEALIAS_H__ |
|
23 |
|
24 /******************************************************************************* |
|
25 * |
|
26 * System Includes |
|
27 * |
|
28 ******************************************************************************/ |
|
29 #include <string> |
|
30 using namespace std; |
|
31 |
|
32 /******************************************************************************* |
|
33 * |
|
34 * Definitions |
|
35 * |
|
36 ******************************************************************************/ |
|
37 typedef enum { |
|
38 IAS_INIT, |
|
39 IAS_UP, |
|
40 IAS_DOWN |
|
41 } TInterfaceState; |
|
42 |
|
43 typedef enum { |
|
44 IE_NONE, |
|
45 IE_NO_FREE_ALIAS, |
|
46 IE_INVALID_PARAM, |
|
47 IE_SOCKET_FAILED, |
|
48 IE_INVALID_ADDR, |
|
49 IE_IOCTL_FAILED, |
|
50 IE_INVALID_STATE, |
|
51 IE_INVALID_INTERFACE |
|
52 } TInterfaceAliasError; |
|
53 |
|
54 /******************************************************************************* |
|
55 * |
|
56 * Class CInterfaceAlias |
|
57 * |
|
58 ******************************************************************************/ |
|
59 class CInterfaceAlias |
|
60 { |
|
61 public: |
|
62 CInterfaceAlias(); |
|
63 ~CInterfaceAlias(); |
|
64 |
|
65 TInterfaceAliasError CreateNewInterfaceAlias( int aBaseInterfaceIndex, int aNetMask, int aHostAddress, int *aAliasIndex, int *aErrorCode ); |
|
66 TInterfaceAliasError DestroyInterfaceAlias( int *aErrorCode ); |
|
67 TInterfaceAliasError GetInterfaceIndex( int *aBaseInterfaceIndex, int *aAliasIndex ); |
|
68 TInterfaceAliasError GetInterfaceName( string *aInterfaceName ); |
|
69 TInterfaceAliasError GetInterfaceAddress( string *aInterfaceAddress ); |
|
70 |
|
71 private: |
|
72 TInterfaceAliasError GetBaseInterfaceAddress( int aBaseInterfaceIndex, struct sockaddr_in *aInterfaceAddress, int *aErrorCode ); |
|
73 TInterfaceAliasError GetFreeAliasIndex( int aBaseInterfaceIndex, int *aAliasIndex, int *aErrorCode ); |
|
74 int ParseInterfaceName( char *aInterfaceName, int *aBaseIndex, int *aAliasIndex ); |
|
75 TInterfaceAliasError GetInterfaceList( char *aInterfaceBuffer, int aInputBufferLength, int *aOutputBufferLength, int *aErrorCode ); |
|
76 int ChangeHostAddress( int aBaseAddress, int aNetMask, int aHostAddress ); |
|
77 int NetmaskFromBitcount( int aBitCount ); |
|
78 |
|
79 TInterfaceState iState; |
|
80 int iBaseInterfaceIndex; |
|
81 int iAliasIndex; |
|
82 string iInterfaceAddress; |
|
83 string iInterfaceName; |
|
84 }; |
|
85 |
|
86 #endif //__CINTERFACEALIAS_H__ |