diff --git a/src/io/pibinarylog.cpp b/src/io/pibinarylog.cpp index 65954447..96d0e4a0 100644 --- a/src/io/pibinarylog.cpp +++ b/src/io/pibinarylog.cpp @@ -77,6 +77,9 @@ bool PIBinaryLog::openDevice() { piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly"; return false; } + if (path().isEmpty() && mode_ == WriteOnly) { + setPath(getLogfilePath()); + } if (!file.open(path(), mode_)) { piCoutObj << "Error: Can't open file" << path(); return false; @@ -177,8 +180,7 @@ bool PIBinaryLog::threadedRead(uchar *readed, int size) { } -PIString PIBinaryLog::createNewFile() { - if (!file.close()) return PIString(); +PIString PIBinaryLog::getLogfilePath() const { PIDir dir(logDir()); dir.setDir(dir.absolutePath()); if (!dir.isExists()) { @@ -192,6 +194,12 @@ PIString PIBinaryLog::createNewFile() { cnpath = npath + "_" + PIString::fromNumber(i) + ".binlog"; i++; } + return cnpath; +} + +PIString PIBinaryLog::createNewFile() { + if (!file.close()) return PIString(); + PIString cnpath = getLogfilePath(); if (open(cnpath, PIIODevice::WriteOnly)) { newFile(file.path()); return file.path(); diff --git a/src/io/pibinarylog.h b/src/io/pibinarylog.h index 8f23f8dd..41acc086 100644 --- a/src/io/pibinarylog.h +++ b/src/io/pibinarylog.h @@ -283,6 +283,7 @@ private: BinLogRecord readRecord(); static void parseLog(PIFile *f, BinLogInfo *info, PIVector * index); void moveIndex(int i); + PIString getLogfilePath() const; PIVector index; PIMap index_pos; diff --git a/src/io/piethernet.cpp b/src/io/piethernet.cpp index 7f5ca336..4a8223ff 100755 --- a/src/io/piethernet.cpp +++ b/src/io/piethernet.cpp @@ -799,13 +799,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() { while (pAdapter) { ci.name = PIString(pAdapter->AdapterName); ci.index = pAdapter->Index; - ci.address = PIString(pAdapter->IpAddressList.IpAddress.String); - if (ci.address == "0.0.0.0") { - pAdapter = pAdapter->Next; - continue; - } ci.mac = macFromBytes(PIByteArray(pAdapter->Address, pAdapter->AddressLength)); - ci.netmask = PIString(pAdapter->IpAddressList.IpMask.String); ci.flags = PIEthernet::ifActive | PIEthernet::ifRunning; //if (ret->ifa_flags & IFF_BROADCAST) ci.flags |= PIEthernet::ifBroadcast; //if (ret->ifa_flags & IFF_MULTICAST) ci.flags |= PIEthernet::ifMulticast; @@ -813,11 +807,22 @@ PIEthernet::InterfaceList PIEthernet::interfaces() { if (pAdapter->Type == MIB_IF_TYPE_LOOPBACK) ci.flags |= PIEthernet::ifLoopback; ci.broadcast.clear(); ci.ptp.clear(); + IP_ADDR_STRING * as = &(pAdapter->IpAddressList); + while (as) { +// piCout << "[pAdapter]" << ci.name << PIString(as->IpAddress.String); + ci.address = PIString(as->IpAddress.String); + ci.netmask = PIString(as->IpMask.String); + if (ci.address == "0.0.0.0") { + as = as->Next; + continue; + } + il << ci; + as = as->Next; + } /*if (ci.flags[PIEthernet::ifBroadcast]) ci.broadcast = getSockAddr(ret->ifa_broadaddr); if (ci.flags[PIEthernet::ifPTP]) ci.ptp = getSockAddr(ret->ifa_dstaddr);*/ - il << ci; pAdapter = pAdapter->Next; } } else @@ -1019,6 +1024,8 @@ PIStringList PIEthernet::allAddresses() { PIStringList al; piForeachC (PIEthernet::Interface & i, il) al << i.address; +// piCout << "[PIEthernet::allAddresses]" << al; + if (!al.contains("127.0.0.1")) al << "127.0.0.1"; return al.removeStrings("0.0.0.0"); //#endif } diff --git a/src/io/pipeer.cpp b/src/io/pipeer.cpp index d4fc432d..daacba57 100755 --- a/src/io/pipeer.cpp +++ b/src/io/pipeer.cpp @@ -789,16 +789,18 @@ void PIPeer::reinit() { void PIPeer::initNetwork() { - piCoutObj << "initNetwork ..."; +// piCoutObj << "initNetwork ..."; eth_send.init(); destroyEths(); destroyMBcasts(); +// piCoutObj << self_info.addresses.size(); self_info.addresses.clear(); PIStringList sl = PIEthernet::allAddresses(); initEths(sl); +// piCoutObj << sl << self_info.addresses.size(); sl.removeAll("127.0.0.1"); initMBcasts(sl); - piCoutObj << "initNetwork done"; +// piCoutObj << "initNetwork done"; } diff --git a/src/pip.h b/src/pip.h index 5e553e5e..07a158b8 100755 --- a/src/pip.h +++ b/src/pip.h @@ -20,13 +20,13 @@ #ifndef PIP_H #define PIP_H -#include "pip/picoremodule.h" -#include "pip/picontainersmodule.h" -#include "pip/piconsolemodule.h" -#include "pip/pithreadmodule.h" -#include "pip/piiomodule.h" -#include "pip/pimathmodule.h" -#include "pip/pigeomodule.h" -#include "pip/pisystemmodule.h" +#include "picoremodule.h" +#include "picontainersmodule.h" +#include "piconsolemodule.h" +#include "pithreadmodule.h" +#include "piiomodule.h" +#include "pimathmodule.h" +#include "pisystemmodule.h" +#include "pigeomodule.h" #endif // PIP_H