osquery-1/osquery/tables/networking/utils.h

36 lines
883 B
C
Raw Normal View History

/*
* 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
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <string>
#include <ifaddrs.h>
#include <arpa/inet.h>
namespace osquery {
namespace tables {
// Define AF_INTERFACE as the alias for interface details.
2015-05-07 04:58:23 +00:00
#ifdef __linux__
#define AF_INTERFACE AF_PACKET
2015-05-07 04:58:23 +00:00
#else
#define AF_INTERFACE AF_LINK
#endif
// Return a string representation for an IPv4/IPv6 struct.
std::string ipAsString(const struct sockaddr *in);
2015-05-10 00:32:24 +00:00
std::string ipAsString(const struct in_addr *in);
std::string macAsString(const struct ifaddrs *addr);
std::string macAsString(const char *addr);
int netmaskFromIP(const struct sockaddr *in);
}
}