fehQlibs 26
Qlibs
Loading...
Searching...
No Matches
socket_if.c
Go to the documentation of this file.
1#include <sys/types.h>
2#include <sys/param.h>
3#include <sys/socket.h>
4#include <netinet/in.h>
5#include <net/if.h>
6#include "socket_if.h"
7
15const unsigned char V4loopback[4] = {127,0,0,1};
16const unsigned char V4localnet[4] = {0,0,0,0};
17/* the 'V4mappedprefix' constant is needed by 'ip.a' too */
18const unsigned char V4mappedprefix[12] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff};
19const unsigned char V6localnet[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
20const unsigned char V6loopback[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1};
21
22uint32 socket_getifidx(const char *ifname)
23{
24 return if_nametoindex(ifname);
25}
26
27static char ifname[IFNAMSIZ];
28
29const char* socket_getifname(uint32 scope_id)
30{
31 char *tmp = if_indextoname(scope_id,ifname);
32 if (tmp)
33 return tmp;
34 else
35 return "[unknown]";
36}
uint32 socket_getifidx(const char *ifname)
Definition: socket_if.c:22
const unsigned char V6loopback[16]
Definition: socket_if.c:20
const unsigned char V4loopback[4]
Definition: socket_if.c:15
const unsigned char V4localnet[4]
Definition: socket_if.c:16
const unsigned char V4mappedprefix[12]
Definition: socket_if.c:18
const unsigned char V6localnet[16]
Definition: socket_if.c:19
const char * socket_getifname(uint32 scope_id)
Definition: socket_if.c:29
uint32_t uint32
Definition: uint_t.h:40