mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
POSIX PCAP: Platform agnostic MAC address discovery
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#ifndef __MACADDR_DARWIN_H_
|
||||
#define __MACADDR_DARWIN_H_
|
||||
|
||||
#include <net/if_dl.h>
|
||||
|
||||
#define ICSNEO_AF_MACADDR (AF_LINK)
|
||||
|
||||
// Points towards the first byte of the MAC address, given a sockaddr*
|
||||
#define PLATFORM_MAC_FROM_SOCKADDR(SADDR) (((struct sockaddr_dl*)SADDR)->sdl_data + ((struct sockaddr_dl*)SADDR)->sdl_nlen)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef __MACADDR_LINUX_H_
|
||||
#define __MACADDR_LINUX_H_
|
||||
|
||||
#include <netpacket/packet.h>
|
||||
|
||||
#define ICSNEO_AF_MACADDR (AF_PACKET)
|
||||
|
||||
// Points towards the first byte of the MAC address, given a sockaddr*
|
||||
#define PLATFORM_MAC_FROM_SOCKADDR(SADDR) (((struct sockaddr_ll*)SADDR)->sll_addr)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef __MACADDR_POSIX_H_
|
||||
#define __MACADDR_POSIX_H_
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "icsneo/platform/posix/darwin/macaddr.h"
|
||||
#else
|
||||
#include "icsneo/platform/posix/linux/macaddr.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user