|
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 * CUDPAirInterface |
|
16 * Air Interface for the mobile termination. Sends and receives data over UDP |
|
17 * sockets using addresses and ports specified. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 #ifndef __CUDPAIRINTERFACE_H__ |
|
24 #define __CUDPAIRINTERFACE_H__ |
|
25 |
|
26 /******************************************************************************* |
|
27 * |
|
28 * System Includes |
|
29 * |
|
30 ******************************************************************************/ |
|
31 #ifdef WIN32 |
|
32 #include <winsock2.h> |
|
33 #else |
|
34 #include <sys/types.h> |
|
35 #include <sys/socket.h> |
|
36 #include <netinet/in.h> |
|
37 #endif |
|
38 |
|
39 /******************************************************************************* |
|
40 * |
|
41 * Local Includes |
|
42 * |
|
43 ******************************************************************************/ |
|
44 #include "MTInterfaces.h" |
|
45 #include "CLog.h" |
|
46 |
|
47 /******************************************************************************* |
|
48 * |
|
49 * Definitions |
|
50 * |
|
51 ******************************************************************************/ |
|
52 #define KPCKTBUFFSIZE ((1024)*64) |
|
53 |
|
54 |
|
55 /******************************************************************************* |
|
56 * |
|
57 * Types |
|
58 * |
|
59 ******************************************************************************/ |
|
60 typedef enum |
|
61 { |
|
62 AIE_NONE, |
|
63 AIE_RECEIVE_FAILED, |
|
64 AIE_SOCKET_FAILED, |
|
65 AIE_BIND_FAILED, |
|
66 } TAirInterfaceError; |
|
67 |
|
68 |
|
69 /******************************************************************************* |
|
70 * |
|
71 * Class Definition |
|
72 * |
|
73 ******************************************************************************/ |
|
74 class CUDPAirInterface : public IAirInterface |
|
75 { |
|
76 public: |
|
77 // Construction |
|
78 CUDPAirInterface( TPhoneData *aPhoneData, CLog *aLog ); |
|
79 virtual ~CUDPAirInterface(); |
|
80 |
|
81 // Control |
|
82 TAirInterfaceError ListenOnInterface( int *aErrCode ); |
|
83 int StopInterface(); |
|
84 |
|
85 // Accessors |
|
86 void GetLocalAddress( struct sockaddr_in *aLocalAddress ); |
|
87 void GetRemoteAddress( struct sockaddr_in *aRemoteAddress ); |
|
88 void SetRemoteAddress( struct sockaddr_in aRemoteAddress ); |
|
89 void SetDatalink( IProcessData *aProcessData ); |
|
90 void SetFilter( IFilter *aFilter ); |
|
91 |
|
92 // IAirInterface |
|
93 virtual TDataPathError SendPacket( char *data, int len, int *aErrCode ); |
|
94 |
|
95 private: |
|
96 int GetSocketError(); |
|
97 |
|
98 private: |
|
99 TPhoneData *iPhoneData; |
|
100 IProcessData *iProcessData; |
|
101 CLog *iLog; |
|
102 IFilter *iFilter; |
|
103 |
|
104 struct sockaddr_in iRemoteAddress; |
|
105 struct sockaddr_in iLocalAddress; |
|
106 |
|
107 char iPacketBuffer[KPCKTBUFFSIZE]; |
|
108 |
|
109 int iSockIncoming; |
|
110 int iSockOutgoing; |
|
111 int iExitFlag; |
|
112 int iRemoteAddressValid; |
|
113 }; |
|
114 |
|
115 #endif //__CUDPAIRINTERFACE_H__ |