00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <iostream>
00024 #include <unistd.h>
00025 #include <sys/socket.h>
00026 #include <sys/ioctl.h>
00027 #include <net/if.h>
00028 #include <netinet/in.h>
00029 #include <netinet/tcp.h>
00030 #include <arpa/inet.h>
00031 #include <errno.h>
00032 #include <limits.h>
00033
00034
00035 #include <sys/syscall.h>
00036
00037
00038 #include "RioError.h"
00039 #include "NetUdp.h"
00040 #include "NetInterface.h"
00041
00042
00043 #ifdef RIO_DEBUG_FILE
00044 #define UDPLOG m_log
00045 #else
00046 #define UDPLOG RioErr
00047 #endif
00048
00049
00050
00051
00052
00053
00054
00055
00056 CNetUdp::CNetUdp( CNetInterface *NetInterface )
00057 {
00058
00059 m_NetInterface = NetInterface;
00060
00061 #ifdef RIO_DEBUG1
00062 UDPLOG << "[CNetUdp - Construtor] Start" << endl;
00063 #endif
00064
00065
00066 m_Started = false;
00067 m_LogRotation = NULL;
00068
00069 #ifdef RIO_DEBUG1
00070 UDPLOG << "[CNetUdp - Construtor] Finish" << endl;
00071 #endif
00072 }
00073
00074
00075 CNetUdp::~CNetUdp()
00076 {
00077 #ifdef RIO_DEBUG1
00078 UDPLOG << "[CNetUdp - Destrutor] Start" << endl;
00079 #endif
00080
00081 #ifdef RIO_DEBUG1
00082 UDPLOG << "[CNetUdp - Destrutor] Finish" << endl;
00083 #endif
00084 }
00085
00086
00087
00088 RioResult CNetUdp::Start( SNetUdpConfig *NetConfig )
00089 {
00090 #ifdef RIO_DEBUG1
00091 UDPLOG << "[CNetUdp - Start] Start" << endl;
00092 #endif
00093
00094
00095 if( !m_Started )
00096 {
00097 #ifdef RIO_DEBUG2
00098 UDPLOG << "CNetUdp::Start o objeto ja foi inicializado." << endl;
00099 #endif
00100
00101 #ifdef RIO_DEBUG1
00102 UDPLOG << "[CNetUdp - Start] Finish1" << endl;
00103 #endif
00104
00105 return ERROR_NETTCP + ERROR_STARTED;
00106 }
00107
00108
00109 m_ServerInstance = NetConfig->isServer;
00110
00111
00112 if( m_ServerInstance )
00113 {
00114
00115 m_LogRotation = NetConfig->LogRotation;
00116 }
00117 else
00118 {
00119
00120 }
00121
00122 #ifdef RIO_DEBUG1
00123 UDPLOG << "[CNetUdp - Start] Finish2" << endl;
00124 #endif
00125
00126 return ERROR_NETUDP + ERROR_NOT_IMPLEMENTED;
00127
00128
00129
00130
00131
00132 }
00133
00134
00135
00136 RioResult CNetUdp::Stop()
00137 {
00138 #ifdef RIO_DEBUG1
00139 UDPLOG << "[CNetUdp - Stop] Start" << endl;
00140 #endif
00141
00142 #ifdef RIO_DEBUG1
00143 UDPLOG << "[CNetUdp - Stop] Start" << endl;
00144 #endif
00145
00146 return ERROR_NETUDP + ERROR_NOT_IMPLEMENTED;
00147
00148
00149
00150
00151
00152 }
00153
00154
00155 RioResult CNetUdp::SendData( int IP, int Port, char *Data,
00156 unsigned int DataSize, void *Param )
00157 {
00158 #ifdef RIO_DEBUG1
00159 UDPLOG << "[CNetUdp - SendData] Start" << endl;
00160 #endif
00161
00162 #ifdef RIO_DEBUG1
00163 UDPLOG << "[CNetUdp - SendData] Finish" << endl;
00164 #endif
00165
00166 return ERROR_NETUDP + ERROR_NOT_IMPLEMENTED;
00167 }
00168
00169
00170
00171 RioResult CNetUdp::GetIPAndPort( int *IP, int *Port, unsigned int Server )
00172 {
00173 #ifdef RIO_DEBUG1
00174 UDPLOG << "[CNetUdp - GetIPAndPort] Start" << endl;
00175 #endif
00176
00177 #ifdef RIO_DEBUG1
00178 UDPLOG << "[CNetUdp - GetIPAndPort] Finish" << endl;
00179 #endif
00180
00181 return ERROR_NETUDP + ERROR_NOT_IMPLEMENTED;
00182 }
00183
00184
00185
00186 RioResult CNetUdp::GetAllIPsAndPorts( int **IPs, int **Ports )
00187 {
00188 #ifdef RIO_DEBUG1
00189 UDPLOG << "[CNetUdp - GetAllIPsAndPorts] Start" << endl;
00190 #endif
00191
00192 #ifdef RIO_DEBUG1
00193 UDPLOG << "[CNetUdp - GetAllIPsAndPorts] Finish" << endl;
00194 #endif
00195
00196 return ERROR_NETUDP + ERROR_NOT_IMPLEMENTED;
00197 }
00198
00199
00200
00201 RioResult CNetUdp::FindIPAndPort( int IP, int Port, bool *isFound )
00202 {
00203 #ifdef RIO_DEBUG1
00204 UDPLOG << "[CNetUdp - FindIPAndPort] Start" << endl;
00205 #endif
00206
00207 #ifdef RIO_DEBUG1
00208 UDPLOG << "[CNetUdp - FindIPAndPort] Finish" << endl;
00209 #endif
00210
00211 return ERROR_NETUDP + ERROR_NOT_IMPLEMENTED;
00212 }
00213
00214
00215
00216 void CNetUdp::setLogRotation( CLogRotation *LogRotation )
00217 {
00218
00219
00220 m_LogRotation = LogRotation;
00221 }