return 0;
}
+#ifndef xmalloc
void *
xmalloc(size_t s)
{
exit (EXIT_FAILURE);
/* NOTREACHED */
}
+#endif
-void *
-xzalloc(size_t s)
-{
- void *value = xmalloc(s);
-
- memset(value, 0, s);
- return value;
-}
-
+#ifndef xrealloc
void *
xrealloc(void *ptr, size_t s)
{
exit(EXIT_FAILURE);
/* NOTREACHED */
}
+#endif
+#ifndef xstrdup
char *
xstrdup(const char *str)
{
exit(EXIT_FAILURE);
/* NOTREACHED */
}
+#endif
+
+void *
+xzalloc(size_t s)
+{
+ void *value = xmalloc(s);
+
+ memset(value, 0, s);
+ return value;
+}
static char *cffile;
static char *pidfile;
static int linkfd = -1, ipv6rsfd = -1, ipv6nsfd = -1;
+static uint8_t *packet;
struct dhcp_op {
uint8_t value;
for (i = 0; i < ifdc; i++)
free(ifdv[i]);
free(ifdv);
+ free(packet);
#endif
if (linkfd != -1)
handle_dhcp_packet(void *arg)
{
struct interface *iface = arg;
- uint8_t *packet;
struct dhcp_message *dhcp = NULL;
const uint8_t *pp;
ssize_t bytes;
/* We loop through until our buffer is empty.
* The benefit is that if we get >1 DHCP packet in our buffer and
* the first one fails for any reason, we can use the next. */
- packet = xmalloc(udp_dhcp_len);
+ if (packet == NULL)
+ packet = xmalloc(udp_dhcp_len);
for(;;) {
bytes = get_raw_packet(iface, ETHERTYPE_IP,
packet, udp_dhcp_len, &partialcsum);
break;
}
free(packet);
+ packet = NULL;
free(dhcp);
}