summaryrefslogtreecommitdiffstats
path: root/isys/iface.h
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2008-08-25 10:19:19 -1000
committerDavid Cantrell <dcantrell@redhat.com>2008-08-25 10:19:19 -1000
commit57e7079052bec83c6aa0bb327b220d1de908d118 (patch)
tree4a4e0a548e489543cdb6152768e8800d43668ddf /isys/iface.h
parent2be503dd8da94df9979528594bc2a91db5e0cc96 (diff)
downloadanaconda-57e7079052bec83c6aa0bb327b220d1de908d118.tar.gz
anaconda-57e7079052bec83c6aa0bb327b220d1de908d118.tar.xz
anaconda-57e7079052bec83c6aa0bb327b220d1de908d118.zip
Use NetworkManager instead of libdhcp. (#458183)
Finally, no more libdhcp. This is the first set of changes to take anaconda over to the wonderful world of NetworkManager. We are no longer linking with libdhcp to do interface configuration. NM is started early in the installation and opens the door to things like WPA installation support and things like that.
Diffstat (limited to 'isys/iface.h')
-rw-r--r--isys/iface.h154
1 files changed, 149 insertions, 5 deletions
diff --git a/isys/iface.h b/isys/iface.h
index 4b0e50f2d..03cffee4e 100644
--- a/isys/iface.h
+++ b/isys/iface.h
@@ -1,7 +1,7 @@
/*
- * iface.h
+ * iface.h - Network interface configuration API
*
- * Copyright (C) 2006, 2007, 2008 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,11 +19,155 @@
* Author(s): David Cantrell <dcantrell@redhat.com>
*/
+#ifndef ISYSIFACE_H
+#define ISYSIFACE_H
+
+#include <resolv.h>
+#include <net/if.h>
#include <netlink/cache.h>
#include <netlink/socket.h>
+/* Enumerated types used in iface.c as well as loader's network code */
+enum { IPUNUSED, IPV4, IPV6 };
+
+enum { IPV4_UNUSED_METHOD, IPV4_DHCP_METHOD, IPV4_MANUAL_METHOD };
+enum { IPV6_UNUSED_METHOD, IPV6_AUTO_METHOD, IPV6_DHCP_METHOD,
+ IPV6_MANUAL_METHOD };
+
+#define IPV4_FIRST_METHOD IPV4_DHCP_METHOD
+#define IPV4_LAST_METHOD IPV4_MANUAL_METHOD
+
+#define IPV6_FIRST_METHOD IPV6_AUTO_METHOD
+#define IPV6_LAST_METHOD IPV6_MANUAL_METHOD
+
+/* Flags for the iface_t */
+#define IFACE_FLAGS_NO_WRITE_RESOLV_CONF (((uint64_t) 1) << 0)
+/* FIXME: do we need these? */
+#define IFACE_FLAGS_IS_PRESET (((uint64_t) 1) << 1)
+#define IFACE_FLAGS_IS_DYNAMIC (((uint64_t) 1) << 2)
+
+#define IFACE_NO_WRITE_RESOLV_CONF(a) ((a) & IFACE_FLAGS_NO_WRITE_RESOLV_CONF)
+#define IFACE_IS_PRESET(a) ((a) & IFACE_FLAGS_IS_PRESET)
+#define IFACE_IS_DYNAMIC(a) ((a) & IFACE_FLAGS_IS_DYNAMIC)
+
+/* Macros for starting NetworkManager */
+#define NETWORKMANAGER "/usr/sbin/NetworkManager"
+#define OUTPUT_TERMINAL "/dev/tty5"
+
+/* Per-interface configuration information */
+typedef struct _iface_t {
+ /* device name (e.g., eth0) */
+ char device[IF_NAMESIZE];
+
+ /* MAC address as xx:xx:xx:xx:xx:xx */
+ char *macaddr;
+
+ /* IPv4 (store addresses in in_addr format, use inet_pton() to display) */
+ struct in_addr ipaddr;
+ struct in_addr netmask;
+ struct in_addr broadcast;
+
+ /* IPv6 (store addresses in in6_addr format, prefix is just an int) */
+ struct in6_addr ip6addr;
+ int ip6prefix;
+
+ /* Gateway settings */
+ struct in_addr gateway;
+ struct in6_addr gateway6;
+
+ /* BOOTP (these can be IPv4 or IPv6, store human-readable version as str) */
+ char *nextserver;
+ char *bootfile;
+
+ /* DNS (these can be IPv4 or IPv6, store human-readable version as str) */
+ char *dns[MAXNS];
+ int numdns;
+ char *hostname;
+ char *domain;
+ char *search;
+
+ /* Misc DHCP settings */
+ int dhcptimeout;
+ char *vendorclass;
+
+ /* Wireless settings */
+ char *ssid;
+ char *wepkey;
+
+ /* s390 specifics */
+ int mtu;
+ char *subchannels;
+ char *portname;
+ char *peerid;
+ char *nettype;
+ char *ctcprot;
+
+ /* flags */
+ uint64_t flags;
+ int ipv4method;
+ int ipv6method;
+} iface_t;
+
/* Function prototypes */
-struct nl_cache *iface_get_link_cache(struct nl_handle **handle);
-char *iface_mac2str(char *ifname);
-char *iface_ip2str(char *ifname);
+
+/*
+ * Given an interface name (e.g., eth0), return the IP address in human
+ * readable format (i.e., the output from inet_ntop()). Return NULL for
+ * no match. NOTE: This function will check for IPv6 and IPv4
+ * addresses. In the case where the interface has both, the IPv4 address
+ * is returned. The only way you will get an IPv6 address from this function
+ * is if that's the only address configured for the interface.
+ */
+char *iface_ip2str(char *);
+
+/*
+ * Given an interface name (e.g., eth0), return the MAC address in human
+ * readable format (e.g., 00:11:52:12:D9:A0). Return NULL for no match.
+ */
+char *iface_mac2str(char *);
+
+/*
+ * Convert an IPv4 CIDR prefix to a dotted-quad netmask. Return NULL on
+ * failure.
+ */
+struct in_addr *iface_prefix2netmask(int);
+
+/*
+ * Convert an IPv4 netmask to an IPv4 CIDR prefix. Return -1 on failure.
+ */
+int iface_netmask2prefix(struct in_addr *);
+
+/*
+ * Look up the hostname and domain for our assigned IP address. Tries IPv4
+ * first, then IPv6. Returns 0 on success, non-negative on failure.
+ */
+int iface_dns_lookup(iface_t *);
+
+/*
+ * Initialize a new iface_t structure to default values.
+ */
+void iface_init_iface_t(iface_t *);
+
+/*
+ * Given a pointer to a struct in_addr, return 1 if it contains a valid
+ * address, 0 otherwise.
+ */
+int iface_have_in_addr(struct in_addr *addr);
+
+/*
+ * Given a pointer to a struct in6_addr, return 1 if it contains a valid
+ * address, 0 otherwise.
+ */
+int iface_have_in6_addr(struct in6_addr *addr6);
+
+/*
+ * Start NetworkManager
+ */
+int iface_start_NetworkManager(iface_t *iface);
+
+/*
+ * Set Maximum Transfer Unit (MTU) on specified interface
+ */
int iface_set_interface_mtu(char *ifname, int mtu);
+
+#endif /* ISYSIFACE_H */