KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
net.h File Reference

Network support. More...

#include <sys/cdefs.h>
#include <arch/types.h>
#include <sys/queue.h>
#include <netinet/in.h>

Go to the source code of this file.

Data Structures

struct  netif_t
 Structure describing one usable network device. More...
 
struct  ip_hdr_t
 IPv4 Packet header. More...
 
struct  ipv6_hdr_t
 IPv6 Packet header. More...
 
struct  net_ipv4_stats_t
 IPv4 statistics structure. More...
 
struct  net_ipv6_stats_t
 IPv6 statistics structure. More...
 
struct  net_udp_stats_t
 UDP statistics structure. More...
 

Macros

#define NETIF_NO_FLAGS   0x00000000
 No flags set.
 
#define NETIF_REGISTERED   0x00000001
 Is it registered?
 
#define NETIF_DETECTED   0x00000002
 Is it detected?
 
#define NETIF_INITIALIZED   0x00000004
 Has it been initialized?
 
#define NETIF_RUNNING   0x00000008
 Has start() been called?
 
#define NETIF_PROMISC   0x00010000
 Promiscuous mode.
 
#define NETIF_NEEDSPOLL   0x01000000
 Needs to be polled for input.
 
#define NETIF_NOETH   0x10000000
 Does not use ethernet.
 
#define NETIF_TX_OK   0
 Tx success.
 
#define NETIF_TX_ERROR   -1
 Tx general error.
 
#define NETIF_TX_AGAIN   -2
 Retry Tx later.
 
#define NETIF_NOBLOCK   0
 Don't block for Tx.
 
#define NETIF_BLOCK   1
 Blocking is OK for Tx.
 
#define ICMP_PROTOCOL_UNREACHABLE   2
 Protocol unreachable.
 
#define ICMP_PORT_UNREACHABLE   3
 Port unreachable.
 
#define ICMP_REASSEMBLY_TIME_EXCEEDED   1
 Valid values for the code in the net_icmp_send_time_exceeded() function.
 
#define ICMP6_DEST_UNREACH_NO_ROUTE   0
 No route available.
 
#define ICMP6_DEST_UNREACH_PROHIBITED   1
 Access prohibited.
 
#define ICMP6_DEST_UNREACH_BEYOND_SCOPE   2
 Gone beyond scope.
 
#define ICMP6_DEST_UNREACH_ADDR_UNREACH   3
 Address unreachable.
 
#define ICMP6_DEST_UNREACH_PORT_UNREACH   4
 Port unreachable.
 
#define ICMP6_DEST_UNREACH_FAIL_EGRESS   5
 Egress failure.
 
#define ICMP6_DEST_UNREACH_BAD_ROUTE   6
 Bad route specified.
 
#define ICMP6_TIME_EXCEEDED_HOPS_EXC   0
 Hops exceeded.
 
#define ICMP6_TIME_EXCEEDED_FRAGMENT   1
 Reassembly time gone.
 
#define ICMP6_PARAM_PROB_BAD_HEADER   0
 Malformed header.
 
#define ICMP6_PARAM_PROB_UNK_HEADER   1
 Unknown header.
 
#define ICMP6_PARAM_PROB_UNK_OPTION   2
 Unknown header option.
 

Typedefs

typedef int(* net_input_func) (netif_t *nif, const uint8 *pkt, int len)
 Network input callback type.
 
typedef void(* net_echo_cb) (const uint8 *ip, uint16 seq, uint64 delta_us, uint8 ttl, const uint8 *data, size_t len)
 ICMPv4 echo reply callback type.
 
typedef void(* net6_echo_cb) (const struct in6_addr *ip, uint16 seq, uint64 delta_us, uint8 hlim, const uint8 *data, size_t len)
 ICMPv6 echo reply callback type.
 

Functions

int net_arp_init (void)
 Init ARP.
 
void net_arp_shutdown (void)
 Shutdown ARP.
 
int net_arp_insert (netif_t *nif, const uint8 mac[6], const uint8 ip[4], uint64 timestamp)
 Add an entry to the ARP cache manually.
 
int net_arp_lookup (netif_t *nif, const uint8 ip_in[4], uint8 mac_out[6], const ip_hdr_t *pkt, const uint8 *data, int data_size)
 Look up an entry from the ARP cache.
 
int net_arp_revlookup (netif_t *nif, uint8 ip_out[4], const uint8 mac_in[6])
 Do a reverse ARP lookup.
 
int net_arp_input (netif_t *nif, const uint8 *pkt, int len)
 Receive an ARP packet and process it (called by net_input).
 
int net_arp_query (netif_t *nif, const uint8 ip[4])
 Generate an ARP who-has query on the given device.
 
int net_input (netif_t *device, const uint8 *data, int len)
 Device drivers should call this function to submit packets received in the background.
 
net_input_func net_input_set_target (net_input_func t)
 Setup a network input target.
 
int net_icmp_send_echo (netif_t *net, const uint8 ipaddr[4], uint16 ident, uint16 seq, const uint8 *data, size_t size)
 Send an ICMP Echo packet to the specified IP.
 
int net_icmp_send_dest_unreach (netif_t *net, uint8 code, const uint8 *msg)
 Send an ICMP Destination Unreachable packet in reply to the given message.
 
int net_icmp_send_time_exceeded (netif_t *net, uint8 code, const uint8 *msg)
 Send an ICMP Time Exceeded packet in reply to the given message.
 
net_ipv4_stats_t net_ipv4_get_stats (void)
 Retrieve statistics from the IPv4 layer.
 
uint32 net_ipv4_address (const uint8 addr[4])
 Create a 32-bit IP address, based on the individual numbers contained within the IP.
 
void net_ipv4_parse_address (uint32 addr, uint8 out[4])
 Parse an IP address that is packet into a uint32 into an array of the individual bytes.
 
int net_icmp6_send_echo (netif_t *net, const struct in6_addr *dst, uint16 ident, uint16 seq, const uint8 *data, size_t size)
 Send an ICMPv6 Echo (PING6) packet to the specified device.
 
int net_icmp6_send_nsol (netif_t *net, const struct in6_addr *dst, const struct in6_addr *target, int dupdet)
 Send a Neighbor Solicitation packet on the specified device.
 
int net_icmp6_send_nadv (netif_t *net, const struct in6_addr *dst, const struct in6_addr *target, int sol)
 Send a Neighbor Advertisement packet on the specified device.
 
int net_icmp6_send_rsol (netif_t *net)
 Send a Router Solicitation request on the specified interface.
 
int net_icmp6_send_dest_unreach (netif_t *net, uint8 code, const uint8 *ppkt, size_t psz)
 Send a destination unreachable packet on the specified interface.
 
int net_icmp6_send_time_exceeded (netif_t *net, uint8 code, const uint8 *ppkt, size_t psz)
 Send a time exceeded message on the specified interface.
 
int net_icmp6_send_param_prob (netif_t *net, uint8 code, uint32 ptr, const uint8 *ppkt, size_t psz)
 Send an ICMPv6 Parameter Problem about the given packet.
 
net_ipv6_stats_t net_ipv6_get_stats (void)
 Retrieve statistics from the IPv6 layer.
 
int net_ndp_init (void)
 Init NDP.
 
void net_ndp_shutdown (void)
 Shutdown NDP.
 
void net_ndp_gc (void)
 Garbage collect timed out NDP entries.
 
int net_ndp_insert (netif_t *nif, const uint8 mac[6], const struct in6_addr *ip, int unsol)
 Add an entry to the NDP cache.
 
int net_ndp_lookup (netif_t *net, const struct in6_addr *ip, uint8 mac_out[6], const ipv6_hdr_t *pkt, const uint8 *data, int data_size)
 Look up an entry from the NDP cache.
 
net_udp_stats_t net_udp_get_stats (void)
 Retrieve statistics from the UDP layer.
 
int net_udp_init (void)
 Init UDP.
 
void net_udp_shutdown (void)
 Shutdown UDP.
 
int net_tcp_init (void)
 Init TCP.
 
void net_tcp_shutdown (void)
 Shutdown TCP.
 
uint32 net_crc32le (const uint8 *data, int size)
 Calculate a "little-endian" CRC-32 over a block of data.
 
uint32 net_crc32be (const uint8 *data, int size)
 Calculate a "big-endian" CRC-32 over a block of data.
 
uint16 net_crc16ccitt (const uint8 *data, int size, uint16 start)
 Calculate a CRC16-CCITT over a block of data.
 
int net_multicast_add (const uint8 mac[6])
 Add a entry to our multicast list.
 
int net_multicast_del (const uint8 mac[6])
 Delete a entry from our multicast list.
 
int net_multicast_check (const uint8 mac[6])
 Check if an address is on the multicast list.
 
int net_multicast_init (void)
 Init multicast support.
 
void net_multicast_shutdown (void)
 Shutdown multicast support.
 
struct netif_list * net_get_if_list (void)
 Function to retrieve the interface list.
 
netif_tnet_set_default (netif_t *n)
 Set our default device to an arbitrary device.
 
int net_reg_device (netif_t *device)
 Register a network device.
 
int net_unreg_device (netif_t *device)
 Unregister a network device.
 
int net_init (uint32 ip)
 Init network support.
 
void net_shutdown (void)
 Shutdown network support.
 

Variables

net_input_func net_input_target
 Where will input packets be routed?
 
net_echo_cb net_icmp_echo_cb
 Where will we handle possibly notifying the user of ping replies?
 
net6_echo_cb net_icmp6_echo_cb
 Where will we handle possibly notifying the user of ping replies?
 
struct netif_list net_if_list
 Interface list; note: do not manipulate directly!
 
netif_tnet_default_dev
 The default network device, used with sockets (read-only).
 

Detailed Description

Network support.

This file contains declarations related to networking support.

Author
Lawrence Sebald
Megan Potter