AquilaOS documentation
How it works, and its code
Toggle main menu visibility
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
16
struct
netif
{
17
char
name
[8];
/* lo, eth0, eth1... (the driver's, or ethN) */
18
uint8_t
mac
[6];
19
uint16_t
mtu
;
20
int
flags
;
21
22
/* its IPv4 configuration, in the network's byte order (0 if not
23
* configured) */
24
uint32_t
ip
,
netmask
,
gateway
;
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
32
struct
{
33
uint64_t
rx_packets
,
rx_bytes
,
rx_errors
,
rx_dropped
;
34
uint64_t
tx_packets
,
tx_bytes
,
tx_errors
,
tx_dropped
;
35
}
stats
;
36
37
struct
netif
*
next
;
38
};
39
40
/* The interfaces. */
41
extern
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. */
45
int
netif_register
(
struct
netif
*
netif
);
46
struct
netif
*
netif_find
(
const
char
*
name
);
47
void
netif_input
(
struct
netif
*
netif
,
struct
netbuf
*nb);
48
void
netif_loopback
(
struct
netif
*
netif
,
struct
netbuf
*nb);
49
int
netif_output
(
struct
netif
*
netif
,
struct
netbuf
*nb);
50
51
/* Calls fn(arg) in `ns` nanoseconds, from the network's thread. */
52
struct
callout
;
53
void
net_callout_set
(
struct
callout
*c,
uint64_t
ns,
void
(*
fn
)(
void
*),
void
*
arg
);
54
55
#endif
/* ! _NET_NETIF_H */
system.h
netbuf.h
netif_register
int netif_register(struct netif *netif)
Registers a network interface.
Definition
netif.c:206
netif_find
struct netif * netif_find(const char *name)
Finds an interface by its name.
Definition
netif.c:186
netif_output
int netif_output(struct netif *netif, struct netbuf *nb)
Sends a frame through an interface's driver.
Definition
netif.c:358
net_callout_set
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
netifs
struct netif * netifs
Definition
netif.c:34
netif_loopback
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
netif_input
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
uint32_t
unsigned int uint32_t
Definition
stddef.h:22
uint8_t
unsigned char uint8_t
Definition
stddef.h:20
uint64_t
unsigned long long int uint64_t
Definition
stddef.h:23
uint16_t
unsigned short int uint16_t
Definition
stddef.h:21
callout
A function to call later, with its argument.
Definition
callout.h:13
callout::arg
void * arg
Definition
callout.h:16
callout::fn
void(*) fn(void *arg)
Definition
callout.h:15
netbuf
A packet (net/netbuf.c).
Definition
netbuf.h:16
netif::[struct].stats::tx_bytes
uint64_t tx_bytes
netif::[struct].stats::rx_bytes
uint64_t rx_bytes
netif::[struct].stats::rx_errors
uint64_t rx_errors
netif::[struct].stats::rx_dropped
uint64_t rx_dropped
netif::[struct].stats::tx_errors
uint64_t tx_errors
netif::[struct].stats::tx_dropped
uint64_t tx_dropped
netif::[struct].stats::rx_packets
uint64_t rx_packets
netif::[struct].stats::tx_packets
uint64_t tx_packets
netif
A network interface (net/netif.c): a device that sends and receives Ethernet frames,...
Definition
netif.h:16
netif::flags
int flags
Definition
netif.h:20
netif::ip
uint32_t ip
Definition
netif.h:24
netif::netmask
uint32_t netmask
Definition
netif.h:24
netif::transmit
int(*) transmit(struct netif *netif, struct netbuf *nb)
Definition
netif.h:28
netif::name
char name[8]
Definition
netif.h:17
netif::stats
struct netif::@020302303320120142126121344055047003105154122231 stats
netif::priv
void * priv
Definition
netif.h:30
netif::gateway
uint32_t gateway
Definition
netif.h:24
netif::mac
uint8_t mac[6]
Definition
netif.h:18
netif::mtu
uint16_t mtu
Definition
netif.h:19
netif::next
struct netif * next
Definition
netif.h:37
kernel
include
net
netif.h
Generated by
1.18.0