Learn More →
onvm_nflib
等 function
進行初始化,透過 DPDK_init
進行 DPDK EAL
環境的建構並執行 onvm_signal
與 manager
建立連線,這裡的連線指的是由 manger
指派的 core
、mempool
等資源的共享。
Learn More →
databasesFromFile
接手,讀取 Snort Rules
並將其解析、儲存於對應的結構體當中。
Learn More →
unordered_map
,將原規則中的變數置換為實體 IP
位址,並於載入完成後進行規則的編譯,將 protocol
、srcAddr
、srcPort
、dstAddr
、dstPort
,部分相同的規則編譯為對應的字元樹資料庫。
Learn More →
Snort Rules
與編譯完成的 DB
將會存在如下圖所示的全域變數結構體當中,並等待後續建構時的調用。
Learn More →
/* ACTION */
ACTION_ALERT
0x00
ACTION_LOG
0x01
ACTION_DROP
0x02
ACTION_REJECT
0x03
ACTION_SDROP
0x04
/* PROTOCOL */
IP_PROTOCOL_ICMP
0x01
IP_PROTOCOL_OTHER
0xFF
nf_setup
的部分,因為這裡我們採用的 scaling
方法是 Run-to-Completion
,因此每個 child thread
都必須根據 parent
儲存的全域變數 RuleHashMap
,建構自己的 Flow
解析器。
Learn More →
Tcp_parser
為例tcp
封包進入 parser
,首先以封包內 srcAddr
、srcPort
、dstAddr
、dstPort
,建構 FlowTuple
結構,並檢查 flow_map
。key
不存在則解析規則並記錄於 flow_map
中。flow_map
中 value
與 steams
內對應的狀態取出db
並於匹配時呼叫對應的 callback fucntion
ProtocolHashMp
*tcp_rules;
vector<unordered_map<FlowTuple, size_t, FlowTupleHash>>
stream_map;
hs_scratch_t
**scratch;
vector<vector<hs_stream_t *>>
streams;
unordered_map<FlowTuple, vector<int>, FlowTupleHash>
flow_map;
Learn More →
const FlowTuple header(ipv4, tcp->src_port, tcp->dst_port);
if (flow_map.find(header) == flow_map.end()) {
int index = 0;
for (it = tcp_rules->begin(); it != tcp_rules->end(); ++it, ++index) {
if (parseRule(it->first, header)) {
flow_map[header].push_back(index);
}
}
}
Learn More →
for (auto &index : flow_map.at(header)) {
it = next(tcp_rules->begin(), index);
stream_map[index].insert(make_pair(header, stream_map[index].size()));
err = hs_scan_stream(streams[index][stream_map[index].size()], payload, length, 0, *scratch, onMatch,
this);
if (err != HS_SUCCESS) {
cerr << "ERROR: Unable to scan tcp packet. Exiting." << endl;
exit(-1);
}
}
Learn More →
GitHub/MBP-bluetooth patchGitHub/MBP-sound driverGitHub/bluezGitHub/bluez-alsaGitHub/Bluez-GATT-HID-Keyboard-Emulator-ExampleGoogle Git/Fluoride
May 9, 2025{%hackmd theme-dark %} Server Hardware Dell PowerEdge R240 1U * 2 Laptop * 1 Hardware Info $lshw -class network -businfo //check PCI
May 24, 2021contributed by < Rsysz > Gameboy 模擬器 GitHub Intro 首先根據老師給予的 jitboy 內的描述,了解到當前模擬器有兩種較常見的實作方向。 一是模擬 Game boy 的環境,就能讓舊有的 ROM 順利執行,但缺點就是因 CPU instruction 不兼容,因此須將指令逐行翻譯,採用靜態編譯,因此 branch miss 將無法避免 第二種便是透過 JITcompiler 達成動態編譯,也就是在執行期才對下段指令編譯,因更好的效能而為多數模擬器所採用,相對於前者更消耗資源
Mar 19, 2021contributed by < Rsysz > {%hackmd theme-dark %} 編譯時期生成 lookup table 首先因為對 C++ 一竅不通,花了不少時間在研讀各種命名與定義,考慮到對 C++ 程式碼的理解,就先行撰寫 編譯時期生成 lookup table 的部分。 再來根據我查到的資料,撰寫 compile time table 通常會使用 constexpr ,而它是對於我們常見的 const 修飾子的加強,const 代表英文中 constant 常數的意思,代表被修飾的變數數值在編譯期(compile-time)已定,也無法再通過語法修改,任何對於標示為常數的變數的嘗試修改都會造成編譯器報錯。詳情請看 Reference 那我這邊也不多廢話,constexpr 的標準隨著 C++11, 14, 17 發展逐漸放寬,只要 constexpr 標記的函數內所有變數都能在編譯時期確認,那就能使用,因此可以透過對不同 table 撰寫不同的 Generator 大幅減少程式碼,同時保證程式的靈活度
Jan 15, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up