我试图做一个自制的系统来交换数据包,特别是在第二层,上面没有任何东西,在CentOS上.
我使用
问题是,当我的程序接收和发送数据包(因此使用pcap++和libcrafter)时,与类Packet (在libcrafter和Pcap++中都定义)存在冲突.
这是我的标题:
#include <stdio.h>
#include <iostream>
#include <getopt.h>
#include <stdlib.h>
#include <fstream>
#include <memory>
#include <pthread.h>
#include <errno.h>
#include <vector>
#include <string>
#include <sstream>
/**** LIBCRAFTER ******/
#include <MacAddress.h>
#include <IpAddress.h>
#include <PlatformSpecificUtils.h>
#include <PcapLiveDeviceList.h>
#include <PcapLiveDevice.h>
#include <EthLayer.h>
#include <PayloadLayer.h>
#include <Logger.h>
#include <in.h>
#include <PointerVector.h>
#include <crafter.h>
using namespace Crafter;
using namespace std;这是我的第一个错误:
server_resp.cpp: In function ‘int main(int, char**)’:
server_resp.cpp:74:3: error: reference to ‘Packet’ is ambiguous
Packet pack_decod(capturedPackets.getAndRemoveFromVector(position));
^
In file included from /home/myself/Downloads/PcapPlusPlus-master/Dist/header/PcapLiveDevice.h:9:0,
from /home/myself/Downloads/PcapPlusPlus-master/Dist/header/PcapLiveDeviceList.h:5,
from server_resp.cpp:16:
/home/myself/Downloads/PcapPlusPlus-master/Dist/header/Packet.h:19:7: note: candidates are: class Packet
class Packet {
^
In file included from /usr/local/include/crafter/Crafter.h:104:0,
from /usr/local/include/crafter.h:33,
from server_resp.cpp:23:
/usr/local/include/crafter/Packet.h:44:8: note: class Crafter::Packet
class Packet {
^我可以提供一个MME,但它很长(150行),我想保持简单的问题.
编辑:我还遇到了Ethernet类的问题
发布于 2015-09-01 10:18:43
在名称冲突这样的情况下,您实际上只能做两件事:
我倾向于将库包装在它自己的名称空间中。因为这是最不费劲的事。
最后,我建议对此进行修补,并将其邮寄给库的作者。这可能不是第一次发生,也不会是最后一次。
发布于 2017-06-23 23:01:53
请注意,现在PcapPlusPlus有了自己的名称空间(pcpp),因此这些冲突不应该再发生了。
https://stackoverflow.com/questions/32325639
复制相似问题