AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
netif.h
Go to the documentation of this file.
1#ifndef _NET_NETIF_H
2#define _NET_NETIF_H
3
4#include <core/system.h>
5#include <net/netbuf.h>
6
7/* A network interface's flags. */
8#define NETIF_UP 0x0001 /* it's configured, and takes packets */
9#define NETIF_RUNNING 0x0002 /* its link is up */
10#define NETIF_LOOPBACK 0x0004 /* it's lo, 127/8: what it sends comes back */
11
16struct netif {
17 char name[8]; /* lo, eth0, eth1... (the driver's, or ethN) */
20 int flags;
21
22 /* its IPv4 configuration, in the network's byte order (0 if not
23 * configured) */
25
26 /* sends a frame (its Ethernet header included); the netbuf stays the
27 * caller's */
28 int (*transmit)(struct netif *netif, struct netbuf *nb);
29
30 void *priv; /* the driver's own data */
31
36
37 struct netif *next;
38};
39
40/* The interfaces. */
41extern struct netif *netifs;
42
43/* Registers an interface; finds one; a frame that came in on one; sends a
44 * frame, or loops it back. */
45int netif_register(struct netif *netif);
46struct netif *netif_find(const char *name);
47void netif_input(struct netif *netif, struct netbuf *nb);
48void netif_loopback(struct netif *netif, struct netbuf *nb);
49int netif_output(struct netif *netif, struct netbuf *nb);
50
51/* Calls fn(arg) in `ns` nanoseconds, from the network's thread. */
52struct callout;
53void net_callout_set(struct callout *c, uint64_t ns, void (*fn)(void *), void *arg);
54
55#endif /* ! _NET_NETIF_H */
int netif_register(struct netif *netif)
Registers a network interface.
Definition netif.c:206
struct netif * netif_find(const char *name)
Finds an interface by its name.
Definition netif.c:186
int netif_output(struct netif *netif, struct netbuf *nb)
Sends a frame through an interface's driver.
Definition netif.c:358
void net_callout_set(struct callout *c, uint64_t ns, void(*fn)(void *), void *arg)
Sets a callout that the network's thread runs: fn(arg) is called once ns ns have passed.
Definition netif.c:137
struct netif * netifs
Definition netif.c:34
void netif_loopback(struct netif *netif, struct netbuf *nb)
Hands the stack an IPv4 packet sent to one of our own addresses, as if it had come in through an inte...
Definition netif.c:340
void netif_input(struct netif *netif, struct netbuf *nb)
Hands the stack a frame that a driver received, possibly from an interrupt.
Definition netif.c:323
unsigned int uint32_t
Definition stddef.h:22
unsigned char uint8_t
Definition stddef.h:20
unsigned long long int uint64_t
Definition stddef.h:23
unsigned short int uint16_t
Definition stddef.h:21
A function to call later, with its argument.
Definition callout.h:13
void * arg
Definition callout.h:16
void(*) fn(void *arg)
Definition callout.h:15
A packet (net/netbuf.c).
Definition netbuf.h:16
A network interface (net/netif.c): a device that sends and receives Ethernet frames,...
Definition netif.h:16
int flags
Definition netif.h:20
uint32_t ip
Definition netif.h:24
uint32_t netmask
Definition netif.h:24
int(*) transmit(struct netif *netif, struct netbuf *nb)
Definition netif.h:28
char name[8]
Definition netif.h:17
struct netif::@020302303320120142126121344055047003105154122231 stats
void * priv
Definition netif.h:30
uint32_t gateway
Definition netif.h:24
uint8_t mac[6]
Definition netif.h:18
uint16_t mtu
Definition netif.h:19
struct netif * next
Definition netif.h:37