net: Implement net_available

This commit is contained in:
Xavier Del Campo Romero 2022-09-23 04:27:58 +02:00
parent b108afb6e7
commit 8435b3f5fd
3 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#ifndef NET_H
#define NET_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
@ -71,7 +72,7 @@ struct net_socket;
int net_init(void);
void net_deinit(void);
int net_update(struct net_socket *s);
bool net_available(enum net_domain d);
struct net_socket *net_server(const union net_server *srv);
struct net_socket *net_connect(const union net_connect *c);
int net_read(struct net_socket *s, void *buf, size_t n);

View File

@ -109,3 +109,8 @@ void net_deinit(void)
net_deinit_ipv4();
net_deinit_serial();
}
bool net_available(const enum net_domain d)
{
return true;
}

View File

@ -1,6 +1,7 @@
#include <net.h>
#include <net/serial.h>
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
int net_read(struct net_socket *const h, void *const buf, const size_t n)
@ -42,6 +43,11 @@ void net_deinit(void)
{
}
bool net_available(const enum net_domain d)
{
return d == NET_DOMAIN_SERIAL;
}
const char *const *net_serial_devices(size_t *const n)
{
static const char *const dev[] =