2014-12-18 18:50:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
2015-05-12 06:31:13 +00:00
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
2014-12-18 18:50:47 +00:00
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
*/
|
2014-08-20 20:27:41 +00:00
|
|
|
|
2014-09-10 01:54:53 +00:00
|
|
|
#pragma once
|
2014-08-20 20:27:41 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <ifaddrs.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2014-11-16 21:59:19 +00:00
|
|
|
namespace osquery {
|
|
|
|
namespace tables {
|
|
|
|
|
2015-01-11 08:39:16 +00:00
|
|
|
// Define AF_INTERFACE as the alias for interface details.
|
2015-05-07 04:58:23 +00:00
|
|
|
#ifdef __linux__
|
2015-01-11 08:39:16 +00:00
|
|
|
#define AF_INTERFACE AF_PACKET
|
2015-05-07 04:58:23 +00:00
|
|
|
#else
|
|
|
|
#define AF_INTERFACE AF_LINK
|
2015-01-11 08:39:16 +00:00
|
|
|
#endif
|
|
|
|
|
2014-08-20 20:27:41 +00:00
|
|
|
// Return a string representation for an IPv4/IPv6 struct.
|
2014-11-16 21:59:19 +00:00
|
|
|
std::string ipAsString(const struct sockaddr *in);
|
2015-05-10 00:32:24 +00:00
|
|
|
std::string ipAsString(const struct in_addr *in);
|
2014-11-16 21:59:19 +00:00
|
|
|
std::string macAsString(const struct ifaddrs *addr);
|
|
|
|
std::string macAsString(const char *addr);
|
|
|
|
int netmaskFromIP(const struct sockaddr *in);
|
|
|
|
}
|
|
|
|
}
|