Skip to content

Commit

Permalink
merge from dev, version bump to 1.0.3
Browse files Browse the repository at this point in the history
Change-Id: Ie18ea1247b5b870482b483dda1cf7db8121d5a4d
  • Loading branch information
vinaykul committed Jul 8, 2016
2 parents 4ae0011 + a714aca commit 03c4d43
Show file tree
Hide file tree
Showing 8 changed files with 894 additions and 75 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AC_PREREQ(2.59)

AC_INIT([netmgmt], [1.0.2], [support@vmware.com])
AC_INIT([netmgmt], [1.0.3], [support@vmware.com])
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_HEADERS([include/config.h])
Expand Down
240 changes: 230 additions & 10 deletions include/public/netmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,260 @@ ifdown(
const char * pszInterfaceName
);


/*
* Interface configuration APIs
*/

typedef enum _NET_LINK_MODE
{
LINK_AUTO = 0,
LINK_MANUAL,
} NET_LINK_MODE;

typedef enum _NET_LINK_STATE
{
LINK_DOWN = 0,
LINK_UP,
LINK_UNKNOWN,
} NET_LINK_STATE;

typedef struct _NET_LINK_INFO
{
char *pszInterfaceName;
char *pszMacAddress;
uint32_t mtu;
NET_LINK_MODE mode;
NET_LINK_STATE state;
} NET_LINK_INFO;

// Override the 'factory/nvram' mac address. mtu=0 -> use default 1500
int
set_iaid(
set_link_info(
const char *pszInterfaceName,
const uint32_t iaid
const char *pszMacAddress,
uint32_t mtu
);

int
get_iaid(
set_link_mode(
const char *pszInterfaceName,
uint32_t *iaid
NET_LINK_MODE mode
);

int
set_duid(
set_link_state(
const char *pszInterfaceName,
const char *pszDuid
NET_LINK_STATE state
);

int
get_duid(
get_link_info(
const char *pszInterfaceName,
size_t *pCount,
NET_LINK_INFO **ppLinkInfo
);


/*
* IP Address configuration APIs
*/

//TODO: Support address for virtual interface e.g. "eth1:0"
int
set_static_ipv4_addr(
const char *pszInterfaceName,
const char *pszIPv4Addr,
uint8_t prefix,
uint32_t flags
);

int
delete_static_ipv4_addr(
const char *pszInterfaceName
);

#define fCLEAR_IPV6_ADDR_LIST 0x00000001
int
add_static_ipv6_addr(
const char *pszInterfaceName,
const char *pszIPv6Addr,
uint8_t prefix,
uint32_t flags
);

int
delete_static_ipv6_addr(
const char *pszInterfaceName,
const char *pszIPv6Addr,
uint8_t prefix,
uint32_t flags
);

#define fDHCP_IPV4 0x00000001
#define fDHCP_IPV6 0x00000010
#define fAUTO_IPV6 0x00000020
//[3 - dhcp=yes], [4 - dhcp=no, autoconf=1], [1 - dhcp=ipv4, autoconf=0], [2 - dhcp=ipv6, autoconf=0]
int
set_ip_dhcp_mode(
const char *pszInterfaceName,
uint32_t dhcpModeFlags
);

typedef enum _NET_ADDR_TYPE
{
STATIC_IPV4 = 0x00000001,
STATIC_IPV6 = 0x00000002,
DHCP_IPV4 = 0x00000010,
DHCP_IPV6 = 0x00000020,
AUTO_IPV6 = 0x00000040,
} NET_ADDR_TYPE;

//#define ALL_IP_ADDR = or of all the above enum values
typedef struct _NET_IP_ADDR
{
NET_ADDR_TYPE type;
char *pszIPAddr;
uint8_t prefix;
} NET_IP_ADDR;

int
get_ip_addr_info(
const char *pszInterfaceName,
char *pszDuid
uint32_t flags,
size_t *pCount,
NET_IP_ADDR **ppAddrList
);


/*
* Route configuration APIs
*/

typedef enum _NET_ROUTE_TYPE
{
GLOBAL_ROUTE,
LINK_ROUTE,
HOST_ROUTE,
} NET_ROUTE_TYPE;

typedef struct _NET_IP_ROUTE
{
char *pszInterfaceName;
char *pszDestAddr;
uint8_t prefix;
char *pszGateway;
NET_ROUTE_TYPE type;
} NET_IP_ROUTE;

#define fCLEAR_ROUTES_LIST 0x00000001
#define fSCOPE_HOST 0x00000010
int
set_ip_route(
const char *pszInterfaceName,
const char *pszDestAddr,
uint8_t prefix,
const char *pszGateway,
uint32_t metric,
uint32_t flags
);

int
delete_ip_route(
const char *pszInterfaceName,
const char *pszDestAddr,
uint8_t prefix,
uint32_t flags
);

int
get_ip_route_info(
size_t *pCount,
NET_IP_ROUTE **ppRouteList
);


/*
* DNS configuration APIs
*/

typedef enum _NET_DNS_MODE
{
STATIC_DNS = 0,
DHCP_DNS,
} NET_DNS_MODE;

#define fAPPEND_DNS_SERVERS_LIST 0x00000001
int
set_dns_servers(
const char *pszInterfaceName,
const char *pszDnsServers
NET_DNS_MODE mode,
size_t count,
const char **ppDnsServers,
uint32_t flags
);

#define fRESOLVED_CONF_DNS_SERVERS
int
get_dns_servers(
const char *pszInterfaceName,
char *pszDnsServers
uint32_t flags,
NET_DNS_MODE *pMode,
size_t *pCount,
char ***ppDnsServers
);

#define fAPPEND_DNS_DOMAINS_LIST 0x00000001
int
set_dns_domains(
const char *pszInterfaceName,
size_t count,
const char **ppDnsDomains,
uint32_t flags
);

#define fRESOLVED_CONF_DNS_DOMAINS 0x00000001
int
get_dns_domains(
const char *pszInterfaceName,
uint32_t flags,
size_t *pCount,
char **ppDnsDomains
);


/*
* DHCP options, DUID, IAID configuration APIs
*/

int
set_iaid(
const char *pszInterfaceName,
uint32_t iaid
);

int
get_iaid(
const char *pszInterfaceName,
uint32_t *pIaid
);

int
set_duid(
const char *pszInterfaceName,
const char *pszDuid
);

int
get_duid(
const char *pszInterfaceName,
char **ppszDuid
);

int
set_dns_servers_v0(
const char *pszInterfaceName,
const char *pszDnsServers
);

#endif /* __NETMGR_H__ */
Expand Down
10 changes: 9 additions & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@
#define __DEFINES_H__


#define MAX_LINE 128
#define MAX_LINE 512

#define SYSTEMD_PATH "/etc/systemd/"
#define SYSTEMD_NET_PATH "/etc/systemd/network/"

#define SECTION_RESOLVE "Resolve"
#define SECTION_NETWORK "Network"
#define SECTION_DHCP "DHCP"

#define KEY_IAID "IAID"
#define KEY_DUID_TYPE "DUIDType"
#define KEY_DUID_RAWDATA "DUIDRawData"
#define KEY_DNS "DNS"
#define KEY_USE_DNS "UseDNS"


#define bail_on_error(errcode) \
Expand All @@ -36,4 +41,7 @@
} \
} while(0)

#define SET_FLAG(v,f) ((v) | (f))
#define TEST_FLAG(v,f) (((v) & (f)) != 0)

#endif /* __DEFINES_H__ */
Loading

0 comments on commit 03c4d43

Please sign in to comment.