00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "IPEndpoint.h"
00012 #include <stdio.h>
00013 #include <iostream.h>
00014
00015
00016
00017
00018
00019
00020 IPEndpoint::IPEndpoint(int sbs, int rbs) :
00021 sharedSendBufferSize(sbs),
00022 sharedReceiveBufferSize(rbs)
00023 {
00024 ipStackRef = antStackRef("IPStack");
00025
00026
00027
00028 myOID_ = ProcessBase::theInstance->getOID();
00029
00030
00031
00032
00033 ProcessBase::theInstance->
00034 getAntInformation(listenContSelector,
00035 sendContSelector, receiveContSelector,
00036 closeContSelector, connectContSelector);
00037
00038
00039 antEnvCreateSharedBufferMsg sendBufferMsg(sharedSendBufferSize);
00040 sendBufferMsg.Call(ipStackRef, sizeof(sendBufferMsg));
00041
00042 if (sendBufferMsg.error != ANT_SUCCESS)
00043 {
00044 cout << "IPEndpoint: ANT Error creating send buffer \n";
00045 }
00046
00047 sendBuffer = sendBufferMsg.buffer;
00048 sendBuffer.Map();
00049 sharedSendBuffer = static_cast<byte*>(sendBuffer.GetAddress());
00050
00051
00052 antEnvCreateSharedBufferMsg receiveBufferMsg(sharedReceiveBufferSize);
00053 receiveBufferMsg.Call(ipStackRef, sizeof(receiveBufferMsg));
00054
00055 if (receiveBufferMsg.error != ANT_SUCCESS)
00056 {
00057 cout << "IPEndpoint: ANT Error creating receive buffer \n";
00058 }
00059
00060 receiveBuffer = receiveBufferMsg.buffer;
00061 receiveBuffer.Map();
00062 sharedReceiveBuffer = static_cast<byte*>(receiveBuffer.GetAddress());
00063
00064 cout << "IPEndpoint(): created sendBuffer with " << sharedSendBufferSize
00065 << " and receiveBuffer with " << sharedReceiveBufferSize << " bytes \n";
00066 }
00067
00068 IPEndpoint::~IPEndpoint()
00069 {
00070 sendBuffer.UnMap();
00071 receiveBuffer.UnMap();
00072
00073
00074
00075
00076
00077
00078 }
00079
00080 Out& operator<<(Out& stream, const IPAddress& ipAddress)
00081 {
00082 unsigned int address = ipAddress.Address();
00083
00084 stream << (address >> 24) << "."
00085 << (address >> 16 & 255) << "."
00086 << (address >> 8 & 255) << "."
00087 << (address & 255);
00088
00089 return(stream);
00090 }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128