AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
netif.h File Reference
#include <core/system.h>
#include <net/netbuf.h>

Go to the source code of this file.

Data Structures

struct  netif
 A network interface (net/netif.c): a device that sends and receives Ethernet frames, and its IPv4 configuration. More...

Macros

#define NETIF_UP   0x0001
#define NETIF_RUNNING   0x0002
#define NETIF_LOOPBACK   0x0004

Functions

int netif_register (struct netif *netif)
 Registers a network interface.
struct netif * netif_find (const char *name)
 Finds an interface by its name.
void netif_input (struct netif *netif, struct netbuf *nb)
 Hands the stack a frame that a driver received, possibly from an interrupt.
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 interface.
int netif_output (struct netif *netif, struct netbuf *nb)
 Sends a frame through an interface's driver.
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.

Variables

struct netif * netifs

Macro Definition Documentation

◆ NETIF_LOOPBACK

#define NETIF_LOOPBACK   0x0004

Definition at line 10 of file netif.h.

Referenced by ifreq_request(), ipv4_input(), ipv4_route(), loopback_init(), and netif_register().

◆ NETIF_RUNNING

#define NETIF_RUNNING   0x0002

Definition at line 9 of file netif.h.

Referenced by e1000_probe(), ifreq_request(), link_check(), and loopback_init().

◆ NETIF_UP

#define NETIF_UP   0x0001

Function Documentation

◆ 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.

TCP's timers use it.

Parameters
cthe callout
nsthe delay, in ns
fnthe function to call
argits argument

Definition at line 137 of file netif.c.

References callout_set_on(), net_callout_set(), net_callouts, net_thread, and thread_wakeup().

Referenced by arp_resolve(), arp_retry(), keepalive_timeout(), net_callout_set(), rexmt_timeout(), tcp_dack(), tcp_fin_wait_2(), tcp_keepalive_reset(), tcp_output(), tcp_rexmt_start(), and tcp_time_wait().

◆ netif_find()

struct netif * netif_find ( const char * name)

Finds an interface by its name.

Parameters
namethe name (at most 16 characters, IFNAMSIZ)
Returns
the interface, or NULL

Definition at line 186 of file netif.c.

References netif::name, netif_find(), netifs, netif::next, and NULL.

Referenced by ifreq_request(), netif_find(), and socket_inet_setsockopt().

◆ netif_input()

void netif_input ( struct netif * netif,
struct netbuf * nb )

Hands the stack a frame that a driver received, possibly from an interrupt.

The netbuf is the stack's from now on.

Parameters
netifthe interface it came in on
nbthe frame

Definition at line 323 of file netif.c.

References netbuf::len, netbuf::loopback, netbuf::netif, netif_input(), rx_queue(), and netif::stats.

Referenced by loopback_transmit(), netif_input(), and rx_poll().

◆ 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 interface.

Parameters
netifthe interface it is received on
nbthe packet, from its IPv4 header

Definition at line 340 of file netif.c.

References netbuf::len, netbuf::loopback, netbuf::netif, netif_loopback(), rx_queue(), and netif::stats.

Referenced by ipv4_output(), and netif_loopback().

◆ netif_output()

int netif_output ( struct netif * netif,
struct netbuf * nb )

Sends a frame through an interface's driver.

The netbuf stays the caller's.

Parameters
netifthe interface
nbthe frame
Returns
0, or the driver's negative errno

Definition at line 358 of file netif.c.

References netbuf::len, netif_output(), netif::stats, and netif::transmit.

Referenced by ether_output(), and netif_output().

◆ netif_register()

int netif_register ( struct netif * netif)

Registers a network interface.

An interface without a name gets the next "ethN". The first Ethernet interface is configured from the kernel's ip= argument. The network's thread is started with the first interface.

Parameters
netifthe interface, with its MAC address and transmit set
Returns
0

Definition at line 206 of file netif.c.

References ethers_nr, netif::flags, kthread_create(), loopback, loopback_init(), netif::mac, mac_string(), netif::mtu, netif::name, net_main(), net_thread, netif_config(), NETIF_LOOPBACK, netif_register(), netifs, netif::next, NULL, panic, printk(), snprintf(), netif::transmit, and thread::urgent.

Referenced by e1000_probe(), loopback_init(), and netif_register().

Variable Documentation

◆ netifs

struct netif* netifs
extern

Definition at line 34 of file netif.c.

Referenced by ifconf(), ipv4_is_local(), ipv4_route(), netif_find(), netif_index(), netif_register(), and route().