R
R
Rainb262020-02-22 23:53:01
linux
Rainb26, 2020-02-22 23:53:01

How to find out Source and Destination addresses from MPLS type packet (pcap.h, c/c++)?

I'm trying to write a program that extracts information from a pcap file (similar to Wireshark).

if (ethernet->ether_type == 8)
      {
        printf("IPv4: src address: %s ",  inet_ntoa(ip->ip_src));
        printf("dest address: %s\n",  inet_ntoa(ip->ip_dst));
     }

This code works if the packet type is IPv4, if the packet type is different, inet_ntoa outputs invalid addresses.
According to Wireshark, I have most of the packets of the MPLS type.
The question is, how to print source and destination addresses for non-IPv4 packets?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CityCat4, 2020-02-23
@CityCat4

Obviously, read the RFC describing MPLS packets and what can be extracted from them, and whether there is a source and destination there at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question