コードで inet_ntop を使用して、オフラインでキャプチャされたファイルの IP アドレスを取得しています。エラーが発生しています
error LNK2019: unresolved external symbol "char const*__cdecl inet_ntop(int,void const *,char *,unsigned int)" (?inet_ntop@@YAPBDHPBXPADI@Z) referenced in function _main
ddd.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <iostream>
#include <pcap.h>
#include <ether.h>
#include <ip.h>
#include <ipnet.h>
#include <ipproto.h>
#include <tcp.h>
#include <udp.h>
#include <ethertype.h>
#include <tcpdump-stdinc.h>
using namespace std;
void PrintPacket(pcap_pkthdr * header, const u_char *data);
void PrintData(u_int startOctet, u_int endOctet, const u_char *data);
u_short get_ethertype_value(const u_char *data);
char * get_ethertype(const u_int16_t ethertype);
static u_int packetCount = 0;
#define SIZE_ETHERNET 14
int main(int argc, char *argv[])
{
string file = "C:\\Users\\legendkiller\\Documents\\Visual Studio 2010\\Projects\\new.pcap";
char errbuff[PCAP_ERRBUF_SIZE];
pcap_t * pcap = pcap_open_offline(file.c_str(), errbuff);
struct pcap_pkthdr *header;
const u_char *data;
while (int returnValue = pcap_next_ex(pcap, &header, &data) >= 0)
{
PrintPacket(header, data);
printf("Packet Details\n");
const struct ether_header *ethernet;
const struct ip* ipHeader;
char sourceIp[INET_ADDRSTRLEN];
char destIp[INET_ADDRSTRLEN];
ethernet = (struct ether_header*)(data);
// Print Destination Mac Address
printf("Dst MAC: ");
PrintData(0,5,ethernet->ether_dhost);
// Print Source Mac Address
printf("Src MAC: ", ethernet->ether_shost);
PrintData(0,5,ethernet->ether_shost);
// Print EtherType
u_short ethertype = ntohs(ethernet->ether_type);
printf("Ethertype: %s (%#.4x)\n", get_ethertype(ethertype), ethertype);
ipHeader = (struct ip*)(data + sizeof(struct ether_header));
inet_ntop(IPH_AF_INET, &(ipHeader->ip_src), sourceIp, INET_ADDRSTRLEN);
inet_ntop(IPH_AF_INET, &(ipHeader->ip_dst), destIp, INET_ADDRSTRLEN);
printf("sourceIp : %s\n", sourceIp);
printf("destIp :%s\n",destIp);
printf("\n\n");
}
}