Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 4504 → Rev 4505

/branches/network/uspace/srv/net/tl/tcp/tcp.c
87,18 → 87,23
uint8_t * data;
data = packet_get_data( packet );
printf( "Receiving packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id( packet ), packet_get_data_length( packet ), data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ], data[ 16 ], data[ 17 ], data[ 18 ], data[ 19 ], data[ 20 ], data[ 21 ], data[ 22 ], data[ 23 ], data[ 24 ], data[ 25 ], data[ 26 ], data[ 27 ], data[ 28 ], data[ 29 ], data[ 30 ], data[ 31 ], data[ 32 ], data[ 33 ], data[ 34 ], data[ 35 ], data[ 36 ], data[ 37 ], data[ 38 ], data[ 39 ], data[ 40 ], data[ 41 ], data[ 42 ], data[ 43 ], data[ 44 ], data[ 45 ], data[ 46 ], data[ 47 ], data[ 48 ], data[ 49 ], data[ 50 ], data[ 51 ], data[ 52 ], data[ 53 ], data[ 54 ], data[ 55 ], data[ 56 ], data[ 57 ], data[ 58 ], data[ 59 ] );
pq_release( tcp_globals.net_phone, packet_get_id( packet ));
 
return EOK;
}
 
int tcp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
ERROR_DECLARE;
 
packet_t packet;
 
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
return EOK;
case NET_TL_RECEIVED:
// TODO received
return ENOTSUP;
ERROR_PROPAGATE( packet_translate( tcp_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return tcp_received_msg( IPC_GET_DEVICE( call ), packet, 0 );
}
return ENOTSUP;
}
/branches/network/uspace/srv/net/tl/udp/udp.c
88,18 → 88,23
uint8_t * data;
data = packet_get_data( packet );
printf( "Receiving packet:\n\tid\t= %d\n\tlength\t= %d\n\tdata\t= %.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX\n\t\t%.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX:%.2hhX %.2hhX %.2hhX %.2hhX\n", packet_get_id( packet ), packet_get_data_length( packet ), data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ], data[ 16 ], data[ 17 ], data[ 18 ], data[ 19 ], data[ 20 ], data[ 21 ], data[ 22 ], data[ 23 ], data[ 24 ], data[ 25 ], data[ 26 ], data[ 27 ], data[ 28 ], data[ 29 ], data[ 30 ], data[ 31 ], data[ 32 ], data[ 33 ], data[ 34 ], data[ 35 ], data[ 36 ], data[ 37 ], data[ 38 ], data[ 39 ], data[ 40 ], data[ 41 ], data[ 42 ], data[ 43 ], data[ 44 ], data[ 45 ], data[ 46 ], data[ 47 ], data[ 48 ], data[ 49 ], data[ 50 ], data[ 51 ], data[ 52 ], data[ 53 ], data[ 54 ], data[ 55 ], data[ 56 ], data[ 57 ], data[ 58 ], data[ 59 ] );
pq_release( udp_globals.net_phone, packet_get_id( packet ));
 
return EOK;
}
 
int udp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
ERROR_DECLARE;
 
packet_t packet;
 
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
case IPC_M_PHONE_HUNGUP:
return EOK;
case NET_TL_RECEIVED:
// TODO received
return ENOTSUP;
ERROR_PROPAGATE( packet_translate( udp_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return udp_received_msg( IPC_GET_DEVICE( call ), packet, 0 );
}
return ENOTSUP;
}
/branches/network/uspace/srv/net/nil/eth/eth.c
548,7 → 548,7
 
length = packet_get_addr( packet, & src, & dest );
if( length < 0 ) return length;
if( length < ETH_ADDR ) return EINVAL;
if( length != ETH_ADDR ) return EINVAL;
length = packet_get_data_length( packet );
if( length > mtu ) return EINVAL;
if( length < ETH_MIN_TAGGED_CONTENT( flags )){
/branches/network/uspace/srv/net/structures/packet/packet_remote.c
36,6 → 36,7
*/
 
#include <async.h>
#include <errno.h>
 
#include <ipc/ipc.h>
#include <sys/mman.h>
45,6 → 46,7
 
#include "packet.h"
#include "packet_client.h"
#include "packet_header.h"
#include "packet_messages.h"
 
/** Obtains the packet from the packet server as the shared memory block.
63,12 → 65,17
ERROR_DECLARE;
 
unsigned int size;
packet_t next;
 
if( ! packet ) return EINVAL;
* packet = pm_find( packet_id );
if( * packet ) return EOK;
ERROR_PROPAGATE( async_req_1_1( phone, NET_PACKET_GET_SIZE, packet_id, & size ));
return packet_return( phone, packet, packet_id, size );
if( !( * packet )){
ERROR_PROPAGATE( async_req_1_1( phone, NET_PACKET_GET_SIZE, packet_id, & size ));
ERROR_PROPAGATE( packet_return( phone, packet, packet_id, size ));
}
if(( ** packet ).next ){
return packet_translate( phone, & next, ( ** packet ).next );
}else return EOK;
}
 
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size ){
97,10 → 104,15
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_4_2( phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, ( ipcarg_t * ) & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
if( ERROR_OCCURRED( async_req_4_2( phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, ( ipcarg_t * ) & packet_id, & size ))){
return NULL;
}
packet = pm_find( packet_id );
if( ! packet ){
if( ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
}
return packet;
}
 
111,10 → 123,15
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, ( ipcarg_t * ) & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, ( ipcarg_t * ) & packet_id, & size ))){
return NULL;
}
packet = pm_find( packet_id );
if( ! packet ){
if( ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
}
return packet;
}
 
/branches/network/uspace/srv/net/structures/packet/packet_header.h
37,8 → 37,6
#ifndef __NET_PACKET_HEADER_H__
#define __NET_PACKET_HEADER_H__
 
#include "../../messages.h"
 
#include "packet.h"
 
/** Packet integrity check magic value.
/branches/network/uspace/srv/net/structures/packet/packet_client.c
34,16 → 34,13
* Packet client implementation.
*/
 
#include <async.h>
#include <errno.h>
#include <mem.h>
#include <unistd.h>
//#include <stdio.h>
 
#include <ipc/ipc.h>
#include <sys/mman.h>
 
#include "../../err.h"
#include "../../messages.h"
 
#include "packet.h"
61,7 → 58,7
}
 
void * packet_prefix( packet_t packet, size_t length ){
if(( ! packet_is_valid( packet )) || ( packet->data_start - sizeof( struct packet ) - 2 * packet->addr_len < length )) return NULL;
if(( ! packet_is_valid( packet )) || ( packet->data_start - sizeof( struct packet ) - 2 * ( packet->dest_addr - packet->src_addr ) < length )) return NULL;
packet->data_start -= length;
return ( void * ) packet + packet->data_start;
}
/branches/network/uspace/srv/net/structures/packet/packet.c
40,6 → 40,7
#include <mem.h>
#include <rwlock.h>
//#include <stdio.h>
#include <unistd.h>
 
#include <sys/mman.h>
 
47,8 → 48,8
 
#include "../generic_field.h"
 
#include "packet.h"
#include "packet_header.h"
#include "packet.h"
 
/** Packet map page size.
*/
211,6 → 212,18
return packet;
}
 
int pq_insert_after( packet_t packet, packet_t new_packet ){
packet_t item;
 
if( !( packet_is_valid( packet ) && packet_is_valid( new_packet ))) return EINVAL;
new_packet->previous = packet->packet_id;
new_packet->next = packet->next;
item = pm_find( packet->next );
if( item ) item->previous = new_packet->packet_id;
packet->next = new_packet->packet_id;
return EOK;
}
 
packet_t pq_detach( packet_t packet ){
packet_t next;
packet_t previous;
/branches/network/uspace/srv/net/structures/packet/packet.h
107,6 → 107,14
*/
packet_t pq_add( packet_t first, packet_t packet, int order, size_t metric );
 
/** Inserts packet after the given one.
* @param packet The packet in the queue. Input parameter.
* @param new_packet The new packet to be inserted.
* @returns EOK on success.
* @returns EINVAL if etiher of the packets is invalid.
*/
int pq_insert_after( packet_t packet, packet_t new_packet );
 
/** Detach the packet from the queue.
* @param packet The packet to be detached. Input parameter.
* @returns The next packet in the queue. If the packet is the first one of the queue, this becomes the new first one.
/branches/network/uspace/srv/net/structures/packet/packet_server.c
194,8 → 194,8
case NET_PACKET_GET_SIZE:
packet = pm_find( IPC_GET_ID( call ));
if( ! packet_is_valid( packet )) return ENOENT;
IPC_SET_ARG1( * answer, packet->length );
* answer_count = 1;
IPC_SET_ARG1( * answer, packet->length );
return EOK;
case NET_PACKET_RELEASE:
return packet_release_wrapper( IPC_GET_ID( call ));
234,7 → 234,12
while( packet_is_valid( packet ) && ( packet->length < length )){
packet = pm_find( packet->next );
}
if( packet ){
if( packet_is_valid( packet )){
if( packet == ps_globals.free[ index ] ){
ps_globals.free[ index ] = pq_detach( packet );
}else{
pq_detach( packet );
}
packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
futex_up( & ps_globals.lock );
return packet;
258,29 → 263,24
packet->packet_id = ps_globals.count;
packet->length = length;
packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
packet->magic_value = PACKET_MAGIC_VALUE;
if( ERROR_OCCURRED( pm_add( packet ))){
munmap( packet, packet->length );
return NULL;
}
packet_release( packet );
return packet;
}
 
void packet_init( packet_t packet, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix ){
int length;
 
// clear whole packet
length = packet->length;
bzero( packet, packet->length );
packet->length = length;
packet->magic_value = PACKET_MAGIC_VALUE;
/* // clear the packet header
// clear the packet content
bzero((( void * ) packet ) + sizeof( struct packet ), packet->length - sizeof( struct packet ));
// clear the packet header
packet->order = 0;
packet->metric = 0;
packet->previous = 0;
packet->next = 0;
packet->addr_len = 0;
*/ packet->src_addr = sizeof( struct packet );
packet->src_addr = sizeof( struct packet );
packet->dest_addr = packet->src_addr + addr_len;
packet->max_prefix = max_prefix;
packet->max_content = max_content;
/branches/network/uspace/srv/net/structures/generic_char_map.h
36,6 → 36,7
#ifndef __GENERIC_CHAR_MAP_H__
#define __GENERIC_CHAR_MAP_H__
 
#include <errno.h>
#include <unistd.h>
 
#include "../err.h"
/branches/network/uspace/srv/net/include/sockaddr.h
39,8 → 39,8
 
#include <sys/types.h>
 
#define INET_ADDRSTRLEN ( 4 * 3 + 3 )
#define INET6_ADDRSTRLEN ( 8 * 4 + 7 )
#define INET_ADDRSTRLEN ( 4 * 3 + 3 + 1 )
#define INET6_ADDRSTRLEN ( 8 * 4 + 7 + 1 )
 
typedef struct sockaddr sockaddr_t;
typedef struct in_addr in_addr_t;
/branches/network/uspace/srv/net/include/ip_client.h
0,0 → 1,137
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup ip
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_IP_CLIENT_H__
#define __NET_IP_CLIENT_H__
 
#include "../structures/packet/packet.h"
 
#define IPVERSION 4
#define MAXTTL 255
#define IPDEFTTL 64
 
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_PRECEDENCE_SHIFT 5
#define IPTOS_DELAY_SHIFT 4
#define IPTOS_THROUGHPUT_SHIFT 3
#define IPTOS_RELIABILITY_SHIFT 2
#define IPTOS_COST_SHIFT 1
 
#define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT )
#define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT )
 
#define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT )
#define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT )
 
#define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT )
#define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT )
 
#define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT )
#define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT )
 
#define IPTOS_PREC_MASK 0xE0
#define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT )
 
#define IPOPT_COPY_SHIFT 7
#define IPOPT_CLASS_SHIFT 5
#define IPOPT_NUMBER_SHIFT 0
#define IPOPT_CLASS_MASK 0x60
#define IPOPT_NUMBER_MASK 0x1F
 
#define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT )
 
#define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK ))
 
#define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY )
#define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK )
#define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK )
 
#define IPOPT_CONTROL ( 0 << IPOPT_CLASS_SHIFT )
#define IPOPT_RESERVED1 ( 1 << IPOPT_CLASS_SHIFT )
#define IPOPT_MEASUREMENT ( 2 << IPOPT_CLASS_SHIFT )
#define IPOPT_RESERVED2 ( 3 << IPOPT_CLASS_SHIFT )
 
//#define IPOPT_END_OF_LIST 0x0
#define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 )
//#define IPOPT_NO_OPERATION 0x1
#define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 )
//#define IPOPT_SECURITY 0x82
#define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 )
#define IPOPT_SEC_LENGTH 11
#define IPOPT_SEC_UNCLASIFIED 0x0
#define IPOPT_SEC_CONFIDENTIAL 0xF035
#define IPOPT_SEC_EFTO 0x789A
#define IPOPT_SEC_MMMM 0xBC4D
#define IPOPT_SEC_PROG 0x5E26
#define IPOPT_SEC_RESTRICTED 0xAF13
#define IPOPT_SEC_SECRET 0xD788
#define IPOPT_SEC_TOP_SECRET 0x6BC5
//#define IPOPT_LOOSE_SOURCE 0x83
#define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 )
//#define IPOPT_STRICT_SOURCE 0x89
#define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 )
//#define IPOPT_RECORD_ROUTE 0x07
#define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 )
//#define IPOPT_STREAM_IDENTIFIER 0x88
#define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 )
#define IPOPT_SID_LENGTH 4
//#define IPOPT_INTERNET_TIMESTAMP 0x44
#define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 )
#define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 )
 
#define IPOPT_NOP IPOPT_NOOP
#define IPOPT_EOL IPOPT_END
#define IPOPT_TS IPOPT_TIMESTAMP
 
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
 
int ip_client_prepare_packet( packet_t packet, int protocol, int ttl, int tos, int dont_fragment, int ipopt_length );
 
// TODO ipopt manipulation
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/include/net_interface.h
58,7 → 58,7
* @returns EINVAL if the count is zero (0).
* @returns Other error codes as defined for the generic_translate_req() function.
*/
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, int count, char ** data );
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data );
 
/** Returns the global configuration.
* @param net_phone The networking module phone. Input parameter.
70,7 → 70,7
* @returns EINVAL if the count is zero (0).
* @returns Other error codes as defined for the generic_translate_req() function.
*/
int net_get_conf_req( int net_phone, measured_string_ref * configuration, int count, char ** data );
int net_get_conf_req( int net_phone, measured_string_ref * configuration, size_t count, char ** data );
 
/** Frees the received settings.
* @param settings The received settings. Input parameter.
/branches/network/uspace/srv/net/include/crc.h
31,7 → 31,7
*/
 
/** @file
* General CRC computation.
* General CRC and checksum computation.
*/
 
#ifndef __NET_CRC_H__
69,6 → 69,21
*/
uint32_t compute_crc32_be( uint32_t seed, uint8_t * data, int length );
 
/** Computes sum of the 2 byte fields.
* Padds one zero (0) byte if odd.
* @param seed Initial value. Often used as 0 or ~0. Input parameter.
* @param data Pointer to the beginning of data to process. Input parameter.
* @param length Length of the data in bytes. Input parameter.
* @returns The computed checksum of the length bytes of the data.
*/
uint32_t compute_checksum( uint32_t seed, uint8_t * data, int length );
 
/** Compacts the computed checksum to the 16 bit number adding the carries.
* @param Computed checksum. Input parameter.
* @returns Compacted computed checksum to the 16 bits.
*/
uint16_t compact_checksum( uint32_t sum );
 
#endif
 
/** @}
/branches/network/uspace/srv/net/include/ip_interface.h
48,9 → 48,20
 
#include "../structures/packet/packet.h"
 
#include "sockaddr.h"
 
/** The transport layer notification function type definition.
* Notifies the transport layer modules about the received packet/s.
* @param device_id The device identifier. Input parameter.
* @param packet The received packet or the received packet queue. Input parameter.
* @param receiver The receiving module service. Input parameter.
* @returns EOK on success.
*/
typedef int ( * tl_received_msg_t )( device_id_t device_id, packet_t packet, services_t receiver );
 
/** \todo
*/
int ip_bind_service( services_t service, services_t me, async_client_conn_t receiver );
int ip_bind_service( services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg );
 
/** Registers the new device.
* Registers itself as the ip packet receiver.
85,6 → 96,18
*/
int ip_connect_module( services_t service );
 
/** \todo
*/
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 );
 
/** \todo
*/
int ip_set_gateway_req( int ip_phone, device_id_t device_id, in_addr_t gateway );
 
/** \todo
*/
int ip_packet_size_req( int ip_phone, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix );
 
#endif
 
/** @}
/branches/network/uspace/srv/net/net/net_standalone.c
80,8 → 80,8
task_id = spawn( "/srv/ip" );
if( ! task_id ) return EINVAL;
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id, ip_connect_module ));
// if( ! spawn( "/srv/udp" )) return EINVAL;
// if( ! spawn( "/srv/tcp" )) return EINVAL;
if( ! spawn( "/srv/udp" )) return EINVAL;
if( ! spawn( "/srv/tcp" )) return EINVAL;
// if( ! spawn( "/srv/socket" )) return EINVAL;
// not always necesssary
// if( ! spawn( "/srv/arp" )) return EINVAL;
100,6 → 100,7
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "15535" ));
}else if( str_lcmp( name, "ne2k", 4 ) == 0 ){
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ));
110,10 → 111,10
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "576" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.240" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" ));
/branches/network/uspace/srv/net/net/net_bundle.c
49,6 → 49,8
 
#include "../il/arp/arp_module.h"
#include "../il/ip/ip_module.h"
#include "../tl/udp/udp_module.h"
#include "../tl/tcp/tcp_module.h"
 
#include "net.h"
 
57,7 → 59,8
extern net_globals_t net_globals;
 
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
if( IS_NET_IL_MESSAGE( call )){
if(( IPC_GET_METHOD( * call ) == IPC_M_CONNECT_TO_ME )
|| IS_NET_IL_MESSAGE( call )){
switch( IPC_GET_TARGET( call )){
case SERVICE_IP:
return ip_message( callid, call, answer, answer_count );
66,6 → 69,15
default:
return EINVAL;
}
}else if( IS_NET_TL_MESSAGE( call )){
switch( IPC_GET_TARGET( call )){
case SERVICE_UDP:
return udp_message( callid, call, answer, answer_count );
case SERVICE_TCP:
return tcp_message( callid, call, answer, answer_count );
default:
return EINVAL;
}
}else if( IS_NET_IP_MESSAGE( call ) || IS_NET_NIL_MESSAGE( call )){
return ip_message( callid, call, answer, answer_count );
}else if( IS_NET_ARP_MESSAGE( call )){
74,11 → 86,11
return rarp_message( callid, call, answer, answer_count );
}else if( IS_NET_ICMP_MESSAGE( call )){
return icmp_message( callid, call, answer, answer_count );
}else if( IS_NET_UDP_MESSAGE( call )){
*/ }else if( IS_NET_UDP_MESSAGE( call )){
return udp_message( callid, call, answer, answer_count );
}else if( IS_NET_TCP_MESSAGE( call )){
return tcp_message( callid, call, answer, answer_count );
}else if( IS_NET_SOCKET_MESSAGE( call )){
/* }else if( IS_NET_SOCKET_MESSAGE( call )){
return socket_message( callid, call, answer, answer_count );
*/ }else{
if( IS_NET_PACKET_MESSAGE( call )){
114,10 → 126,10
// ERROR_PROPAGATE( rarp_initialize( client_connection ));
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_ICMP, & phonehash ));
// ERROR_PROPAGATE( icmp_initialize( client_connection ));
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_UDP, & phonehash ));
// ERROR_PROPAGATE( udp_initialize( client_connection ));
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_TCP, & phonehash ));
// ERROR_PROPAGATE( tcp_initialize( client_connection ));
ERROR_PROPAGATE( REGISTER_ME( SERVICE_UDP, & phonehash ));
ERROR_PROPAGATE( udp_initialize( client_connection ));
ERROR_PROPAGATE( REGISTER_ME( SERVICE_TCP, & phonehash ));
ERROR_PROPAGATE( tcp_initialize( client_connection ));
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_SOCKET, & phonehash ));
// ERROR_PROPAGATE( socket_initialize( client_connection ));
// ERROR_PROPAGATE( REGISTER_ME( SERVICE_ETHERNET, & phonehash ));
135,6 → 147,7
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "15535" ));
}else if( str_lcmp( name, "ne2k", 4 ) == 0 ){
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ));
147,7 → 160,7
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.0" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.240" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" ));
ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" ));
/branches/network/uspace/srv/net/net/net_remote.c
49,11 → 49,11
 
//#include "net_messages.h"
 
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, int count, char ** data ){
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data ){
return generic_translate_req( net_phone, NET_NET_GET_DEVICE_CONF, device_id, 0, * configuration, count, configuration, data );
}
 
int net_get_conf_req( int net_phone, measured_string_ref * configuration, int count, char ** data ){
int net_get_conf_req( int net_phone, measured_string_ref * configuration, size_t count, char ** data ){
return generic_translate_req( net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, * configuration, count, configuration, data );
}
 
/branches/network/uspace/srv/net/net/net.c
127,7 → 127,7
* @param data The found configuration settings data. Output parameter.
* @returns EOK.
*/
int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, int count, char ** data );
int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, size_t count, char ** data );
 
/** Networking module global data.
*/
160,7 → 160,7
return EOK;
}
 
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, int count, char ** data ){
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data ){
netif_ref netif;
 
if( !( configuration && ( count > 0 ))) return EINVAL;
172,14 → 172,14
}
}
 
int net_get_conf_req( int net_phone, measured_string_ref * configuration, int count, char ** data ){
int net_get_conf_req( int net_phone, measured_string_ref * configuration, size_t count, char ** data ){
if( !( configuration && ( count > 0 ))) return EINVAL;
return net_get_conf( NULL, * configuration, count, data );
}
 
int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, int count, char ** data ){
int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, size_t count, char ** data ){
measured_string_ref setting;
int index;
size_t index;
 
if( data ) * data = NULL;
for( index = 0; index < count; ++ index ){
/branches/network/uspace/srv/net/net/Makefile
53,10 → 53,13
ifeq ($(NETWORKING), module)
 
SOURCES += $(NAME)_bundle.c \
$(NET_BASE)crc.c \
$(NET_BASE)il/arp/arp.c \
$(NET_BASE)il/ip/ip.c \
$(NET_BASE)sockaddr.c
# $(NET_BASE)tl/tcp/tcp.c
$(NET_BASE)il/ip/ip_client.c \
$(NET_BASE)sockaddr.c \
$(NET_BASE)tl/tcp/tcp.c \
$(NET_BASE)tl/udp/udp.c
 
else
 
/branches/network/uspace/srv/net/crc.c
31,7 → 31,7
*/
 
/** @file
* General CRC computation implementation.
* General CRC and checksum computation implementation.
*/
 
#include <sys/types.h>
100,5 → 100,28
return seed;
}
 
uint32_t compute_checksum( uint32_t seed, uint8_t * data, int length ){
int index;
 
// sum all the 16 bit fields
for( index = 0; index < length - 1; index += 2 ){
seed += ( data[ index ] << 8 ) + data[ index + 1 ];
}
 
// last odd byte with zero padding
if( index == length - 1 ){
seed += data[ index ] << 8;
}
 
return seed;
}
 
uint16_t compact_checksum( uint32_t sum ){
// shorten to the 16 bits
while( sum >> 16 ) sum = ( sum & 0xFFFF ) + ( sum >> 16 );
 
return ( uint16_t ) sum;
}
 
/** @}
*/
/branches/network/uspace/srv/net/il/il_messages.h
60,13 → 60,22
* @see ip_send_msg()
*/
NET_IL_SEND,
/** Packet size message.
* @see ip_packet_size_req()
*/
NET_IL_PACKET_SPACE
} il_messages;
 
/** Returns the ip protocol number message parameter.
/** Returns the protocol number message parameter.
* @param call The message call structure. Input parameter.
*/
#define IL_GET_PROTO( call ) ( int ) IPC_GET_ARG1( * call )
 
/** Returns the registering service message parameter.
* @param call The message call structure. Input parameter.
*/
#define IL_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG2( * call )
 
#endif
 
/** @}
/branches/network/uspace/srv/net/il/ip/ip_remote.c
35,21 → 35,18
 
#include <ipc/services.h>
 
#include <ipc/services.h>
 
#include "../../messages.h"
#include "../../modules.h"
 
#include "../../include/device.h"
#include "../../include/ip_interface.h"
#include "../../include/sockaddr.h"
 
#include "../../structures/packet/packet_client.h"
 
#include "../il_messages.h"
 
int ip_bind_service( services_t service, services_t me, async_client_conn_t receiver ){
return bind_service( service, 0, me, 0, receiver );
}
#include "ip_messages.h"
 
int ip_device_req( int ip_phone, device_id_t device_id, services_t service ){
return generic_device_req( ip_phone, NET_IL_DEVICE, device_id, 0, service );
56,7 → 53,7
}
 
int ip_send_msg( int ip_phone, device_id_t device_id, packet_t packet, services_t sender ){
return generic_send_msg( ip_phone, NET_IL_SEND, -1, packet_get_id( packet ), sender );
return generic_send_msg( ip_phone, NET_IL_SEND, device_id, packet_get_id( packet ), sender );
}
 
int ip_connect_module( services_t service ){
63,5 → 60,21
return connect_to_service( SERVICE_IP );
}
 
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 ){
return async_req_4_0( ip_phone, NET_IP_ADD_ROUTE, device_id, ( ipcarg_t ) gateway.s_addr, ( ipcarg_t ) address.s_addr, ( ipcarg_t ) netmask.s_addr );
}
 
int ip_set_gateway_req( int ip_phone, device_id_t device_id, in_addr_t gateway ){
return async_req_2_0( ip_phone, NET_IP_SET_GATEWAY, device_id, ( ipcarg_t ) gateway.s_addr );
}
 
int ip_packet_size_req( int ip_phone, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
return generic_packet_size_req( ip_phone, NET_IL_PACKET_SPACE, device_id, addr_len, prefix, content, suffix );
}
 
int ip_bind_service( services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg ){
return bind_service( service, protocol, me, service, receiver );
}
 
/** @}
*/
/branches/network/uspace/srv/net/il/ip/ip_messages.h
0,0 → 1,71
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup ip
* @{
*/
 
/** @file
* Internet protocol layer module messages.
* @see ip_interface.h
*/
 
#ifndef __NET_IP_MESSAGES_H__
#define __NET_IP_MESSAGES_H__
 
#include <ipc/ipc.h>
 
/** Internet protocol layer module messages.
*/
typedef enum{
/** Adds the routing entry.
* @see ip_add_route()
*/
NET_IP_ADD_ROUTE = NET_IP_FIRST,
/** Sets the default gateway.
* @see ip_set_default_gateway()
*/
NET_IP_SET_GATEWAY
} ip_messages;
 
/** \todo
*/
#define IP_GET_GATEWAY( call ) ({ in_addr_t addr; addr.s_addr = IPC_GET_ARG2( * call ); addr; })
 
/** \todo
*/
#define IP_GET_ADDRESS( call ) ({ in_addr_t addr; addr.s_addr = IPC_GET_ARG3( * call ); addr; })
 
/** \todo
*/
#define IP_GET_NETMASK( call ) ({ in_addr_t addr; addr.s_addr = IPC_GET_ARG4( * call ); addr; })
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/il/ip/ip_header.h
39,7 → 39,7
#define __NET_IP_HEADER_H__
 
#include <byteorder.h>
#include <types.h>
#include <sys/types.h>
 
/** Type definition of the internet header.
* @see ip_header
58,19 → 58,19
#ifdef ARCH_IS_BIG_ENDIAN
/** The Version field indicates the format of the internet header.
*/
uint8_t:4 version;
uint8_t version:4;
/** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
* Note that the minimum value for a~correct header is~5.
*/
uint8_t:4 ihl;
uint8_t ihl:4;
#else
/** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
* Note that the minimum value for a~correct header is~5.
*/
uint8_t:4 ihl;
uint8_t ihl:4;
/** The Version field indicates the format of the internet header.
*/
uint8_t:4 version;
uint8_t version:4;
#endif
/** The Type of Service provides an indication of the abstract parameters of the quality of service desired.
* These parameters are to be used to guide the selection of the actual service parameters when transmitting a~datagram through a~particular network.
84,21 → 84,21
uint16_t total_length;
/** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram.
*/
unit16_t identification;
uint16_t identification;
#ifdef ARCH_IS_BIG_ENDIAN
/** Various control flags.
*/
uint_16:3 flags;
uint16_t flags:3;
/** This field indicates where in the datagram this fragment belongs.
*/
uint_16:13 fragment_offset;
uint16_t fragment_offset:3;
#else
/** This field indicates where in the datagram this fragment belongs.
*/
uint_16:13 fragment_offset;
uint16_t fragment_offset:13;
/** Various control flags.
*/
uint_16:3 flags;
uint16_t flags:3;
#endif
/** This field indicates the maximum time the datagram is allowed to remain in the internet system.
* If this field contains the value zero, then the datagram must be destroyed.
132,7 → 132,7
/** Type definition of the internet option header pointer.
* @see ip_header
*/
typedef ip_option * ip_option_ref;
typedef ip_option_t * ip_option_ref;
 
/** Internet option header.
* Only type field is always valid.
151,49 → 151,20
#ifdef ARCH_IS_BIG_ENDIAN
/** The number of IP modules that cannot register timestamps due to lack of space.
*/
uint8_t:4 overflow;
uint8_t overflow:4;
/** Various internet timestamp control flags.
*/
uint8_t:4 flags;
uint8_t flags:4;
#else
/** Various internet timestamp control flags.
*/
uint8_t:4 flags;
uint8_t flags:4;
/** The number of IP modules that cannot register timestamps due to lack of space.
*/
uint8_t:4 overflow;
uint8_t overflow:4;
#endif
} __attribute__ ((packed));
 
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_PRECEDENCE_SHIFT 5
#define IPTOS_DELAY_SHIFT 4
#define IPTOS_THROUGHPUT_SHIFT 3
#define IPTOS_RELIABILITY_SHIFT 2
#define IPTOS_COST_SHIFT 1
 
#define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT )
#define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT )
 
#define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT )
#define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT )
 
#define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT )
#define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT )
 
#define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT )
#define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT )
 
#define IPTOS_PREC_MASK 0xE0
#define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT )
#define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT )
 
#define IPFLAG_FRAGMENT_SHIFT 1
#define IPFLAG_FRAGMENTED_SHIFT 0
 
203,70 → 174,14
#define IPFLAG_LAST_FRAGMENT ( 0x0 << IPFLAG_FRAGMENTED_SHIFT )
#define IPFLAG_MORE_FRAGMENTS ( 0x1 << IPFLAG_FRAGMENTED_SHIFT )
 
#define IPOPT_COPY_SHIFT 7
#define IPOPT_CLASS_SHIFT 5
#define IPOPT_NUMBER_SHIFT 0
#define IPOPT_CLASS_MASK 0x60
#define IPOPT_NUMBER_MASK 0x1F
 
#define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT )
 
#define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK ))
 
#define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY )
#define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK )
#define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK )
 
#define IPOPT_CONTROL ( 1 << IPOPT_CLASS_SHIFT )
#define IPOPT_RESERVED1 ( 2 << IPOPT_CLASS_SHIFT )
#define IPOPT_MEASUREMENT ( 3 << IPOPT_CLASS_SHIFT )
#define IPOPT_RESERVED2 ( 4 << IPOPT_CLASS_SHIFT )
 
//#define IPOPT_END_OF_LIST 0x0
#define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 )
//#define IPOPT_NO_OPERATION 0x1
#define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 )
//#define IPOPT_SECURITY 0x82
#define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 )
#define IPOPT_SEC_LENGTH 11
#define IPOPT_SEC_UNCLASIFIED 0x0
#define IPOPT_SEC_CONFIDENTIAL 0xF035
#define IPOPT_SEC_EFTO 0x789A
#define IPOPT_SEC_MMMM 0xBC4D
#define IPOPT_SEC_PROG 0x5E26
#define IPOPT_SEC_RESTRICTED 0xAF13
#define IPOPT_SEC_SECRET 0xD788
#define IPOPT_SEC_TOP_SECRET 0x6BC5
//#define IPOPT_LOOSE_SOURCE 0x83
#define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 )
//#define IPOPT_STRICT_SOURCE 0x89
#define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 )
//#define IPOPT_RECORD_ROUTE 0x07
#define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 )
//#define IPOPT_STREAM_IDENTIFIER 0x88
#define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 )
#define IPOPT_SID_LENGTH 4
//#define IPOPT_INTERNET_TIMESTAMP 0x44
#define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 )
#define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 )
 
#define IPVERSION 4
#define MAXTTL 255
#define IPDEFTTL 64
 
/*
#define IPOPT_OPTVAL 0
#define IPOPT_OLEN 1
#define IPOPT_OFFSET 2
#define IPOPT_MINOFF 4
#define MAX_IPOPTLEN 40
#define IPOPT_NOP IPOPT_NOOP
#define IPOPT_EOL IPOPT_END
#define IPOPT_TS IPOPT_TIMESTAMP
*/
 
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
 
#endif
 
/** @}
/branches/network/uspace/srv/net/il/ip/ip_client.c
0,0 → 1,71
/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup ip
* @{
*/
 
/**
* @file
*/
 
#include <errno.h>
 
#include <sys/types.h>
 
#include "../../include/ip_client.h"
 
#include "../../structures/packet/packet.h"
#include "../../structures/packet/packet_client.h"
 
#include "ip_header.h"
 
int ip_client_prepare_packet( packet_t packet, int protocol, int ttl, int tos, int dont_fragment, int ipopt_length ){
ip_header_ref header;
uint8_t * data;
int padding;
 
padding = ipopt_length % 4;
if( padding ){
padding = 4 - padding;
ipopt_length += padding;
}
data = ( uint8_t * ) packet_prefix( packet, sizeof( ip_header_t ) + padding );
if( ! data ) return ENOMEM;
while( padding -- ) data[ sizeof( ip_header_t ) + padding ] = IPOPT_NOOP;
header = ( ip_header_ref ) data;
header->ihl = ( sizeof( ip_header_t ) + ipopt_length ) / 4;
header->ttl = ( ttl > 0 ) ? (( ttl <= MAXTTL ) ? ttl : MAXTTL ) : IPDEFTTL;
header->tos = tos;
header->protocol = protocol;
if( dont_fragment ) header->flags = IPFLAG_DONT_FRAGMENT;
return EOK;
}
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/il/ip/ip.c
41,6 → 41,8
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include <sys/types.h>
 
#include "../../err.h"
#include "../../messages.h"
#include "../../modules.h"
48,11 → 50,15
#include "../../include/net_interface.h"
#include "../../include/sockaddr.h"
#include "../../include/socket.h"
#include "../../include/byteorder.h"
#include "../../include/crc.h"
#include "../../include/device.h"
#include "../../include/arp_interface.h"
#include "../../include/nil_interface.h"
#include "../../include/il_interface.h"
#include "../../include/ip_client.h"
#include "../../include/ip_interface.h"
#include "../../include/tl_interface.h"
#include "../../structures/measured_strings.h"
#include "../../structures/module_map.h"
#include "../../structures/packet/packet_client.h"
62,13 → 68,28
#include "../il_messages.h"
 
#include "ip.h"
#include "ip_header.h"
#include "ip_messages.h"
#include "ip_module.h"
 
#define DEFAULT_IPV 4
#define IP_MIN_CONTENT 576
 
#define ARP_NAME "arp"
#define ARP_FILENAME "/srv/arp"
 
#define IP_ADDR sizeof( in_addr_t )
#define IP_PREFIX sizeof( ip_header_t )
#define IP_SUFFIX 0
#define IP_MAX_CONTENT 65535
#define IP_HEADER_LENGTH( header ) (( header )->ihl * 4 )
#define IP_TOTAL_LENGTH( header ) ntohs(( header )->total_length )
#define IP_HEADER_DATA_LENGTH( header ) ( IP_TOTAL_LENGTH( header ) - IP_HEADER_LENGTH( header ))
#define IP_HEADER_CHECKSUM( header ) ( htons( ip_checksum(( uint8_t * )( header ), IP_HEADER_LENGTH( header ))))
 
//zero is returned as 0xFFFF (not flipped)
#define IP_HEADER_CHECKSUM_ZERO 0xFFFF
 
ip_globals_t ip_globals;
 
DEVICE_MAP_IMPLEMENT( ip_netifs, ip_netif_t )
75,14 → 96,60
 
INT_MAP_IMPLEMENT( ip_protos, ip_proto_t )
 
GENERIC_FIELD_IMPLEMENT( ip_routes, ip_route_t )
 
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state );
int ip_register( int il_phone, int protocol, int phone );
int ip_register( int protocol, services_t service, int phone, tl_received_msg_t tl_received_msg );
int ip_netif_initialize( ip_netif_ref ip_netif );
 
int ip_send_route( packet_t packet, ip_netif_ref netif, ip_route_ref route, in_addr_t * src, in_addr_t dest );
int ip_prepare_packet( in_addr_t * source, packet_t packet, measured_string_ref destination );
 
packet_t ip_split_packet( packet_t packet, size_t prefix, size_t content, size_t suffix, size_t addr_len );
int ip_fragment_packet( packet_t packet, size_t length, size_t prefix, size_t suffix, size_t addr_len );
int ip_fragment_packet_data( packet_t packet, packet_t new_packet, ip_header_ref header, ip_header_ref new_header, size_t length, void * src, void * dest, size_t address_length );
ip_header_ref ip_create_middle_header( packet_t packet, ip_header_ref last );
ip_header_ref ip_create_last_header( packet_t packet, ip_header_ref first );
 
in_addr_t * ip_netif_addr( ip_netif_ref netif );
ip_route_ref ip_find_route( in_addr_t destination );
ip_route_ref ip_netif_find_route( ip_netif_ref netif, in_addr_t destination );
 
int ip_received_msg( device_id_t device_id, packet_t packet );
int ip_process_packet( device_id_t device_id, packet_t packet );
in_addr_t ip_get_destination( ip_header_ref header );
int ip_deliver_local( device_id_t device_id, packet_t packet, ip_header_ref header );
 
/** Computes the ip header checksum.
* To compute the checksum of a new packet, the checksum header field must be zero.
* To check the checksum of a received packet, the checksum may be left set.
* The zero (0) value will returned in this case if valid.
* @param data The header data. Input parameter.
* @param length The header length in bytes. Input parameter.
* @returns The internet protocol header checksum.
* @returns IP_HEADER_CHECKSUM_ZERO if the computed checksum is zero.
*/
uint16_t ip_checksum( uint8_t * data, int length );
 
uint16_t ip_checksum( uint8_t * data, int length ){
uint16_t checksum;
 
checksum = compact_checksum(compute_checksum( 0, data, length ));
 
// flip, zero is returned as 0xFFFF (not flipped)
return ( ~ checksum ) ? ~ checksum : IP_HEADER_CHECKSUM_ZERO;
}
 
/** Initializes the module.
*/
int ip_initialize( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ip_globals.packet_counter = 0;
ip_globals.gateway.address.s_addr = 0;
ip_globals.gateway.netmask.s_addr = 0;
ip_globals.gateway.gateway.s_addr = 0;
ip_globals.gateway.netif = NULL;
ERROR_PROPAGATE( ip_netifs_initialize( & ip_globals.netifs ));
ERROR_PROPAGATE( ip_protos_initialize( & ip_globals.protos ));
ip_globals.client_connection = client_connection;
94,17 → 161,67
int ip_device_req( int il_phone, device_id_t device_id, services_t netif ){
ERROR_DECLARE;
 
ip_netif_ref ip_netif;
ip_netif_ref ip_netif;
ip_route_ref route;
int index;
char * data;
 
ip_netif = ( ip_netif_ref ) malloc( sizeof( ip_netif_t ));
if( ! ip_netif ) return ENOMEM;
if( ERROR_OCCURRED( ip_routes_initialize( & ip_netif->routes ))){
free( ip_netif );
return ERROR_CODE;
}
ip_netif->device_id = device_id;
ip_netif->service = netif;
ip_netif->state = NETIF_STOPPED;
if( ERROR_OCCURRED( ip_netif_initialize( ip_netif ))){
ip_routes_destroy( & ip_netif->routes );
free( ip_netif );
return ERROR_CODE;
}
if( ip_netif->arp ) ++ ip_netif->arp->usage;
// print the settings
printf( "New device registered:\n\tid\t= %d\n\tphone\t= %d\n\tIPV\t= %d\n", ip_netif->device_id, ip_netif->phone, ip_netif->ipv );
printf( "\tconfiguration\t= %s\n", ip_netif->dhcp ? "dhcp" : "static" );
// TODO ipv6 addresses
data = ( char * ) malloc( INET_ADDRSTRLEN );
if( data ){
for( index = 0; index < ip_routes_count( & ip_netif->routes ); ++ index ){
route = ip_routes_get_index( & ip_netif->routes, index );
if( route ){
printf( "\tRouting %d:\n", index );
inet_ntop( AF_INET, ( uint8_t * ) & route->address.s_addr, data, INET_ADDRSTRLEN );
printf( "\t\taddress\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & route->netmask.s_addr, data, INET_ADDRSTRLEN );
printf( "\t\tnetmask\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & route->gateway.s_addr, data, INET_ADDRSTRLEN );
printf( "\t\tgateway\t= %s\n", data );
}
}
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->broadcast.s_addr, data, INET_ADDRSTRLEN );
printf( "\tbroadcast\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns1, data, INET_ADDRSTRLEN );
printf( "\tdns1\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns2, data, INET_ADDRSTRLEN );
printf( "\tdns2\t= %s\n", data );
free( data );
}
return EOK;
}
 
int ip_netif_initialize( ip_netif_ref ip_netif ){
ERROR_DECLARE;
 
measured_string_t names[ 9 ] = {{ "IPV", 3 }, { "IP_CONFIG", 9 }, { "IP_ADDR", 7 }, { "NETMASK", 7 }, { "GATEWAY", 7 }, { "BROADCAST", 9 }, { "DNS1", 4 }, { "DNS2", 4 }, { "ARP", 3 }};
measured_string_ref configuration;
int count = 9;
size_t count = sizeof( names ) / sizeof( measured_string_t );
char * data;
int index;
ip_route_ref route;
in_addr_t gateway;
 
configuration = & names[ 0 ];
ip_netif = ( ip_netif_ref ) malloc( sizeof( ip_netif_t ));
if( ! ip_netif ) return ENOMEM;
ip_netif->device_id = device_id;
// get configuration
ERROR_PROPAGATE( net_get_device_conf_req( ip_globals.net_phone, ip_netif->device_id, & configuration, count, & data ));
if( configuration ){
117,23 → 234,35
if( ip_netif->dhcp ){
// TODO dhcp
net_free_settings( configuration, data );
free( ip_netif );
return ENOTSUP;
}else if( ip_netif->ipv == 4 ){
if( ERROR_OCCURRED( inet_pton( AF_INET, configuration[ 2 ].value, ( uint8_t * ) & ip_netif->address ))
|| ERROR_OCCURRED( inet_pton( AF_INET, configuration[ 3 ].value, ( uint8_t * ) & ip_netif->netmask ))
|| ( inet_pton( AF_INET, configuration[ 4 ].value, ( uint8_t * ) & ip_netif->gateway ) == EINVAL )
|| ( inet_pton( AF_INET, configuration[ 5 ].value, ( uint8_t * ) & ip_netif->broadcast ) == EINVAL )
route = ( ip_route_ref ) malloc( sizeof( ip_route_t ));
if( ! route ){
net_free_settings( configuration, data );
return ENOMEM;
}
route->address.s_addr = 0;
route->netmask.s_addr = 0;
route->gateway.s_addr = 0;
route->netif = ip_netif;
index = ip_routes_add( & ip_netif->routes, route );
if( index < 0 ){
net_free_settings( configuration, data );
free( route );
return index;
}
if( ERROR_OCCURRED( inet_pton( AF_INET, configuration[ 2 ].value, ( uint8_t * ) & route->address.s_addr ))
|| ERROR_OCCURRED( inet_pton( AF_INET, configuration[ 3 ].value, ( uint8_t * ) & route->netmask.s_addr ))
|| ( inet_pton( AF_INET, configuration[ 4 ].value, ( uint8_t * ) & gateway.s_addr ) == EINVAL )
|| ( inet_pton( AF_INET, configuration[ 5 ].value, ( uint8_t * ) & ip_netif->broadcast.s_addr ) == EINVAL )
|| ( inet_pton( AF_INET, configuration[ 6 ].value, ( uint8_t * ) & ip_netif->dns1 ) == EINVAL )
|| ( inet_pton( AF_INET, configuration[ 7 ].value, ( uint8_t * ) & ip_netif->dns2 ) == EINVAL )){
net_free_settings( configuration, data );
free( ip_netif );
return EINVAL;
}
}else{
// TODO ipv6
// TODO ipv6 in separate module
net_free_settings( configuration, data );
free( ip_netif );
return ENOTSUP;
}
if( configuration[ 8 ].value ){
141,7 → 270,6
if( ! ip_netif->arp ){
printf( "Failed to start the arp %s\n", configuration[ 8 ].value );
net_free_settings( configuration, data );
free( ip_netif );
return EINVAL;
}
}else{
149,66 → 277,64
}
net_free_settings( configuration, data );
}
ip_netif->phone = bind_service( netif, ip_netif->device_id, SERVICE_IP, 0, ip_globals.client_connection );
ip_netif->phone = bind_service( ip_netif->service, ip_netif->device_id, SERVICE_IP, 0, ip_globals.client_connection );
if( ip_netif->phone < 0 ){
printf( "Failed to contact the nil service %d\n", netif );
free( ip_netif );
printf( "Failed to contact the nil service %d\n", ip_netif->service );
return ip_netif->phone;
}
// MUST BE AFTER the bind_service up there!
if( ip_netif->arp ){
configuration[ 0 ].value = ( char * ) & ip_netif->address;
configuration[ 0 ].value = ( char * ) & route->address.s_addr;
configuration[ 0 ].length = CONVERT_SIZE( in_addr_t, char, 1 );
if( ERROR_OCCURRED( arp_device_req( ip_netif->arp->phone, ip_netif->device_id, SERVICE_IP, netif, & configuration[ 0 ] ))){
free( ip_netif );
return ERROR_CODE;
}
ERROR_PROPAGATE( arp_device_req( ip_netif->arp->phone, ip_netif->device_id, SERVICE_IP, ip_netif->service, & configuration[ 0 ] ));
}
// get packet dimensions
ERROR_PROPAGATE( nil_packet_size_req( ip_netif->phone, ip_netif->device_id, & ip_netif->addr_len, & ip_netif->prefix, & ip_netif->content, & ip_netif->suffix ));
if( ip_netif->content < IP_MIN_CONTENT ){
printf( "Maximum transmission unit %d bytes is too small, at least %d bytes are needed\n", ip_netif->content, IP_MIN_CONTENT );
ip_netif->content = IP_MIN_CONTENT;
}
index = ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif );
if( index < 0 ){
free( ip_netif );
return index;
if( index < 0 ) return index;
if( gateway.s_addr ){
// the default gateway
ip_globals.gateway.address.s_addr = 0;
ip_globals.gateway.netmask.s_addr = 0;
ip_globals.gateway.gateway.s_addr = gateway.s_addr;
ip_globals.gateway.netif = ip_netif;
}
if( ip_netif->arp ) ++ ip_netif->arp->usage;
// print the settings
printf( "New device registered:\n\tid\t= %d\n\tphone\t= %d\n\tIPV\t= %d\n", ip_netif->device_id, ip_netif->phone, ip_netif->ipv );
printf( "\tconfiguration\t= %s\n", ip_netif->dhcp ? "dhcp" : "static" );
// TODO ipv6 addresses
data = malloc( INET_ADDRSTRLEN );
if( data ){
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->address, data, INET_ADDRSTRLEN );
printf( "\taddress\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->netmask, data, INET_ADDRSTRLEN );
printf( "\tnetmask\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->gateway, data, INET_ADDRSTRLEN );
printf( "\tgateway\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->broadcast, data, INET_ADDRSTRLEN );
printf( "\tbroadcast\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns1, data, INET_ADDRSTRLEN );
printf( "\tdns1\t= %s\n", data );
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns2, data, INET_ADDRSTRLEN );
printf( "\tdns2\t= %s\n", data );
free( data );
}
return EOK;
}
 
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){
// ERROR_DECLARE;
ERROR_DECLARE;
 
/* measured_string_t address;
measured_string_ref translation;
char * data;
*/
packet_t packet;
in_addr_t destination;
 
ip_netif_ref netif;
 
/* measured_string_t address;
measured_string_ref translation;
char * data;
*/
netif = ip_netifs_find( & ip_globals.netifs, device_id );
if( ! netif ) return ENOENT;
netif->state = state;
// TODO state
printf( "ip - device %d changed state to %d\n\n", device_id, state );
/* if( netif->arp ){
address.value = ( char * ) & netif->gateway;
address.length = CONVERT_SIZE( in_addr_t, char, 1 );
if( netif->arp ){
/* address.value = ( char * ) & ip_globals.gateway.gateway.s_addr;
address.length = CONVERT_SIZE( ip_globals.gateway.gateway.s_addr, char, 1 );
if( ERROR_OCCURRED( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data ))){
ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data ));
}
printf( "\tgateway translated to\t= %X:%X:%X:%X:%X:%X\n", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
free( translation );
free( data );
address.value = ( char * ) & ip_globals.gateway.gateway.s_addr;
address.length = CONVERT_SIZE( ip_globals.gateway.gateway.s_addr, char, 1 );
if( ERROR_OCCURRED( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data ))){
sleep( 2 );
ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data ));
}
215,12 → 341,29
printf( "\tgateway translated to\t= %X:%X:%X:%X:%X:%X\n", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
free( translation );
free( data );
*/ printf( "IP - testing to send packet:\n" );
ERROR_PROPAGATE( inet_pton( AF_INET, "90.182.101.18", ( uint8_t * ) & destination.s_addr ));
packet = packet_get_4( ip_globals.net_phone, 30, netif->addr_len, netif->prefix + sizeof( ip_header_t ), netif->suffix );
if( ! packet ) return ENOMEM;
pq_release( ip_globals.net_phone, packet_get_id( packet ));
packet = packet_get_4( ip_globals.net_phone, 30, netif->addr_len, netif->prefix + sizeof( ip_header_t ), netif->suffix );
if( ! packet ) return ENOMEM;
pq_release( ip_globals.net_phone, packet_get_id( packet ));
packet = packet_get_4( ip_globals.net_phone, 30, netif->addr_len, netif->prefix + sizeof( ip_header_t ), netif->suffix );
if( ! packet ) return ENOMEM;
pq_release( ip_globals.net_phone, packet_get_id( packet ));
packet = packet_get_4( ip_globals.net_phone, 1500, netif->addr_len, netif->prefix + sizeof( ip_header_t ), netif->suffix );
if( ! packet ) return ENOMEM;
// try this long version
// if( ERROR_OCCURRED( packet_copy_data( packet, "Hi, this is IP, wery long version 1, wery long version 2, wery long version 3, wery long version 4, wery long version 5, wery long version 6, wery long version 7, wery long version 8, wery long version 9, wery long version 10, wery long version 11, wery long version 12, wery long version 13, wery long version 14, wery long version 15, wery long version 16, wery long version 17, wery long version 18, wery long version 19, wery long version 20, wery long version 21, wery long version 22, wery long version 23, wery long version 24, wery long version 25, wery long version 26, wery long version 27, wery long version 28, wery long version 29, wery long version 30Hi, this is IP, wery long version 1, wery long version 2, wery long version 3, wery long version 4, wery long version 5, wery long version 6, wery long version 7, wery long version 8, wery long version 9, wery long version 10, wery long version 11, wery long version 12, wery long version 13, wery long version 14, wery long version 15, wery long version 16, wery long version 17, wery long version 18, wery long version 19, wery long version 20, wery long version 21, wery long version 22, wery long version 23, wery long version 24, wery long version 25, wery long version 26, wery long version 27, wery long version 28, wery long version 29, wery long version 30", 1330 ))
if( ERROR_OCCURRED( packet_copy_data( packet, "Hi, this is IP", 14 ))
|| ERROR_OCCURRED( packet_set_addr( packet, NULL, ( uint8_t * ) & destination.s_addr, 4 ))
|| ERROR_OCCURRED( ip_client_prepare_packet( packet, 0, 0, 0, 0, 0 ))){
pq_release( ip_globals.net_phone, packet_get_id( packet ));
}
ERROR_CODE = ip_send_msg( 0, 0, packet, SERVICE_IP );
printf( "send returned %d\n", ERROR_CODE );
}
*/ return EOK;
}
 
int ip_bind_service( services_t service, services_t me, async_client_conn_t receiver ){
//TODO receive function
return EOK;
}
 
228,14 → 371,21
return EOK;
}
 
int ip_register( int il_phone, int protocol, int phone ){
int ip_bind_service( services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg ){
return ip_register( protocol, me, 0, tl_received_msg );
}
 
int ip_register( int protocol, services_t service, int phone, tl_received_msg_t tl_received_msg ){
ip_proto_ref proto;
int index;
 
if( !( protocol && service && (( phone > 0 ) || ( tl_received_msg )))) return EINVAL;
proto = ( ip_proto_ref ) malloc( sizeof( ip_protos_t ));
if( ! proto ) return ENOMEM;
proto->protocol = protocol;
proto->service = service;
proto->phone = phone;
proto->tl_received_msg = tl_received_msg;
index = ip_protos_add( & ip_globals.protos, proto->protocol, proto );
if( index < 0 ){
free( proto );
245,13 → 395,147
return EOK;
}
 
int ip_send_msg( int il_phone, device_id_t device_id, packet_t packet, services_t target ){
// TODO send packet
printf( "Packet to send via %d: %s\n", device_id, packet_get_data( packet ));
pq_release( ip_globals.net_phone, packet_get_id( packet ));
int ip_send_msg( int il_phone, device_id_t device_id, packet_t packet, services_t sender ){
ERROR_DECLARE;
 
int length;
ip_netif_ref netif;
ip_route_ref route;
in_addr_t dest;
in_addr_t * src;
 
// addresses in the host byte order
// should be the next hop address or the target destination address
length = packet_get_addr( packet, NULL, ( void * )( & dest.s_addr ));
if( length < 0 ){
pq_release( ip_globals.net_phone, packet_get_id( packet ));
return length;
}
// TODO IPv6
if( length != IP_ADDR ){
pq_release( ip_globals.net_phone, packet_get_id( packet ));
return EINVAL;
}
// rwlock_read_lock( & ip_globals.devices_lock );
// device specified?
// dest.s_addr = ntohl( dest.s_addr );
if( device_id ){
netif = ip_netifs_find( & ip_globals.netifs, device_id );
route = ip_netif_find_route( netif, dest );
}else{
// TODO IPv6
route = ip_find_route( dest );
netif = route ? route->netif : NULL;
}
if( !( netif && route )){
// rwlock_read_unlock( & ip_globals.devices_lock );
pq_release( ip_globals.net_phone, packet_get_id( packet ));
return ENOENT;
}
// to me?
if( route->address.s_addr == dest.s_addr ){
// TODO loopback deliver
}
 
src = ip_netif_addr( netif );
if( ! src ){
pq_release( ip_globals.net_phone, packet_get_id( packet ));
return ENOENT;
}
if( ERROR_OCCURRED( ip_send_route( packet, netif, route, src, dest ))){
pq_release( ip_globals.net_phone, packet_get_id( packet ));
}
return ERROR_CODE;
}
 
in_addr_t * ip_netif_addr( ip_netif_ref netif ){
ip_route_ref route;
 
route = ip_routes_get_index( & netif->routes, 0 );
return route ? & route->address : NULL;
}
 
int ip_send_route( packet_t packet, ip_netif_ref netif, ip_route_ref route, in_addr_t * src, in_addr_t dest ){
ERROR_DECLARE;
 
packet_t next;
packet_t tmp;
measured_string_t destination;
measured_string_ref translation;
char * data;
 
if( route->gateway.s_addr ){
dest.s_addr = route->gateway.s_addr;
}
// get destination hardware address
if( netif->arp ){
destination.value = ( char * ) & dest.s_addr;
destination.length = CONVERT_SIZE( dest.s_addr, char, 1 );
if( ERROR_OCCURRED( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & destination, & translation, & data ))){
usleep( 200000 );
ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & destination, & translation, & data ));
}
// TODO unreachable
if( ! translation ) return EINVAL;
if( ! translation->value ){
// TODO unreachable
free( translation );
free( data );
return EINVAL;
}
}else translation = NULL;
// process packet queue
next = packet;
do{
if( ERROR_OCCURRED( ip_prepare_packet( src, next, translation ))){
// release invalid packet
tmp = pq_detach( next );
if( next == packet ) packet = tmp;
pq_release( ip_globals.net_phone, packet_get_id( next ));
next = tmp;
}else{
next = pq_next( next );
}
}while( next );
if( translation ){
free( translation );
free( data );
}
// send packet queue
if( packet ){
packet = ip_split_packet( packet, netif->prefix, netif->content, netif->suffix, netif->addr_len );
if( packet ){
nil_send_msg( netif->phone, netif->device_id, packet, SERVICE_IP );
}
}
// rwlock_read_unlock( & ip_globals.netifs_lock );
return EOK;
}
 
int ip_prepare_packet( in_addr_t * source, packet_t packet, measured_string_ref destination ){
ERROR_DECLARE;
 
int length;
ip_header_ref header;
 
length = packet_get_data_length( packet );
if(( length < sizeof( ip_header_t )) || ( length > IP_MAX_CONTENT )) return EINVAL;
header = ( ip_header_ref ) packet_get_data( packet );
if( destination ){
ERROR_PROPAGATE( packet_set_addr( packet, NULL, ( uint8_t * ) destination->value, CONVERT_SIZE( char, uint8_t, destination->length )));
}
header->version = 4;
header->total_length = htons( length );
header->fragment_offset = 0;
if( source ) header->source_address = source->s_addr;//htonl( source.s_addr );
++ ip_globals.packet_counter;
header->identification = htons( ip_globals.packet_counter );
header->header_checksum = 0;
// unnecessary for all protocols
header->header_checksum = IP_HEADER_CHECKSUM( header );
return EOK;
}
 
int ip_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
ERROR_DECLARE;
 
264,7 → 548,7
case NET_IL_DEVICE:
return ip_device_req( 0, IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ));
case IPC_M_CONNECT_TO_ME:
return ip_register( 0, IL_GET_PROTO( call ), IPC_GET_PHONE( call ));
return ip_register( IL_GET_PROTO( call ), IL_GET_SERVICE( call ), IPC_GET_PHONE( call ), NULL );
case NET_IL_SEND:
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return ip_send_msg( 0, IPC_GET_DEVICE( call ), packet, 0 );
271,14 → 555,327
case NET_IL_DEVICE_STATE:
case NET_NIL_DEVICE_STATE:
return ip_device_state_msg( 0, IPC_GET_DEVICE( call ), IPC_GET_STATE( call ));
// TODO packet received
case NET_IL_RECEIVED:
case NET_NIL_RECEIVED:
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call )));
//return il_receive_msg( 0, IPC_GET_DEVICE( call ), packet );
return ip_received_msg( IPC_GET_DEVICE( call ), packet );
case NET_IP_ADD_ROUTE:
return ip_add_route_req( 0, IPC_GET_DEVICE( call ), IP_GET_ADDRESS( call ), IP_GET_NETMASK( call ), IP_GET_GATEWAY( call ));
case NET_IP_SET_GATEWAY:
return ip_set_gateway_req( 0, IPC_GET_DEVICE( call ), IP_GET_GATEWAY( call ));
case NET_IL_PACKET_SPACE:
ERROR_PROPAGATE( ip_packet_size_req( 0, IPC_GET_DEVICE( call ), IPC_SET_ADDR( answer ), IPC_SET_PREFIX( answer ), IPC_SET_CONTENT( answer ), IPC_SET_SUFFIX( answer )));
* answer_count = 3;
return EOK;
}
return ENOTSUP;
}
 
int ip_packet_size_req( int ip_phone, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
ip_netif_ref netif;
 
if( !( addr_len && prefix && content && suffix )) return EBADMEM;
// rwlock_read_lock( & ip_globals.netifs_lock );
netif = ip_netifs_find( & ip_globals.netifs, device_id );
if( ! netif ){
// rwlock_read_unlock( & ip_globals.netifs_lock );
return ENOENT;
}
* content = IP_MAX_CONTENT - IP_PREFIX;
* addr_len = ( netif->addr_len > IP_ADDR ) ? netif->addr_len : IP_ADDR;
* prefix = netif->prefix + IP_PREFIX;
* suffix = netif->suffix + IP_SUFFIX;
// rwlock_read_unlock( & ip_globals.netifs_lock );
return EOK;
}
 
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 ){
ip_route_ref route;
ip_netif_ref netif;
int index;
 
netif = ip_netifs_find( & ip_globals.netifs, device_id );
if( ! netif ) return ENOENT;
route = ( ip_route_ref ) malloc( sizeof( ip_route_t ));
if( ! route ) return ENOMEM;
route->address.s_addr = address.s_addr;
route->netmask.s_addr = netmask.s_addr;
route->gateway.s_addr = gateway.s_addr;
route->netif = netif;
index = ip_routes_add( & netif->routes, route );
if( index < 0 ) free( route );
return index;
}
 
ip_route_ref ip_find_route( in_addr_t destination ){
int index;
ip_route_ref route;
ip_netif_ref netif;
 
// start with the last netif - the newest one
index = ip_netifs_count( & ip_globals.netifs ) - 1;
while( index >= 0 ){
netif = ip_netifs_get_index( & ip_globals.netifs, index );
if( netif && ( netif->state == NETIF_ACTIVE )){
route = ip_netif_find_route( netif, destination );
if( route ) return route;
}
-- index;
}
return & ip_globals.gateway;
}
 
ip_route_ref ip_netif_find_route( ip_netif_ref netif, in_addr_t destination ){
int index;
ip_route_ref route;
 
if( netif ){
// start with the first one - the direct route
for( index = 0; index < ip_routes_count( & netif->routes ); ++ index ){
route = ip_routes_get_index( & netif->routes, index );
if( route && (( route->address.s_addr & route->netmask.s_addr ) == ( destination.s_addr & route->netmask.s_addr ))){
return route;
}
}
}
return NULL;
}
 
int ip_set_gateway_req( int ip_phone, device_id_t device_id, in_addr_t gateway ){
ip_netif_ref netif;
 
netif = ip_netifs_find( & ip_globals.netifs, device_id );
if( ! netif ) return ENOENT;
ip_globals.gateway.address.s_addr = 0;
ip_globals.gateway.netmask.s_addr = 0;
ip_globals.gateway.gateway.s_addr = gateway.s_addr;
ip_globals.gateway.netif = netif;
return EOK;
}
 
packet_t ip_split_packet( packet_t packet, size_t prefix, size_t content, size_t suffix, size_t addr_len ){
size_t length;
packet_t next;
packet_t new_packet;
 
next = packet;
// check all packets
while( next ){
length = packet_get_data_length( next );
// too long?
if( length > content ){
if( ip_fragment_packet( next, content, prefix, suffix, addr_len ) != EOK ){
new_packet = pq_detach( next );
if( next == packet ){
packet = new_packet;
}
pq_release( ip_globals.net_phone, packet_get_id( next ));
next = new_packet;
continue;
}
}
next = pq_next( next );
}
return packet;
}
 
int ip_fragment_packet( packet_t packet, size_t length, size_t prefix, size_t suffix, size_t addr_len ){
ERROR_DECLARE;
 
packet_t new_packet;
ip_header_ref header;
ip_header_ref middle_header;
ip_header_ref last_header;
uint8_t * src;
uint8_t * dest;
int address_length;
 
address_length = packet_get_addr( packet, & src, & dest );
if( address_length <= 0 ) return EINVAL;
if( packet_get_data_length( packet ) <= sizeof( ip_header_t )) return ENOMEM;
// get header
header = ( ip_header_ref ) packet_get_data( packet );
if( ! header ) return EINVAL;
// fragmentation forbidden?
if( header->flags & IPFLAG_DONT_FRAGMENT ){
// TODO fragmentation necessary ICMP
return EPERM;
}
// create the last fragment
new_packet = packet_get_4( ip_globals.net_phone, prefix, length, suffix, (( address_length > addr_len ) ? address_length : addr_len ));
if( ! new_packet ) return ENOMEM;
last_header = ip_create_last_header( new_packet, header );
if( ! last_header ){
pq_release( ip_globals.net_phone, packet_get_id( new_packet ));
return ENOMEM;
}
// biggest multiple of 8 lower than content
// TODO even fragmentation?
length = length & ( ~ 0x7 );// ( content / 8 ) * 8
if( ERROR_OCCURRED( ip_fragment_packet_data( packet, new_packet, header, last_header, (( IP_TOTAL_LENGTH( header ) - length ) % ( length - IP_HEADER_LENGTH( last_header ))), src, dest, address_length ))){
pq_release( ip_globals.net_phone, packet_get_id( new_packet ));
return ERROR_CODE;
}
// mark the first as fragmented
header->flags |= IPFLAG_MORE_FRAGMENTS;
// create middle framgents
while( IP_TOTAL_LENGTH( header ) > length ){
new_packet = packet_get_4( ip_globals.net_phone, prefix, length, suffix, (( address_length >= addr_len ) ? address_length : addr_len ));
if( ! new_packet ) return ENOMEM;
middle_header = ip_create_middle_header( new_packet, last_header );
if( ! middle_header ){
pq_release( ip_globals.net_phone, packet_get_id( new_packet ));
return ENOMEM;
}
if( ERROR_OCCURRED( ip_fragment_packet_data( packet, new_packet, header, middle_header, length - IP_HEADER_LENGTH( middle_header ), src, dest, address_length ))){
pq_release( ip_globals.net_phone, packet_get_id( new_packet ));
return ERROR_CODE;
}
}
// finish the first fragment
header->header_checksum = IP_HEADER_CHECKSUM( header );
printf( "ok\n" );
return EOK;
}
 
int ip_fragment_packet_data( packet_t packet, packet_t new_packet, ip_header_ref header, ip_header_ref new_header, size_t length, void * src, void * dest, size_t address_length ){
ERROR_DECLARE;
 
void * data;
 
data = packet_suffix( new_packet, length );
if( ! data ) return ENOMEM;
memcpy( data, (( void * ) header ) + IP_TOTAL_LENGTH( header ) - length, length );
ERROR_PROPAGATE( packet_trim( packet, 0, length ));
header->total_length = htons( IP_TOTAL_LENGTH( header ) - length );
new_header->total_length = htons( IP_HEADER_LENGTH( new_header ) + length );
new_header->fragment_offset = header->fragment_offset + IP_HEADER_DATA_LENGTH( header ) / 8;
new_header->header_checksum = IP_HEADER_CHECKSUM( new_header );
ERROR_PROPAGATE( packet_set_addr( new_packet, src, dest, address_length ));
return pq_insert_after( packet, new_packet );
}
 
ip_header_ref ip_create_middle_header( packet_t packet, ip_header_ref last ){
ip_header_ref middle;
 
middle = ( ip_header_ref ) packet_suffix( packet, IP_HEADER_LENGTH( last ));
if( ! middle ) return NULL;
memcpy( middle, last, IP_HEADER_LENGTH( last ));
middle->flags |= IPFLAG_MORE_FRAGMENTS;
return middle;
}
 
ip_header_ref ip_create_last_header( packet_t packet, ip_header_ref first ){
ip_header_ref last;
ip_option_ref option;
size_t next;
size_t length;
 
// allocate as much as originally
last = ( ip_header_ref ) packet_suffix( packet, IP_HEADER_LENGTH( first ));
if( ! last ) return NULL;
// copy first itself
memcpy( last, first, sizeof( ip_header_t ));
length = sizeof( ip_header_t );
next = sizeof( ip_header_t );
// process all ip options
while( next < first->ihl ){
option = ( ip_option_ref ) ((( void * ) first ) + next );
// skip end or noop
if(( option->type == IPOPT_END ) || ( option->type == IPOPT_NOOP )){
++ next;
}else{
// copy if said so or skip
if( IPOPT_COPIED( option->type )){
memcpy((( void * ) last ) + length, (( void * ) first ) + next, option->length );
length += option->length;
}
// next option
next += option->length;
}
}
// align 4 byte boundary
if( length % 4 ){
bzero((( void * ) last ) + length, 4 - ( length % 4 ));
last->ihl = length / 4 + 1;
}else{
last->ihl = length / 4;
}
// trim the unused space
if( packet_trim( packet, 0, IP_HEADER_LENGTH( first ) - IP_HEADER_LENGTH( last )) != EOK ) return NULL;
return last;
}
 
int ip_received_msg( device_id_t device_id, packet_t packet ){
packet_t next;
 
do{
next = pq_detach( packet );
if( ip_process_packet( device_id, packet ) != EOK ){
pq_release( ip_globals.net_phone, packet_get_id( packet ));
}
packet = next;
}while( packet );
return EOK;
}
 
int ip_process_packet( device_id_t device_id, packet_t packet ){
ERROR_DECLARE;
 
ip_header_ref header;
in_addr_t dest;
ip_route_ref route;
 
header = ( ip_header_ref ) packet_get_data( packet );
if( ! header ) return ENOMEM;
// checksum
if(( header->header_checksum ) && ( IP_HEADER_CHECKSUM( header ))){
// TODO checksum error ICMP?
return EINVAL;
}
// TODO ttl oxceeded ICMP?
if( !( -- header->ttl )) return EINVAL;
// process ipopt and get destination
dest = ip_get_destination( header );
ERROR_PROPAGATE( packet_set_addr( packet, NULL, ( uint8_t * ) & dest.s_addr, IP_ADDR ));
route = ip_find_route( dest );
// TODO unreachable ICMP?
if( ! route ) return ENOENT;
if( route->address.s_addr == dest.s_addr ){
// local delivery
return ip_deliver_local( device_id, packet, header );
}else{
return ip_send_route( packet, route->netif, route, NULL, dest );
}
}
 
int ip_deliver_local( device_id_t device_id, packet_t packet, ip_header_ref header ){
ERROR_DECLARE;
 
ip_proto_ref proto;
 
if(( header->flags & IPFLAG_MORE_FRAGMENTS ) || header->fragment_offset ){
// TODO fragmented
return ENOTSUP;
}else{
proto = ip_protos_find( & ip_globals.protos, header->protocol );
if( ! proto ) return ENOENT;
ERROR_PROPAGATE( packet_set_addr( packet, ( uint8_t * ) & header->source_address, ( uint8_t * ) & header->destination_address, IP_ADDR ));
if( proto->tl_received_msg ){
return proto->tl_received_msg( device_id, packet, SERVICE_IP );
}else{
return tl_received_msg( proto->phone, device_id, packet, proto->service );
}
}
}
 
in_addr_t ip_get_destination( ip_header_ref header ){
in_addr_t destination;
 
// TODO search set ipopt route?
destination.s_addr = header->destination_address; //ntohl( header->destination_address );
return destination;
}
 
/** @}
*/
/branches/network/uspace/srv/net/il/ip/Makefile
38,8 → 38,10
SOURCES = \
$(NAME)_module.c \
$(NAME).c \
$(NAME)_client.c \
$(NET_BASE)module.c \
$(NET_BASE)modules.c \
$(NET_BASE)crc.c \
$(STRUCTURES)char_map.c \
$(STRUCTURES)measured_strings.c \
$(STRUCTURES)module_map.c \
/branches/network/uspace/srv/net/il/ip/ip.h
38,10 → 38,14
#define __NET_IP_H__
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include "../../include/sockaddr.h"
#include "../../include/device.h"
#include "../../include/ip_interface.h"
 
#include "../../structures/int_map.h"
#include "../../structures/generic_field.h"
#include "../../structures/module_map.h"
 
typedef struct ip_netif ip_netif_t;
50,6 → 54,9
typedef struct ip_proto ip_proto_t;
typedef ip_proto_t * ip_proto_ref;
 
typedef struct ip_route ip_route_t;
typedef ip_route_t * ip_route_ref;
 
typedef struct ip_globals ip_globals_t;
 
DEVICE_MAP_DECLARE( ip_netifs, ip_netif_t )
56,32 → 63,57
 
INT_MAP_DECLARE( ip_protos, ip_proto_t )
 
GENERIC_FIELD_DECLARE( ip_routes, ip_route_t )
 
struct ip_netif{
device_id_t device_id;
services_t service;
int phone;
module_ref arp;
int ipv;
int dhcp;
in_addr_t address;
in_addr_t netmask;
in_addr_t gateway;
device_state_t state;
in_addr_t broadcast;
in_addr_t dns1;
in_addr_t dns2;
// TODO modules
ip_routes_t routes;
/** Reserved packet prefix length.
*/
size_t prefix;
/** Maximal packet content length.
*/
size_t content;
/** Reserved packet suffix length.
*/
size_t suffix;
/** Packet address length.
* The hardware address length is used.
*/
size_t addr_len;
};
 
struct ip_proto{
int protocol;
services_t service;
int phone;
tl_received_msg_t tl_received_msg;
};
 
struct ip_route{
in_addr_t address;
in_addr_t netmask;
in_addr_t gateway;
ip_netif_ref netif;
};
 
struct ip_globals{
int net_phone;
int net_phone;
ip_netifs_t netifs;
ip_protos_t protos;
ip_route_t gateway;
modules_t modules;
async_client_conn_t client_connection;
uint16_t packet_counter;
};
 
#endif
/branches/network/uspace/srv/net/Makefile
36,11 → 36,11
net/start
 
DIRS_MODULAR = il/ip \
il/arp \
tl/udp \
tl/tcp \
il/arp \
# il/rarp \
# il/icmp \
# tl/udp \
# socket
 
DIRS_ALL = $(DIRS) $(DIRS_MODULAR)
/branches/network/boot/arch/ia32/Makefile.inc
64,11 → 64,11
 
ifeq ($(NETWORKING), modular)
RD_SRVS += $(USPACEDIR)/srv/net/il/ip/ip \
$(USPACEDIR)/srv/net/il/arp/arp \
$(USPACEDIR)/srv/net/tl/udp/udp \
$(USPACEDIR)/srv/net/tl/tcp/tcp \
$(USPACEDIR)/srv/net/il/arp/arp \
# $(USPACEDIR)/srv/net/il/rarp/rarp \
# $(USPACEDIR)/srv/net/il/icmp/icmp \
# $(USPACEDIR)/srv/net/tl/udp/udp \
# $(USPACEDIR)/srv/net/socket
endif