summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdhcpagent/common/dhcpagent_ipc.c
diff options
context:
space:
mode:
authorcarlsonj <none@none>2007-04-25 11:54:45 -0700
committercarlsonj <none@none>2007-04-25 11:54:45 -0700
commitcfb9c9abdc2696bc174bb10a3a28552dc917b98f (patch)
tree66f98c1f0a916d6eacc66a9141e1153208695386 /usr/src/lib/libdhcpagent/common/dhcpagent_ipc.c
parent8cb045d062db356cee4eaacd954f772ab314f6f3 (diff)
downloadillumos-gate-cfb9c9abdc2696bc174bb10a3a28552dc917b98f.tar.gz
6396937 dhcpagent: cannot write /etc/dhcp/e1000g0.dhc
6514851 in.ndpd "giving up" message needs work 6524645 clear_lif_dhcp is too cautious 6525108 inconsistent handling of lists due to fix for CR 6209214 6528047 dhcp inform messages are sent with zero source 6541139 dhcpagent can leave timers running on drop 6541633 dhcpagent's route clean-up mechanism can misfire, removing default route
Diffstat (limited to 'usr/src/lib/libdhcpagent/common/dhcpagent_ipc.c')
-rw-r--r--usr/src/lib/libdhcpagent/common/dhcpagent_ipc.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/usr/src/lib/libdhcpagent/common/dhcpagent_ipc.c b/usr/src/lib/libdhcpagent/common/dhcpagent_ipc.c
index 8a3ec18060..0d5cc7f8ff 100644
--- a/usr/src/lib/libdhcpagent/common/dhcpagent_ipc.c
+++ b/usr/src/lib/libdhcpagent/common/dhcpagent_ipc.c
@@ -76,6 +76,12 @@ static int dhcp_ipc_timed_read(int, void *, unsigned int, int *);
static int getinfo_ifnames(const char *, dhcp_optnum_t *, DHCP_OPT **);
static char *get_ifnames(int, int);
+/* must be kept in sync with enum in dhcpagent_ipc.h */
+static const char *ipc_typestr[] = {
+ "drop", "extend", "ping", "release", "start", "status",
+ "inform", "get_tag"
+};
+
/*
* dhcp_ipc_alloc_request(): allocates a dhcp_ipc_request_t of the given type
* and interface, with a timeout of 0.
@@ -636,6 +642,25 @@ dhcp_ipc_strerror(int error)
}
/*
+ * dhcp_string_to_request(): maps a string into a request code
+ *
+ * input: const char *: the string to map
+ * output: dhcp_ipc_type_t: the request code, or -1 if unknown
+ */
+
+dhcp_ipc_type_t
+dhcp_string_to_request(const char *request)
+{
+ unsigned int i;
+
+ for (i = 0; i < DHCP_NIPC; i++)
+ if (strcmp(ipc_typestr[i], request) == 0)
+ return ((dhcp_ipc_type_t)i);
+
+ return ((dhcp_ipc_type_t)-1);
+}
+
+/*
* dhcp_ipc_type_to_string(): maps an ipc command code into a human-readable
* string
*
@@ -646,15 +671,10 @@ dhcp_ipc_strerror(int error)
const char *
dhcp_ipc_type_to_string(dhcp_ipc_type_t type)
{
- static const char *typestr[] = {
- "drop", "extend", "ping", "release", "start", "status",
- "inform", "get_tag"
- };
-
if (type < 0 || type >= DHCP_NIPC)
return ("unknown");
else
- return (typestr[(int)type]);
+ return (ipc_typestr[(int)type]);
}
/*