Merge tag 'fsl-qoriq-for-v2019.01-rc2' of git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / arch / sandbox / cpu / eth-raw-os.c
index df7acaa0bc8480ec01cad2a0b1d3543bbf3841f9..8d05bc2eda039a21598950075bc9bb0ae74bffe1 100644 (file)
@@ -11,6 +11,7 @@
 #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();
+}
+
+void sandbox_eth_raw_if_freenameindex(struct sandbox_eth_raw_if_nameindex *ptr)
+{
+       if_freenameindex((struct if_nameindex *)ptr);
+}
+
 int sandbox_eth_raw_os_is_local(const char *ifname)
 {
        int fd = socket(AF_INET, SOCK_DGRAM, 0);
@@ -61,7 +74,7 @@ static int _raw_packet_start(struct eth_sandbox_raw_priv *priv,
 
        /* 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;
@@ -134,7 +147,7 @@ static int _local_inet_start(struct eth_sandbox_raw_priv *priv)
        /* 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;
@@ -269,7 +282,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length,
 
 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;