#include <async.h>
#include <errno.h>
#include <fibril_synch.h>
#include <stdio.h>
#include <str.h>
#include <ipc/services.h>
#include <ipc/net.h>
#include <ipc/nil.h>
#include <ipc/il.h>
#include <ipc/ip.h>
#include <sys/types.h>
#include <byteorder.h>
#include "ip.h"
#include <adt/measured_strings.h>
#include <adt/module_map.h>
#include <packet_client.h>
#include <net/socket_codes.h>
#include <net/in.h>
#include <net/in6.h>
#include <net/inet.h>
#include <net/modules.h>
#include <net/device.h>
#include <net/packet.h>
#include <net/icmp_codes.h>
#include <arp_interface.h>
#include <net_checksum.h>
#include <icmp_client.h>
#include <icmp_remote.h>
#include <ip_client.h>
#include <ip_interface.h>
#include <ip_header.h>
#include <net_interface.h>
#include <nil_remote.h>
#include <tl_remote.h>
#include <packet_remote.h>
#include <il_remote.h>
#include <il_skel.h>
Go to the source code of this file.
Defines | |
#define | ARP_FILENAME "/srv/arp" |
ARP module filename. | |
#define | ARP_NAME "arp" |
ARP module name. | |
#define | IP_ADDR sizeof(struct sockaddr_in6) |
IP packet address length. | |
#define | IP_MAX_CONTENT 65535 |
IP packet maximum content length. | |
#define | IP_MIN_CONTENT 576 |
Minimum IP packet content. | |
#define | IP_PREFIX sizeof(ip_header_t) |
IP packet prefix length. | |
#define | IP_SUFFIX 0 |
IP packet suffix length. | |
#define | IPV4 4 |
IP version 4. | |
#define | IPV4_LOCALHOST_ADDRESS htonl((127 << 24) + 1) |
The IP localhost address. | |
#define | NAME "ip" |
IP module name. | |
#define | NET_DEFAULT_IP_ROUTING false |
Default network interface IP routing. | |
#define | NET_DEFAULT_IPV IPV4 |
Default network interface IP version. | |
Functions | |
int | il_initialize (int net_phone) |
Module initialization. | |
int | il_module_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *answer_count) |
Process the internetwork layer module message. | |
static int | ip_add_route_req_local (int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway) |
static void | ip_create_last_header (ip_header_t *last, ip_header_t *first) |
Copies the fragment header. | |
static ip_header_t * | ip_create_middle_header (packet_t *packet, ip_header_t *last) |
Prefixes a middle fragment header based on the last fragment header to the packet. | |
static int | ip_deliver_local (device_id_t device_id, packet_t *packet, ip_header_t *header, services_t error) |
Delivers the packet to the local host. | |
static int | ip_device_req_local (int il_phone, device_id_t device_id, services_t netif) |
static int | ip_device_state_message (device_id_t device_id, device_state_t state) |
Updates the device state. | |
static ip_route_t * | ip_find_route (in_addr_t destination) |
Searches all network interfaces if there is a suitable route. | |
static int | ip_fragment_packet (packet_t *packet, size_t length, size_t prefix, size_t suffix, socklen_t addr_len) |
Checks the packet length and fragments it if needed. | |
static int | ip_fragment_packet_data (packet_t *packet, packet_t *new_packet, ip_header_t *header, ip_header_t *new_header, size_t length, const struct sockaddr *src, const struct sockaddr *dest, socklen_t addrlen) |
Fragments the packet from the end. | |
static in_addr_t | ip_get_destination (ip_header_t *header) |
Returns the packet destination address from the IP header. | |
static int | ip_get_icmp_phone (void) |
Returns the ICMP phone. | |
static int | ip_get_route_req_local (int ip_phone, ip_protocol_t protocol, const struct sockaddr *destination, socklen_t addrlen, device_id_t *device_id, void **header, size_t *headerlen) |
static int | ip_mtu_changed_message (device_id_t device_id, size_t mtu) |
Updates the device content length according to the new MTU value. | |
static in_addr_t * | ip_netif_address (ip_netif_t *netif) |
Returns the network interface's IP address. | |
static ip_route_t * | ip_netif_find_route (ip_netif_t *netif, in_addr_t destination) |
Searches the network interfaces if there is a suitable route. | |
static int | ip_netif_initialize (ip_netif_t *ip_netif) |
Initializes a new network interface specific data. | |
static int | ip_packet_size_message (device_id_t device_id, size_t *addr_len, size_t *prefix, size_t *content, size_t *suffix) |
Returns the device packet dimensions for sending. | |
static int | ip_prepare_icmp (packet_t *packet, ip_header_t *header) |
Prepares the ICMP notification packet. | |
static int | ip_prepare_icmp_and_get_phone (services_t error, packet_t *packet, ip_header_t *header) |
Prepares the ICMP notification packet. | |
static int | ip_prepare_packet (in_addr_t *source, in_addr_t dest, packet_t *packet, measured_string_t *destination) |
Prepares the outgoing packet or the packet queue. | |
static int | ip_process_packet (device_id_t device_id, packet_t *packet) |
Processes the received packet. | |
static int | ip_received_error_msg_local (int ip_phone, device_id_t device_id, packet_t *packet, services_t target, services_t error) |
Notify the IP module about the received error notification packet. | |
static void | ip_receiver (ipc_callid_t iid, ipc_call_t *icall) |
Process IPC messages from the registered device driver modules. | |
static int | ip_register (int protocol, services_t service, int phone, tl_received_msg_t received_msg) |
Registers the transport layer protocol. | |
static int | ip_release_and_return (packet_t *packet, int result) |
Releases the packet and returns the result. | |
static int | ip_send_msg_local (int il_phone, device_id_t device_id, packet_t *packet, services_t sender, services_t error) |
static int | ip_send_route (packet_t *packet, ip_netif_t *netif, ip_route_t *route, in_addr_t *src, in_addr_t dest, services_t error) |
Sends the packet or the packet queue via the specified route. | |
static int | ip_set_gateway_req_local (int ip_phone, device_id_t device_id, in_addr_t gateway) |
static packet_t * | ip_split_packet (packet_t *packet, size_t prefix, size_t content, size_t suffix, socklen_t addr_len, services_t error) |
Checks the packet queue lengths and fragments the packets if needed. | |
int | main (int argc, char *argv[]) |
Main entry point. | |
Variables | |
ip_globals_t | ip_globals |
IP global data. |
Definition in file ip.c.