我正在为不和谐的机器人制作报告系统,我希望玩家通过ID报告特定消息,以便主持人可以确定该消息是否令人反感。我正在努力寻找一种从给定ID获取消息文本的方法。有没有办法做到这一点?
#include <iostream>
#include <tins/tins.h>
using namespace Tins;
using namespace std;
bool callback(const PDU& pdu) {
// Find the IP layer
const IP& ip = pdu.rfind_pdu<IP>();
// Find the TCP layer
const TCP& tcp = pdu.rfind_pdu<TCP>();
cout << ip.src_addr() << ":" << tcp.sport() << " -> "
<< ip.dst_addr() << ":" << tcp.dport() << endl;
return true;
}
int main() {
Sniffer("eth0").sniff_loop(callback);
}
Run Code Online (Sandbox Code Playgroud)
我给了你默认的代码libtins,但由于某种原因Sniffer是未定义的。我已将所有库包含在链接器中。
当我构建时它也给了我以下错误:
-- Build started: Project: Packet Sniffing, Configuration: Debug x64 ------
1>Packet Sniffing.cpp …Run Code Online (Sandbox Code Playgroud)