#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
+#include <os.h>
+
struct sandbox_eth_raw_if_nameindex *sandbox_eth_raw_if_nameindex(void)
{
return (struct sandbox_eth_raw_if_nameindex *)if_nameindex();
/* Prepare device struct */
priv->local_bind_sd = -1;
- priv->device = malloc(sizeof(struct sockaddr_ll));
+ priv->device = os_malloc(sizeof(struct sockaddr_ll));
if (priv->device == NULL)
return -ENOMEM;
device = priv->device;
/* Prepare device struct */
priv->local_bind_sd = -1;
priv->local_bind_udp_port = 0;
- priv->device = malloc(sizeof(struct sockaddr_in));
+ priv->device = os_malloc(sizeof(struct sockaddr_in));
if (priv->device == NULL)
return -ENOMEM;
device = priv->device;
void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv)
{
- free(priv->device);
+ os_free(priv->device);
priv->device = NULL;
close(priv->sd);
priv->sd = -1;
while (node) {
next = node->next;
- free(node);
+ os_free(node);
node = next;
}
}
/* Create a buffer upfront, with typically sufficient size */
dirlen = strlen(dirname) + 2;
len = dirlen + 256;
- fname = malloc(len);
+ fname = os_malloc(len);
if (!fname) {
ret = -ENOMEM;
goto done;
ret = errno;
break;
}
- next = malloc(sizeof(*node) + strlen(entry->d_name) + 1);
+ next = os_malloc(sizeof(*node) + strlen(entry->d_name) + 1);
if (!next) {
os_dirent_free(head);
ret = -ENOMEM;
if (dirlen + strlen(entry->d_name) > len) {
len = dirlen + strlen(entry->d_name);
old_fname = fname;
- fname = realloc(fname, len);
+ fname = os_realloc(fname, len);
if (!fname) {
- free(old_fname);
- free(next);
+ os_free(old_fname);
+ os_free(next);
os_dirent_free(head);
ret = -ENOMEM;
goto done;
done:
closedir(dir);
- free(fname);
+ os_free(fname);
return ret;
}
for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++)
;
- argv = malloc((argc + count + 1) * sizeof(char *));
+ argv = os_malloc((argc + count + 1) * sizeof(char *));
if (!argv) {
printf("Out of memory for %d argv\n", count);
return -ENOMEM;
os_exit(2);
err = execv(fname, argv);
- free(argv);
+ os_free(argv);
if (err)
return err;