summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c24
-rw-r--r--sbin/ipfw/ipfw2.c40
2 files changed, 48 insertions, 16 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 7da12aa..65f0eb5 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -56,8 +56,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <stddef.h>
-
#include "dhcpd.h"
#include "privsep.h"
@@ -1572,18 +1570,16 @@ make_discover(struct interface_info *ip, struct client_lease *lease)
}
/* set unique client identifier */
- struct hardware client_ident;
+ char client_ident[sizeof(ip->hw_address.haddr) + 1];
if (!options[DHO_DHCP_CLIENT_IDENTIFIER]) {
- size_t hwlen = MIN(ip->hw_address.hlen,
- sizeof(client_ident.haddr));
- client_ident.htype = ip->hw_address.htype;
- client_ident.hlen = hwlen;
- memcpy(client_ident.haddr, ip->hw_address.haddr, hwlen);
+ int hwlen = (ip->hw_address.hlen < sizeof(client_ident)-1) ?
+ ip->hw_address.hlen : sizeof(client_ident)-1;
+ client_ident[0] = ip->hw_address.htype;
+ memcpy(&client_ident[1], ip->hw_address.haddr, hwlen);
options[DHO_DHCP_CLIENT_IDENTIFIER] = &option_elements[DHO_DHCP_CLIENT_IDENTIFIER];
- options[DHO_DHCP_CLIENT_IDENTIFIER]->value = (void *)&client_ident;
- hwlen += offsetof(struct hardware, haddr);
- options[DHO_DHCP_CLIENT_IDENTIFIER]->len = hwlen;
- options[DHO_DHCP_CLIENT_IDENTIFIER]->buf_size = hwlen;
+ options[DHO_DHCP_CLIENT_IDENTIFIER]->value = client_ident;
+ options[DHO_DHCP_CLIENT_IDENTIFIER]->len = hwlen+1;
+ options[DHO_DHCP_CLIENT_IDENTIFIER]->buf_size = hwlen+1;
options[DHO_DHCP_CLIENT_IDENTIFIER]->timeout = 0xFFFFFFFF;
}
@@ -1609,8 +1605,8 @@ make_discover(struct interface_info *ip, struct client_lease *lease)
0, sizeof(ip->client->packet.siaddr));
memset(&(ip->client->packet.giaddr),
0, sizeof(ip->client->packet.giaddr));
- memcpy(ip->client->packet.chaddr, ip->hw_address.haddr,
- MIN(ip->hw_address.hlen, sizeof(ip->client->packet.chaddr)));
+ memcpy(ip->client->packet.chaddr,
+ ip->hw_address.haddr, ip->hw_address.hlen);
}
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 5389268..b2fbf35 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -2280,6 +2280,9 @@ ipfw_sets_handler(char *av[])
if (!isdigit(*(av[2])) || rt.new_set > RESVD_SET)
errx(EX_DATAERR, "invalid dest. set %s\n", av[1]);
i = do_range_cmd(cmd, &rt);
+ if (i < 0)
+ err(EX_OSERR, "failed to move %s",
+ cmd == IP_FW_SET_MOVE ? "set": "rule");
} else if (_substrcmp(*av, "disable") == 0 ||
_substrcmp(*av, "enable") == 0 ) {
int which = _substrcmp(*av, "enable") == 0 ? 1 : 0;
@@ -5128,11 +5131,35 @@ static struct _s_x intcmds[] = {
{ NULL, 0 }
};
+static struct _s_x otypes[] = {
+ { "EACTION", IPFW_TLV_EACTION },
+ { NULL, 0 }
+};
+
+static const char*
+lookup_eaction_name(ipfw_obj_ntlv *ntlv, int cnt, uint16_t type)
+{
+ const char *name;
+ int i;
+
+ name = NULL;
+ for (i = 0; i < cnt; i++) {
+ if (ntlv[i].head.type != IPFW_TLV_EACTION)
+ continue;
+ if (IPFW_TLV_EACTION_NAME(ntlv[i].idx) != type)
+ continue;
+ name = ntlv[i].name;
+ break;
+ }
+ return (name);
+}
+
static void
ipfw_list_objects(int ac, char *av[])
{
ipfw_obj_lheader req, *olh;
ipfw_obj_ntlv *ntlv;
+ const char *name;
size_t sz;
int i;
@@ -5158,8 +5185,17 @@ ipfw_list_objects(int ac, char *av[])
printf("There are no objects\n");
ntlv = (ipfw_obj_ntlv *)(olh + 1);
for (i = 0; i < olh->count; i++) {
- printf(" kidx: %4d\ttype: %6d\tname: %s\n", ntlv->idx,
- ntlv->head.type, ntlv->name);
+ name = match_value(otypes, ntlv->head.type);
+ if (name == NULL)
+ name = lookup_eaction_name(
+ (ipfw_obj_ntlv *)(olh + 1), olh->count,
+ ntlv->head.type);
+ if (name == NULL)
+ printf(" kidx: %4d\ttype: %10d\tname: %s\n",
+ ntlv->idx, ntlv->head.type, ntlv->name);
+ else
+ printf(" kidx: %4d\ttype: %10s\tname: %s\n",
+ ntlv->idx, name, ntlv->name);
ntlv++;
}
free(olh);
OpenPOWER on IntegriCloud