PERFORCE change 222051 for review
Bjoern A. Zeeb
bz at FreeBSD.org
Fri Feb 15 11:36:19 UTC 2013
http://p4web.freebsd.org/@@222051?ac=10
Change 222051 by bz at bz_zenith on 2013/02/15 11:35:17
Add a -g option to prevent the locally administred bit from
being set or in case of -s to manually set an address, change
the warning.
X-Untested: yes
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/ctsrd/atsectl/atsectl.c#2 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/ctsrd/atsectl/atsectl.c#2 (text+ko) ====
@@ -74,15 +74,18 @@
static u_char block[ISF_ERASE_BLOCK];
+static int gflag;
+
/* XXX-BZ should include if_atsereg.h. */
#define ALTERA_ETHERNET_OPTION_BITS_OFF 0x00008000
#define ALTERA_ETHERNET_OPTION_BITS_LEN 0x00007fff
+
static void
usage(int rc)
{
- fprintf(stderr, "usage: atsectl [-hlu] [-s <etheraddr>]\n");
+ fprintf(stderr, "usage: atsectl [-ghlu] [-s <etheraddr>]\n");
exit(rc);
}
@@ -211,8 +214,11 @@
/* Just make sure the last half-byte is really zero. */
block[ALTERA_ETHERNET_OPTION_BITS_OFF + 9] &= ~0x0f;
- /* Set locally administred flag. */
- block[ALTERA_ETHERNET_OPTION_BITS_OFF + 4] |= 2;
+ /* Set (or clear) locally administred flag. */
+ if (gflag == 0)
+ block[ALTERA_ETHERNET_OPTION_BITS_OFF + 4] |= 2;
+ else
+ block[ALTERA_ETHERNET_OPTION_BITS_OFF + 4] &= ~2;
/* Make sure it is not a MC address by accident we start with. */
block[ALTERA_ETHERNET_OPTION_BITS_OFF + 4] &= ~1;
} else {
@@ -231,7 +237,7 @@
warnx("WARN: Selected Ethernet Address is "
"not multi-MAC compatible.\n");
}
- if ((eaddr[0] & 0x2) == 0x0) {
+ if (gflag == 0 && ((eaddr[0] & 0x2) == 0x0)) {
e++;
warnx("WARN: Locally administered bit not set.\n");
}
@@ -303,8 +309,11 @@
char ch, *s;
s = NULL;
- while ((ch = getopt(argc, argv, "hlus:")) != -1) {
+ while ((ch = getopt(argc, argv, "ghlus:")) != -1) {
switch (ch) {
+ case 'g':
+ gflag = 1;
+ break;
case 'h':
usage(0);
/* NOTREACHED */
More information about the p4-projects
mailing list