summaryrefslogtreecommitdiff
path: root/usr/src/lib/libsocket
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libsocket')
-rw-r--r--usr/src/lib/libsocket/common/mapfile-vers6
-rw-r--r--usr/src/lib/libsocket/inet/ether_addr.c53
2 files changed, 41 insertions, 18 deletions
diff --git a/usr/src/lib/libsocket/common/mapfile-vers b/usr/src/lib/libsocket/common/mapfile-vers
index 2f7777f395..471774b462 100644
--- a/usr/src/lib/libsocket/common/mapfile-vers
+++ b/usr/src/lib/libsocket/common/mapfile-vers
@@ -39,6 +39,12 @@
$mapfile_version 2
+SYMBOL_VERSION ILLUMOS_0.2 { # reentrant ethers(3SOCKET)
+ global:
+ ether_aton_r;
+ ether_ntoa_r;
+} ILLUMOS_0.1;
+
SYMBOL_VERSION ILLUMOS_0.1 { # Illumos additions
global:
accept4;
diff --git a/usr/src/lib/libsocket/inet/ether_addr.c b/usr/src/lib/libsocket/inet/ether_addr.c
index 37105bb302..523e7b472d 100644
--- a/usr/src/lib/libsocket/inet/ether_addr.c
+++ b/usr/src/lib/libsocket/inet/ether_addr.c
@@ -22,6 +22,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -37,8 +38,6 @@
* contributors.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* All routines necessary to deal the "ethers" database. The sources
* contain mappings between 48 bit ethernet addresses and corresponding
@@ -258,38 +257,42 @@ ea_buf(void)
}
/*
- * Converts a 48 bit ethernet number to its string representation.
+ * Converts a 48 bit ethernet number to its string representation using a user
+ * defined buffer.
+ */
+char *
+ether_ntoa_r(const struct ether_addr *e, char *buf)
+{
+ (void) sprintf(buf, "%x:%x:%x:%x:%x:%x",
+ e->ether_addr_octet[0], e->ether_addr_octet[1],
+ e->ether_addr_octet[2], e->ether_addr_octet[3],
+ e->ether_addr_octet[4], e->ether_addr_octet[5]);
+ return (buf);
+}
+
+/*
+ * Converts a 48 bit ethernet number to its string representation using a
+ * per-thread buffer.
*/
char *
ether_ntoa(const struct ether_addr *e)
{
eabuf_t *eabuf;
- char *s;
if ((eabuf = ea_buf()) == NULL)
return (NULL);
- s = eabuf->ea_string;
- (void) sprintf(s, "%x:%x:%x:%x:%x:%x",
- e->ether_addr_octet[0], e->ether_addr_octet[1],
- e->ether_addr_octet[2], e->ether_addr_octet[3],
- e->ether_addr_octet[4], e->ether_addr_octet[5]);
- return (s);
+ return (ether_ntoa_r(e, eabuf->ea_string));
}
/*
- * Converts an ethernet address representation back into its 48 bits.
+ * Converts an ethernet address representation back into its 48 bits using a
+ * user defined buffer.
*/
struct ether_addr *
-ether_aton(const char *s)
+ether_aton_r(const char *s, struct ether_addr *e)
{
- eabuf_t *eabuf;
- struct ether_addr *e;
int i;
uint_t t[6];
-
- if ((eabuf = ea_buf()) == NULL)
- return (NULL);
- e = &eabuf->ea_addr;
i = sscanf(s, " %x:%x:%x:%x:%x:%x",
&t[0], &t[1], &t[2], &t[3], &t[4], &t[5]);
if (i != 6)
@@ -298,3 +301,17 @@ ether_aton(const char *s)
e->ether_addr_octet[i] = (uchar_t)t[i];
return (e);
}
+
+/*
+ * Converts an ethernet address representation back into its 48 bits using a
+ * per-thread buffer.
+ */
+struct ether_addr *
+ether_aton(const char *s)
+{
+ eabuf_t *eabuf;
+
+ if ((eabuf = ea_buf()) == NULL)
+ return (NULL);
+ return (ether_aton_r(s, &eabuf->ea_addr));
+}