PacketInfo* parse(char* buf, int len) { cout << "parselib " << PROTO << endl; PacketInfo *pi = new PacketInfo; //ieee80211_radiotap_header *rtap_header = new ieee80211_radiotap_header; INSERT_TAG("version", 1, 0); INSERT_TAG("hdr_len", 2, 2); INSERT_TAG("presence", 4, 4); uint data_offset = (uint)TAG("hdr_len"); if (checkPresence(0, pi)) { // TSFT INSERT_TAG("tsft", 8, data_offset); data_offset += 8; } if (checkPresence(1, pi)) { // flags INSERT_TAG("flags", 1, data_offset); data_offset++; } if (checkPresence(2, pi)) { // Rate INSERT_TAG("rate", 1, data_offset); data_offset++; } if (checkPresence(3, pi)) { // Channel INSERT_TAG("channel.freq", 2, data_offset); INSERT_TAG("channel.flags", 2, data_offset+2); data_offset+=4; } if (checkPresence(4, pi)) { // FHSS INSERT_TAG("fhss.set", 1, data_offset); INSERT_TAG("fhss.pattern", 1, data_offset+1); data_offset+=2; } if (checkPresence(5, pi)) { // Antenna signal INSERT_TAG("ant_signal", 1, data_offset); data_offset++; } if (checkPresence(6, pi)) { // Antenna noise INSERT_TAG("ant_noise", 1, data_offset); data_offset++; } if (checkPresence(7, pi)) { // Lock quality INSERT_TAG("lock_quality", 2, data_offset); data_offset += 2; } if (checkPresence(8, pi)) { // TX attenuation INSERT_TAG("tx_att", 2, data_offset); data_offset+=2; } if (checkPresence(9, pi)) { // db TX attenuation INSERT_TAG("tx_att_db", 2, data_offset); data_offset+=2; } if (checkPresence(10, pi)) { // dBm TX power INSERT_TAG("tx_power", 1, data_offset); data_offset++; } if (checkPresence(11, pi)) { // Antenna INSERT_TAG("antenna", 1, data_offset); data_offset++; } if (checkPresence(12, pi)) { // dB antenna signal INSERT_TAG("ant_signal_db", 1, data_offset); data_offset++; } if (checkPresence(13, pi)) { // dB antenna noise INSERT_TAG("ant_noise_db", 1, data_offset); data_offset++; } if (checkPresence(14, pi)) { // RX flags INSERT_TAG("rx_flags", 2, data_offset); data_offset +=2; } INSERT_TAG("data", len - data_offset, data_offset); return pi; };
std::string DylibSearch::resolve(std::string dylib, MachOObject* requester) { if (dylib.empty()) return std::string(); // expand @rpath, @executable_path and @loader_path if (requester != nullptr && dylib[0] == '@') { if (dylib.compare(0, 16, "@executable_path") == 0) { MachOObject* mainModule = MachOMgr::instance()->mainModule(); if (!mainModule) throw std::runtime_error("Cannot resolve @executable_path without a main module"); dylib.replace(0, 16, mainModule->directory()); } else if (dylib.compare(0, 12, "@loader_path") == 0) { dylib.replace(0, 12, requester->directory()); } else if (dylib.compare(0, 6, "@rpath") == 0) { return resolveViaRpath(dylib, requester); } } // Search in configuration if (const char* aliasTarget = resolveAlias(dylib)) { std::string p; if (!strchr(aliasTarget, '/')) { p = LIB_PATH; p += '/'; p += aliasTarget; // std::cout << p << std::endl; } return p; } // Search in extra paths std::string epath; epath = resolveInPathList(dylib, m_extraPaths); if (!epath.empty()) return epath; // Search in DYLD_LIBRARY_PATH epath = resolveInLdPath(dylib); if (!epath.empty()) return epath; // Try the path as is epath = checkPresence(dylib); if (!epath.empty()) return epath; // If absolute, search in sysroot if (dylib[0] == '/') { const char* prefix = __prefix_get(); if (!MachOMgr::instance()->sysRoot().empty()) { std::vector<std::string> roots = string_explode(MachOMgr::instance()->sysRoot(), ':'); for (const std::string& in_path : roots) { std::string path; if (prefix != nullptr) path = prefix; path += in_path; path += '/'; path += dylib; epath = checkPresence(path); if (!epath.empty()) return epath; } } if (prefix != nullptr) { std::string path = prefix; path += dylib; epath = checkPresence(path); if (!epath.empty()) return epath; } } /*if (MachOMgr::instance()->ignoreMissingDependencies()) { }*/ return std::string(); }
std::string DylibSearch::resolve(std::string dylib, MachOObject* requester) { if (dylib.empty()) return std::string(); // expand @rpath, @executable_path and @loader_path if (requester != nullptr && dylib[0] == '@') { if (dylib.compare(0, 16, "@executable_path") == 0) { MachOObject* mainModule = MachOMgr::instance()->mainModule(); if (!mainModule) throw std::runtime_error("Cannot resolve @executable_path without a main module"); dylib.replace(0, 16, mainModule->directory()); } else if (dylib.compare(0, 12, "@loader_path") == 0) { dylib.replace(0, 12, requester->directory()); } else if (dylib.compare(0, 6, "@rpath") == 0) { return resolveViaRpath(dylib, requester); } } // Search in configuration if (const char* aliasTarget = resolveAlias(dylib)) return aliasTarget; // Search in extra paths std::string epath; epath = resolveInPathList(dylib, m_extraPaths); if (!epath.empty()) return epath; // Search in DYLD_LIBRARY_PATH epath = resolveInLdPath(dylib); if (!epath.empty()) return epath; // Try the path as is epath = checkPresence(dylib); if (!epath.empty()) return epath; // If absolute, search in sysroot if (dylib[0] == '/' && !MachOMgr::instance()->sysRoot().empty()) { std::string path = MachOMgr::instance()->sysRoot(); path += '/'; path += dylib; epath = checkPresence(path); if (!epath.empty()) return epath; } return std::string(); }