44 #include <QNetworkInterface>
51 using namespace FIFFLIB;
69 : version(p_FiffId.version)
95 id.machid[0] = fixed_id[0];
96 id.machid[1] = fixed_id[1];
107 id.time.secs = QDateTime::currentMSecsSinceEpoch()/1000;
108 id.time.usecs = rand() % 1000;
128 QList<QString> possibleHardwareAdresses;
131 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
135 if ( !ifaces.isEmpty() ) {
136 for(
int i = 0; i < ifaces.size(); ++i) {
137 unsigned int flags = ifaces[i].flags();
138 bool isLoopback = (bool)(flags & QNetworkInterface::IsLoopBack);
139 bool isP2P = (bool)(flags & QNetworkInterface::IsPointToPoint);
140 bool isRunning = (bool)(flags & QNetworkInterface::IsRunning);
142 if ( !isRunning )
continue;
144 if ( !ifaces[i].isValid() || isLoopback || isP2P )
continue;
145 possibleHardwareAdresses << ifaces[i].hardwareAddress();
147 if (possibleHardwareAdresses.size() > 0) {
149 QStringList hexPresentation = possibleHardwareAdresses[0].split(
":");
150 if(hexPresentation.size() == 6) {
151 fixed_id[0] = QString(hexPresentation[0] + hexPresentation[1] + hexPresentation[2]).toInt(NULL,16);
152 fixed_id[1] = QString(hexPresentation[3] + hexPresentation[4] + hexPresentation[5]).toInt(NULL,16);
169 printf (
"%d %d ",this->
time.
secs,this->time.usecs);
177 QString strOut = QString(
"%1%2").arg(
machid[0],8,16,QChar(
'0')).arg(
machid[1],8,16,QChar(
'0'));
200 for(
int i=step;i < strOut.size(); i+=step+1)
202 strOut.insert(i,QChar(
':'));
205 return strOut.toUpper();
212 static FiffId defaultFiffId;
213 return defaultFiffId;