Videobearbeitung

FFmpeg
VirtualDub

How to flip a video 180° (vertical/upside down) with FFmpeg?
Videofilm um 180 Grad drehen?

$ ffmpeg -i VID_20150227_105125.mp4 -vf "rotate=PI:bilinear=0,format=yuv420p" -m                                                                                                                                  etadata:s:v rotate=0 -codec:v libx264 -codec:a copy VID_20150227_105125_180.mp4
ffmpeg version N-70348-g9564375 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3                                                                                                                                   --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --ena                                                                                                                                  ble-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --e                                                                                                                                  nable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-lib                                                                                                                                  gsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencor                                                                                                                                  e-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enabl                                                                                                                                  e-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-l                                                                                                                                  ibtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-                                                                                                                                  libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-l                                                                                                                                  ibwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --ena                                                                                                                                  ble-lzma --enable-decklink --enable-zlib
  libavutil      54. 19.100 / 54. 19.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 23.106 / 56. 23.106
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VID_20150227_105125.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: isom3gp4
    creation_time   : 2015-02-27 09:52:53
    location        : +47.4959+008.7180/
    location-eng    : +47.4959+008.7180/
  Duration: 00:01:26.44, start: 0.000000, bitrate: 14490 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu                                                                                                                                  vj420p(pc), 1280x720, 14400 kb/s, SAR 1:1 DAR 16:9, 29.99 fps, 30 tbr, 90k tbn,                                                                                                                                   25 tbc (default)
    Metadata:
      rotate          : 180
      creation_time   : 2015-02-27 09:52:53
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of 180.00 degrees
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt                                                                                                                                  p, 96 kb/s (default)
    Metadata:
      creation_time   : 2015-02-27 09:52:53
      handler_name    : SoundHandle
[swscaler @ 0000000000554320] deprecated pixel format used, make sure you did se                                                                                                                                  t range correctly
[libx264 @ 0000000002e60860] using SAR=1/1
[libx264 @ 0000000002e60860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2                                                                                                                                   AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0000000002e60860] profile High, level 3.1
[libx264 @ 0000000002e60860] 264 - core 144 r2525 40bb568 - H.264/MPEG-4 AVC cod                                                                                                                                  ec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 r                                                                                                                                  ef=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed                                                                                                                                  _ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pski                                                                                                                                  p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci                                                                                                                                  mate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_                                                                                                                                  adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=2                                                                                                                                  5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.6                                                                                                                                  0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'VID_20150227_105125_180.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: isom3gp4
    location-eng    : +47.4959+008.7180/
    location        : +47.4959+008.7180/
    encoder         : Lavf56.23.106
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1                                                                                                                                  280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandle
      creation_time   : 2015-02-27 09:52:53
      rotate          : 0
      encoder         : Lavc56.26.100 libx264
    Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 96                                                                                                                                   kb/s (default)
    Metadata:
      creation_time   : 2015-02-27 09:52:53
      handler_name    : SoundHandle
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   47 fps=0.0 q=0.0 size=       0kB time=00:00:02.04 bitrate=   0.2kbits/s                                                                                                                                  frame=   61 fps= 55 q=29.0 size=     111kB time=00:00:02.04 bitrate= 443.1kbits/                                                                                                                                  frame=   73 fps= 45 q=29.0 size=     181kB time=00:00:02.04 bitrate= 724.3kbits/                                                                                                                                  frame=   85 fps= 40 q=29.0 size=     276kB time=00:00:02.04 bitrate=1102.9kbits/                                                                                                                                  frame=   96 fps= 36 q=29.0 size=     352kB time=00:00:04.05 bitrate= 710.4kbits/                                                                                                                                  frame=  109 fps= 34 q=29.0 size=     452kB time=00:00:04.05 bitrate= 913.9kbits/                                                                                                                                  frame=  121 fps= 33 q=29.0 size=     528kB time=00:00:05.05 bitrate= 855.1kbits/                                                                                                                                  frame= 2585 fps= 19 q=-1.0 Lsize=   25078kB time=00:01:26.44 bitrate=2376.6kbits/s
video:23971kB audio:1014kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.375647%
[libx264 @ 0000000002e60860] frame I:14    Avg QP:21.65  size: 33711
[libx264 @ 0000000002e60860] frame P:1166  Avg QP:24.39  size: 14372
[libx264 @ 0000000002e60860] frame B:1405  Avg QP:26.87  size:  5206
[libx264 @ 0000000002e60860] consecutive B-frames: 10.7% 43.2% 22.2% 24.0%
[libx264 @ 0000000002e60860] mb I  I16..4: 16.7% 70.9% 12.3%
[libx264 @ 0000000002e60860] mb P  I16..4:  3.7%  9.8%  1.0%  P16..4: 51.8% 10.3%  4.8%  0.0%  0.0%    skip:18.7%
[libx264 @ 0000000002e60860] mb B  I16..4:  0.3%  0.9%  0.1%  B16..8: 43.4%  3.4%  0.5%  direct: 2.0%  skip:49.3%  L0:43.8% L1:53.0% BI: 3.2%
[libx264 @ 0000000002e60860] 8x8 transform intra:67.6% inter:82.2%
[libx264 @ 0000000002e60860] coded y,uvDC,uvAC intra: 44.9% 57.4% 10.9% inter: 14.2% 21.4% 0.2%
[libx264 @ 0000000002e60860] i16 v,h,dc,p: 24% 26% 13% 37%
[libx264 @ 0000000002e60860] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 17% 25%  5%  6%  6%  9%  8%  5%
[libx264 @ 0000000002e60860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 23% 16%  4%  7%  7% 11%  6%  3%
[libx264 @ 0000000002e60860] i8c dc,h,v,p: 55% 19% 20%  6%
[libx264 @ 0000000002e60860] Weighted P-Frames: Y:7.2% UV:2.7%
[libx264 @ 0000000002e60860] ref P L0: 65.0% 14.3% 15.0%  5.6%  0.2%
[libx264 @ 0000000002e60860] ref B L0: 83.6% 14.7%  1.7%
[libx264 @ 0000000002e60860] ref B L1: 94.2%  5.8%
[libx264 @ 0000000002e60860] kb/s:2278.86

Format Time of File Modification to use in a Shell Script

$ ls -l --full-time make.sh
-rw-------+ 1 AndreasB mkpasswd 5772 2015-02-12 11:35:54.323703100 +0100 make.sh

$ perl -MPOSIX=strftime -le 'print strftime("%Y%m%d", localtime((stat shift)[9]))' make.sh
20150212

$ stat make.sh
  File: 'make.sh'
  Size: 5772            Blocks: 8          IO Block: 65536  regular file
Device: 7a51ec0fh/2052189199d   Inode: 12384898975415113  Links: 1
Access: (0600/-rw-------)  Uid: (  400/AndreasB)   Gid: (  401/mkpasswd)
Access: 2015-02-12 11:35:54.323703100 +0100
Modify: 2015-02-12 11:35:54.323703100 +0100
Change: 2015-02-13 14:48:31.352376000 +0100
 Birth: 2014-11-26 17:16:45.173977800 +0100

$ stat -c %y make.sh
2015-02-12 11:35:54.323703100 +0100

$ stat -c %x make.sh
2015-02-12 11:35:54.323703100 +0100

file date format
HowTo Format Date For Display or Use In a Shell Script

IPv6 in FreeBSD/Linux

FreeBSD Subversion

Subversion Mirror Sites

FreeBSD VLAN

FreeBSD VLAN Configuration
FreeBSD – Adding VLAN Tagged subinterface using ifconfig

struct  vlanreq {
    char    vlr_parent[IFNAMSIZ];
    u_short vlr_tag;
};
Step 1: create the vlan subinterface
# ifconfig vlan122 create

Step 2: assign it a vlan ID and vlan device:
# ifconfig vlan122 vlan 122 vlandev em0

Step 3: check the vlan subinterface:
# ifconfig vlan122
vlan122: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:07:e9:a5:9b:fa
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 122 parent interface: em0

Step 4: assign ip address:
# ifconfig vlan122 10.1.122.1/24
# ifconfig vlan122 up
# ifconfig vlan122
vlan122: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:07:e9:a5:9b:fa
        inet 10.1.122.1 netmask 0xffffff00 broadcast 10.1.122.255
        media: Ethernet autoselect (1000baseTX <full-duplex>)
        status: active
        vlan: 122 parent interface: em0

Or edit rc.conf:
cloned_interfaces="vlan0"
ifconfig_vlan0="inet x.x.x.x netmask y.y.y.y vlan 2 vlandev em0"

FreeBSD Manual Pages

getifaddrs — get interface addresses
ether_ntohost — Ethernet address conversion and lookup routines

FreeBSD Implementation

DEC Direct Data Link Interface (DLI)
How to know ip address for interfaces in c
Polling interface names via SIOCGIFCONF in Linux
Broadcasting and Determining Network Configuration
FreeBSD: network interface information
lo0 not in ioctl( SIOCGIFCONF )
SOLVED: lo0 not in ioctl( SIOCGIFCONF )
How to get IPv6 address using getifaddrs and which version of glibc supports
How can I enumerate the list of network devices or interfaces in C or C++ in FreeBSD? [duplicate]
Re: ioctl programming probs

getifaddrs.c

Linux:
struct ifreq {
    char ifr_name[IFNAMSIZ]; /* Interface name */
    union {
        struct sockaddr ifr_addr;
        struct sockaddr ifr_dstaddr;
        struct sockaddr ifr_broadaddr;
        struct sockaddr ifr_netmask;
        struct sockaddr ifr_hwaddr;
        short           ifr_flags;
        int             ifr_ifindex;
        int             ifr_metric;
        int             ifr_mtu;
        struct ifmap    ifr_map;
        char            ifr_slave[IFNAMSIZ];
        char            ifr_newname[IFNAMSIZ];
        char           *ifr_data;
    };
};

struct ifconf {
    int                 ifc_len; /* size of buffer */
    union {
        char           *ifc_buf; /* buffer address */
        struct ifreq   *ifc_req; /* array of structures */
    };
};

FreeBSD:

/*
 * Length of interface external name, including terminating '\0'.
 * Note: this is the same size as a generic device's external name.
 */
#define         IF_NAMESIZE     16
#if __BSD_VISIBLE
#define         IFNAMSIZ        IF_NAMESIZE
#define         IF_MAXUNIT      0x7fff  /* historical value */
#endif
#if __BSD_VISIBLE

/*
 * Interface request structure used for socket
 * ioctl's.  All interface ioctl's must have parameter
 * definitions which begin with ifr_name.  The
 * remainder may be interface specific.
 */
struct  ifreq {
        char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */
        union {
                struct  sockaddr ifru_addr;
                struct  sockaddr ifru_dstaddr;
                struct  sockaddr ifru_broadaddr;
                struct  ifreq_buffer ifru_buffer;
                short   ifru_flags[2];
                short   ifru_index;
                int     ifru_jid;
                int     ifru_metric;
                int     ifru_mtu;
                int     ifru_phys;
                int     ifru_media;
                caddr_t ifru_data;
                int     ifru_cap[2];
                u_int   ifru_fib;
        } ifr_ifru;
#define ifr_addr        ifr_ifru.ifru_addr      /* address */
#define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
#define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_buffer      ifr_ifru.ifru_buffer    /* user supplied buffer with its length */
#define ifr_flags       ifr_ifru.ifru_flags[0]  /* flags (low 16 bits) */
#define ifr_flagshigh   ifr_ifru.ifru_flags[1]  /* flags (high 16 bits) */
#define ifr_jid         ifr_ifru.ifru_jid       /* jail/vnet */
#define ifr_metric      ifr_ifru.ifru_metric    /* metric */
#define ifr_mtu         ifr_ifru.ifru_mtu       /* mtu */
#define ifr_phys        ifr_ifru.ifru_phys      /* physical wire */
#define ifr_media       ifr_ifru.ifru_media     /* physical media */
#define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
#define ifr_reqcap      ifr_ifru.ifru_cap[0]    /* requested capabilities */
#define ifr_curcap      ifr_ifru.ifru_cap[1]    /* current capabilities */
#define ifr_index       ifr_ifru.ifru_index     /* interface index */
#define ifr_fib         ifr_ifru.ifru_fib       /* interface fib */
};


/*
 * Structure used in SIOCGIFCONF request.
 * Used to retrieve interface configuration
 * for machine (useful for programs which
 * must know all networks accessible).
 */
struct  ifconf {
        int     ifc_len;                /* size of associated buffer */
        union {
                caddr_t ifcu_buf;
                struct  ifreq *ifcu_req;
        } ifc_ifcu;
#define ifc_buf ifc_ifcu.ifcu_buf       /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
};

/*-
 * Interface flags are of two types: network stack owned flags, and driver
 * owned flags.  Historically, these values were stored in the same ifnet
 * flags field, but with the advent of fine-grained locking, they have been
 * broken out such that the network stack is responsible for synchronizing
 * the stack-owned fields, and the device driver the device-owned fields.
 * Both halves can perform lockless reads of the other half's field, subject
 * to accepting the involved races.
 *
 * Both sets of flags come from the same number space, and should not be
 * permitted to conflict, as they are exposed to user space via a single
 * field.
 *
 * The following symbols identify read and write requirements for fields:
 *
 * (i) if_flags field set by device driver before attach, read-only there
 *     after.
 * (n) if_flags field written only by the network stack, read by either the
 *     stack or driver.
 * (d) if_drv_flags field written only by the device driver, read by either
 *     the stack or driver.
 */
#define IFF_UP          0x1             /* (n) interface is up */
#define IFF_BROADCAST   0x2             /* (i) broadcast address valid */
#define IFF_DEBUG       0x4             /* (n) turn on debugging */
#define IFF_LOOPBACK    0x8             /* (i) is a loopback net */
#define IFF_POINTOPOINT 0x10            /* (i) is a point-to-point link */
#define IFF_SMART       0x20            /* (i) interface manages own routes */
#define IFF_DRV_RUNNING 0x40            /* (d) resources allocated */
#define IFF_NOARP       0x80            /* (n) no address resolution protocol */
#define IFF_PROMISC     0x100           /* (n) receive all packets */
#define IFF_ALLMULTI    0x200           /* (n) receive all multicast packets */
#define IFF_DRV_OACTIVE 0x400           /* (d) tx hardware queue is full */
#define IFF_SIMPLEX     0x800           /* (i) can't hear own transmissions */
#define IFF_LINK0       0x1000          /* per link layer defined bit */
#define IFF_LINK1       0x2000          /* per link layer defined bit */
#define IFF_LINK2       0x4000          /* per link layer defined bit */
#define IFF_ALTPHYS     IFF_LINK2       /* use alternate physical connection */
#define IFF_MULTICAST   0x8000          /* (i) supports multicast */
#define IFF_CANTCONFIG  0x10000         /* (i) unconfigurable using ioctl(2) */
#define IFF_PPROMISC    0x20000         /* (n) user-requested promisc mode */
#define IFF_MONITOR     0x40000         /* (n) user-requested monitor mode */
#define IFF_STATICARP   0x80000         /* (n) static ARP */
#define IFF_DYING       0x200000        /* (n) interface is winding down */
#define IFF_RENAMING    0x400000        /* (n) interface is being renamed */
/* Throughout this file, IP addresses are expected to be in
 * the same byte order as in IP_PCB. */

/** must be the maximum of all used hardware address lengths
    across all types of interfaces in use */
#define NETIF_MAX_HWADDR_LEN 6U

/** Whether the network interface is 'up'. This is
 * a software flag used to control whether this network
 * interface is enabled and processes traffic.
 * It is set by the startup code (for static IP configuration) or
 * by dhcp/autoip when an address has been assigned.
 */
#define NETIF_FLAG_UP           0x01U
/** If set, the netif has broadcast capability.
 * Set by the netif driver in its init function. */
#define NETIF_FLAG_BROADCAST    0x02U
/** If set, the netif is one end of a point-to-point connection.
 * Set by the netif driver in its init function. */
#define NETIF_FLAG_POINTTOPOINT 0x04U
/** If set, the interface is configured using DHCP.
 * Set by the DHCP code when starting or stopping DHCP. */
#define NETIF_FLAG_DHCP         0x08U
/** If set, the interface has an active link
 *  (set by the network interface driver).
 * Either set by the netif driver in its init function (if the link
 * is up at that time) or at a later point once the link comes up
 * (if link detection is supported by the hardware). */
#define NETIF_FLAG_LINK_UP      0x10U
/** If set, the netif is an ethernet device using ARP.
 * Set by the netif driver in its init function.
 * Used to check input packet types and use of DHCP. */
#define NETIF_FLAG_ETHARP       0x20U
/** If set, the netif is an ethernet device. It might not use
 * ARP or TCP/IP if it is used for PPPoE only.
 */
#define NETIF_FLAG_ETHERNET     0x40U
/** If set, the netif has IGMP capability.
 * Set by the netif driver in its init function. */
#define NETIF_FLAG_IGMP         0x80U

/** Generic data structure used for all lwIP network interfaces.
 *  The following fields should be filled in by the initialization
 *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
struct netif {
    /** pointer to next in linked list */
    struct netif *next;
    
    /** IP address configuration in network byte order */
    ip_addr_t ip_addr;
    ip_addr_t netmask;
    ip_addr_t gw;
    
    /*** LWIP_IPV6 ***********************************************************/
    /** Array of IPv6 addresses for this netif. */
    ip6_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES];
    /** The state of each IPv6 address (Tentative, Preferred, etc).
     * @see ip6_addr.h */
    u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES];

    /** This function is called by the network device driver
     *  to pass a packet up the TCP/IP stack. */
    netif_input_fn input;
    /** This function is called by the IP module when it wants
     *  to send a packet on the interface. This function typically
     *  first resolves the hardware address, then sends the packet. */
    netif_output_fn output;
    /** This function is called by the ARP module when it wants
     *  to send a packet on the interface. This function outputs
     *  the pbuf as-is on the link medium. */
    netif_linkoutput_fn linkoutput;
    
    /*** LWIP_IPV6 ***********************************************************/
    /** This function is called by the IPv6 module when it wants
     *  to send a packet on the interface. This function typically
     *  first resolves the hardware address, then sends the packet. */
     netif_output_ip6_fn output_ip6;
    
    /*** LWIP_NETIF_STATUS_CALLBACK ******************************************/
    /** This function is called when the netif state is set to up or down */
    netif_status_callback_fn status_callback;
    
    /*** LWIP_NETIF_LINK_CALLBACK ********************************************/
    /** This function is called when the netif link is set to up or down */
    netif_status_callback_fn link_callback;
    
    /*** LWIP_NETIF_REMOVE_CALLBACK ******************************************/
    /** This function is called when the netif has been removed */
    netif_status_callback_fn remove_callback;
    
    /** This field can be set by the device driver and could point
     *  to state information for the device. */
    void *state;
    
    /*** LWIP_DHCP ***********************************************************/
    /** the DHCP client state information for this netif */
    struct dhcp *dhcp;
    
    /*** LWIP_AUTOIP *********************************************************/
    /** the AutoIP client state information for this netif */
    struct autoip *autoip;
    
    /*** LWIP_IPV6_AUTOCONFIG ************************************************/
    /** is this netif enabled for IPv6 autoconfiguration */
    u8_t ip6_autoconfig_enabled;
    
    /*** LWIP_IPV6_SEND_ROUTER_SOLICIT ***************************************/
    /** Number of Router Solicitation messages that remain to be sent. */
    u8_t rs_count;
    
    /*** LWIP_IPV6_DHCP6 *****************************************************/
    /** the DHCPv6 client state information for this netif */
    struct dhcp6 *dhcp6;
    
    /*** LWIP_NETIF_HOSTNAME *************************************************/
    /* the hostname for this netif, NULL is a valid value */
    char*  hostname;
    
    /** maximum transfer unit (in bytes) */
    u16_t mtu;
    /** number of bytes used in hwaddr */
    u8_t hwaddr_len;
    /** link level hardware address of this interface */
    u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
    /** flags (see NETIF_FLAG_ above) */
    u8_t flags;
    /** descriptive abbreviation */
    char name[2];
    /** number of this interface */
    u8_t num;
    
    /*** LWIP_SNMP ***********************************************************/
    /** link type (from "snmp_ifType" enum from snmp.h) */
    u8_t link_type;
    /** (estimate) link speed */
    u32_t link_speed;
    /** timestamp at last change made (up/down) */
    u32_t ts;
    /** counters */
    u32_t ifinoctets;
    u32_t ifinucastpkts;
    u32_t ifinnucastpkts;
    u32_t ifindiscards;
    u32_t ifoutoctets;
    u32_t ifoutucastpkts;
    u32_t ifoutnucastpkts;
    u32_t ifoutdiscards;
    
    /*** LWIP_IGMP ***********************************************************/
    /** This function could be called to add or delete a entry in the multicast
     *  filter table of the ethernet MAC.*/
    netif_igmp_mac_filter_fn igmp_mac_filter;
    
    /*** LWIP_IPV6 && LWIP_IPV6_MLD ******************************************/
    /** This function could be called to add or delete an entry in the IPv6 multicast
     *  filter table of the ethernet MAC. */
    netif_mld_mac_filter_fn mld_mac_filter;
    
    /*** LWIP_NETIF_HWADDRHINT ***********************************************/
    u8_t *addr_hint;
    
    /*** ENABLE_LOOPBACK *****************************************************/
    /* List of packets to be queued for ourselves. */
    struct pbuf *loop_first;
    struct pbuf *loop_last;
    
    u16_t loop_cnt_current;
};
#define SIOCSIFPHYADDR   _IOW('i', 70, struct ifaliasreq) /* set gif addres */
#define SIOCGIFPSRCADDR _IOWR('i', 71, struct ifreq)    /* get gif psrc addr */
#define SIOCGIFPDSTADDR _IOWR('i', 72, struct ifreq)    /* get gif pdst addr */
struct nd_ifinfo {
    u_int32_t linkmtu;              /* LinkMTU */
    u_int32_t maxmtu;               /* Upper bound of LinkMTU */
    u_int32_t basereachable;        /* BaseReachableTime */
    u_int32_t reachable;            /* Reachable Time */
    u_int32_t retrans;              /* Retrans Timer */
    u_int32_t flags;                /* Flags */
    int recalctm;                   /* BaseReacable re-calculation timer */
    u_int8_t chlim;                 /* CurHopLimit */
    u_int8_t initialized;           /* Flag to see the entry is initialized */
    
    /* the following 3 members are for privacy extension for addrconf */
    u_int8_t randomseed0[8];        /* upper 64 bits of MD5 digest */
    u_int8_t randomseed1[8];        /* lower 64 bits (usually the EUI64 IFID) */
    u_int8_t randomid[8];           /* current random ID */
};

struct  in6_ndireq {
    char ifname[IFNAMSIZ];
    struct nd_ifinfo ndi;
};

struct in6_ndireq nd;

memset(&nd, 0, sizeof(nd));
strncpy(nd.ifname, ifr.ifr_name, sizeof(nd.ifname));
error = ioctl(s, SIOCGIFINFO_IN6, &nd);
/*
 * Structure of a Link-Level sockaddr:
 */
struct sockaddr_dl {
        u_char  sdl_len;        /* Total length of sockaddr */
        u_char  sdl_family;     /* AF_LINK */
        u_short sdl_index;      /* if != 0, system given index for interface */
        u_char  sdl_type;       /* interface type */
        u_char  sdl_nlen;       /* interface name length, no trailing 0 reqd. */
        u_char  sdl_alen;       /* link level address length */
        u_char  sdl_slen;       /* link layer selector length */
        char    sdl_data[46];   /* minimum work area, can be larger;
                                   contains both if name and ll address */
};
$2  = {sdl_len = 56 '8', sdl_family = 18 (AF_LINK), sdl_index = 1, sdl_type = 0x06 (IFT_ETHER), sdl_nlen = 3, sdl_alen = 6, sdl_slen = 0, sdl_data = "vr0", ...}
$13 = {sdl_len = 56 '8', sdl_family = 18 (AF_LINK), sdl_index = 2, sdl_type = 0x06 (IFT_ETHER), sdl_nlen = 3, sdl_alen = 6, sdl_slen = 0, sdl_data = "vr1", ...}
$14 = {sdl_len = 56 '8', sdl_family = 18 (AF_LINK), sdl_index = 3, sdl_type = 0x06 (IFT_ETHER), sdl_nlen = 3, sdl_alen = 6, sdl_slen = 0, sdl_data = "vr2", ...}
$15 = {sdl_len = 56 '8', sdl_family = 18 (AF_LINK), sdl_index = 4, sdl_type = 0x18 (IFT_LOOP),  sdl_nlen = 3, sdl_alen = 0, sdl_slen = 0, sdl_data = "lo0", ...}
$16 = {sdl_len = 56 '8', sdl_family = 18 (AF_LINK), sdl_index = 5, sdl_type = 0xf6 (IFT_PFLOG), sdl_nlen = 6, sdl_alen = 0, sdl_slen = 0, sdl_data = "pflog0", ...}

sdl->sdl_nlen   /* interface name length, no trailing 0 reqd. */
sdl->sdl_alen   /* link level address length */

sdl->sdl_type:
/usr/include/net/if_types.h
#define	IFT_ETHER	0x6		/* Ethernet CSMA/CD */
#define	IFT_LOOP	0x18		/* loopback */
#define	IFT_PFLOG	0xf6            /* PF firewall */
#define ETH_ALEN	6		/* Octets in one ethernet addr	 */
Linux:

#define ETHER_ADDR_LEN  ETH_ALEN                 /* size of ethernet addr */

/* This is a name for the 48 bit ethernet address available on many
   systems.  */
struct ether_addr
{
  u_int8_t ether_addr_octet[ETH_ALEN];
} __attribute__ ((__packed__));


FreeBSD:
/*
* The number of bytes in an	ethernet (MAC) address.
*/
#define ETHER_ADDR_LEN	   6

/*
* Structure	of a 48-bit Ethernet address.
*/
struct  ether_addr {
   u_char octet[ETHER_ADDR_LEN];
};

Do SIOCGIFNUM ioctl to find the number of interfaces

/*
 * Do SIOCGIFNUM ioctl to find the number of interfaces
 *
 * Allocate space for number of interfaces found
 *
 * Do SIOCGIFCONF with allocated buffer
 *
 */
if (ioctl(s, SIOCGIFNUM, (char *)&numifs) == -1) {
    numifs = MAXIFS;
}
bufsize = numifs * sizeof(struct ifreq);
reqbuf = (struct ifreq *) malloc(bufsize);
if (reqbuf == NULL) {
    fprintf(stderr, "out of memory\n");
    exit(1);
}
ifc.ifc_buf = (caddr_t)&reqbuf[0];
ifc.ifc_len = bufsize;
if (ioctl(s, SIOCGIFCONF, (char *)&ifc) == -1) {
    perror("ioctl(SIOCGIFCONF)");
    exit(1);
}

ioctl(sockfd, SIOCGIFCONF, &ifc)