IP module implementation. More...
#include <async.h>
#include <errno.h>
#include <fibril_synch.h>
#include <stdio.h>
#include <string.h>
#include <ipc/ipc.h>
#include <ipc/services.h>
#include <sys/types.h>
#include "../../err.h"
#include "../../messages.h"
#include "../../modules.h"
#include "../../include/arp_interface.h"
#include "../../include/byteorder.h"
#include "../../include/checksum.h"
#include "../../include/device.h"
#include "../../include/icmp_client.h"
#include "../../include/icmp_codes.h"
#include "../../include/icmp_interface.h"
#include "../../include/il_interface.h"
#include "../../include/in.h"
#include "../../include/in6.h"
#include "../../include/inet.h"
#include "../../include/ip_client.h"
#include "../../include/ip_interface.h"
#include "../../include/net_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/tl_interface.h"
#include "../../include/socket_codes.h"
#include "../../include/socket_errno.h"
#include "../../structures/measured_strings.h"
#include "../../structures/module_map.h"
#include "../../structures/packet/packet_client.h"
#include "../../nil/nil_messages.h"
#include "../il_messages.h"
#include "ip.h"
#include "ip_header.h"
#include "ip_messages.h"
#include "ip_module.h"
Defines | |
#define | IPV4 4 |
IP version 4. | |
#define | NET_DEFAULT_IPV IPV4 |
Default network interface IP version. | |
#define | NET_DEFAULT_IP_ROUTING false |
Default network interface IP routing. | |
#define | IP_MIN_CONTENT 576 |
Minimum IP packet content. | |
#define | ARP_NAME "arp" |
ARP module name. | |
#define | ARP_FILENAME "/srv/arp" |
ARP module filename. | |
#define | IP_ADDR sizeof(struct sockaddr_in6) |
IP packet address length. | |
#define | IP_PREFIX sizeof(ip_header_t) |
IP packet prefix length. | |
#define | IP_SUFFIX 0 |
IP packet suffix length. | |
#define | IP_MAX_CONTENT 65535 |
IP packet maximum content length. | |
#define | IPV4_LOCALHOST_ADDRESS htonl((127 << 24) + 1) |
The IP localhost address. | |
Functions | |
int | ip_mtu_changed_message (device_id_t device_id, size_t mtu) |
Updates the device content length according to the new MTU value. | |
int | ip_device_state_message (device_id_t device_id, device_state_t state) |
Updates the device state. | |
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. | |
int | ip_register (int protocol, services_t service, int phone, tl_received_msg_t tl_received_msg) |
Registers the transport layer protocol. | |
int | ip_netif_initialize (ip_netif_ref ip_netif) |
Initializes a new network interface specific data. | |
int | ip_send_route (packet_t packet, ip_netif_ref netif, ip_route_ref route, in_addr_t *src, in_addr_t dest, services_t error) |
Sends the packet or the packet queue via the specified route. | |
int | ip_prepare_packet (in_addr_t *source, in_addr_t dest, packet_t packet, measured_string_ref destination) |
Prepares the outgoing packet or the packet queue. | |
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 | 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. | |
int | ip_fragment_packet_data (packet_t packet, packet_t new_packet, ip_header_ref header, ip_header_ref new_header, size_t length, const struct sockaddr *src, const struct sockaddr *dest, socklen_t addrlen) |
Fragments the packet from the end. | |
ip_header_ref | ip_create_middle_header (packet_t packet, ip_header_ref last) |
Prefixes a middle fragment header based on the last fragment header to the packet. | |
void | ip_create_last_header (ip_header_ref last, ip_header_ref first) |
Copies the fragment header. | |
in_addr_t * | ip_netif_address (ip_netif_ref netif) |
Returns the network interface's IP address. | |
ip_route_ref | ip_find_route (in_addr_t destination) |
Searches all network interfaces if there is a suitable route. | |
ip_route_ref | ip_netif_find_route (ip_netif_ref netif, in_addr_t destination) |
Searches the network interfaces if there is a suitable route. | |
int | ip_receive_message (device_id_t device_id, packet_t packet) |
Processes the received IP packet or the packet queue one by one. | |
int | ip_process_packet (device_id_t device_id, packet_t packet) |
Processes the received packet. | |
in_addr_t | ip_get_destination (ip_header_ref header) |
Returns the packet destination address from the IP header. | |
int | ip_deliver_local (device_id_t device_id, packet_t packet, ip_header_ref header, services_t error) |
Delivers the packet to the local host. | |
int | ip_prepare_icmp_and_get_phone (services_t error, packet_t packet, ip_header_ref header) |
Prepares the ICMP notification packet. | |
int | ip_get_icmp_phone (void) |
Returns the ICMP phone. | |
int | ip_prepare_icmp (packet_t packet, ip_header_ref header) |
Prepares the ICMP notification packet. | |
int | ip_release_and_return (packet_t packet, int result) |
Releases the packet and returns the result. | |
int | ip_initialize (async_client_conn_t client_connection) |
Initializes the IP module. | |
int | ip_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, int *answer_count) |
Processes the IP message. | |
IP module interface | |
int | ip_device_req (int ip_phone, device_id_t device_id, services_t netif) |
Registers the new device. | |
int | ip_connect_module (services_t service) |
Connects to the IP module. | |
int | ip_bind_service (services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg) |
Creates bidirectional connection with the ip module service and registers the message receiver. | |
int | ip_send_msg (int ip_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error) |
Sends the packet queue. | |
int | ip_packet_size_req (int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension) |
Returns the device packet dimension for sending. | |
int | ip_add_route_req (int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway) |
Adds a route to the device routing table. | |
int | ip_set_gateway_req (int ip_phone, device_id_t device_id, in_addr_t gateway) |
Sets the default gateway. | |
int | ip_received_error_msg (int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error) |
Notifies the IP module about the received error notification packet. | |
int | ip_get_route_req (int ip_phone, ip_protocol_t protocol, const struct sockaddr *destination, socklen_t addrlen, device_id_t *device_id, ip_pseudo_header_ref *header, size_t *headerlen) |
Returns the device identifier and the IP pseudo header based on the destination address. | |
Variables | |
ip_globals_t | ip_globals |
IP global data. |
IP module implementation.