My Kernel v0.1.0
interface.h
Go to the documentation of this file.
1
30#ifndef KERNEL_NET_INTERFACE_H
31#define KERNEL_NET_INTERFACE_H
32
34#include <kernel/types.h>
35
36#include <libalgo/linked_list.h>
37
40 const char *name;
44};
45
47struct subnet {
48 LLIST_NODE(this);
49 struct net_interface *interface;
50 __be ipv4_t ip;
51 uint8_t cidr;
52};
53
55struct net_interface *net_interface_new(struct ethernet_device *, const char *);
56
58error_t
59net_interface_add_subnet(struct net_interface *, __be ipv4_t, uint8_t cidr);
60
64const struct subnet *net_interface_find_subnet(__be ipv4_t);
65
67struct net_interface *net_interface_find(__be ipv4_t);
68
69#endif /* KERNEL_NET_INTERFACE_H */
70
Network device.
#define LLIST_NODE(_name)
Declare an intrusive list node.
Definition: linked_list.h:64
const struct subnet * net_interface_find_subnet(__be ipv4_t)
Find the first subnet that contains the specified address.
Definition: interface.c:79
struct net_interface * net_interface_find(__be ipv4_t)
Find the interface by source IP address.
Definition: interface.c:98
struct net_interface * net_interface_new(struct ethernet_device *, const char *)
Create a new network interface.
Definition: interface.c:15
error_t net_interface_add_subnet(struct net_interface *, __be ipv4_t, uint8_t cidr)
Add a new subnet to a network interface.
Definition: interface.c:33
An ethernet device.
Definition: ethernet.h:50
The head of a doubly linked list.
Definition: linked_list.h:43
A network interface.
Definition: interface.h:39
struct ethernet_device * netdev
The name of this interface.
Definition: interface.h:41
llist_t subnets
The interface's network device.
Definition: interface.h:42
LLIST_NODE(this)
The subnets registered under this interface.
An interface subnet.
Definition: interface.h:47
uint8_t cidr
source ip used when interacting with this subnet
Definition: interface.h:51
__be ipv4_t ip
The subnet's containing interface.
Definition: interface.h:50