/branches/network/uspace/srv/net/structures/measured_strings.c |
---|
37,8 → 37,7 |
#include <errno.h> |
#include <malloc.h> |
#include <stdio.h> |
#include <string.h> |
#include <mem.h> |
#include <unistd.h> |
#include <ipc/ipc.h> |
/branches/network/uspace/srv/net/structures/module_map.c |
---|
0,0 → 1,111 |
/* |
* 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 netif |
* @{ |
*/ |
/** |
* @file |
*/ |
#include <malloc.h> |
#include <task.h> |
#include <unistd.h> |
#include <ipc/services.h> |
#include "../err.h" |
#include "../modules.h" |
#include "generic_char_map.h" |
#include "module_map.h" |
GENERIC_CHAR_MAP_IMPLEMENT( modules, module_t ) |
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id ){ |
ERROR_DECLARE; |
module_ref tmp_module; |
tmp_module = ( module_ref ) malloc( sizeof( module_t )); |
if( ! tmp_module ) return ENOMEM; |
tmp_module->task_id = task_id; |
tmp_module->phone = 0; |
tmp_module->usage = 0; |
tmp_module->name = name; |
tmp_module->filename = filename; |
tmp_module->service = service; |
if( ERROR_OCCURRED( modules_add( modules, tmp_module->name, 0, tmp_module ))){ |
free( tmp_module ); |
return ERROR_CODE; |
} |
if( module ) * module = tmp_module; |
return EOK; |
} |
module_ref get_running_module( modules_ref modules, char * name ){ |
module_ref module; |
module = modules_find( modules, name, 0 ); |
// TODO register the unknown one? |
if( ! module ) return NULL; |
if( ! module->task_id ){ |
module->task_id = spawn( module->filename ); |
if( ! module->task_id ) return NULL; |
} |
if( ! module->phone ){ |
module->phone = connect_to_service( module->service ); |
} |
return module; |
} |
task_id_t spawn( char * fname ){ |
char * argv[ 2 ]; |
// char * argv[ 4 ]; |
task_id_t res; |
// printf( "Spawning %s\n", fname ); |
argv[ 0 ] = fname; |
argv[ 1 ] = NULL; |
res = task_spawn( fname, argv ); |
/* argv[ 0 ] = "/app/trace"; |
argv[ 1 ] = "+ti"; |
argv[ 2 ] = fname; |
argv[ 3 ] = NULL; |
res = task_spawn( "/app/trace", argv ); |
*/ |
if( res != 0 ){ |
/* Success */ |
usleep( 10000 ); |
} |
return res; |
} |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/structures/generic_field.h |
---|
38,7 → 38,7 |
#include <errno.h> |
#include <malloc.h> |
#include <string.h> |
#include <mem.h> |
#include <unistd.h> |
#define GENERIC_FIELD_MAGIC_VALUE 0x55667788 |
/branches/network/uspace/srv/net/structures/packet/packet_client.c |
---|
36,9 → 36,9 |
#include <async.h> |
#include <errno.h> |
#include <mem.h> |
#include <unistd.h> |
//#include <stdio.h> |
#include <string.h> |
#include <ipc/ipc.h> |
#include <sys/mman.h> |
122,15 → 122,15 |
padding = packet->addr_len - addr_len; |
if( src ){ |
memcpy(( void * ) packet + packet->src_addr, src, addr_len ); |
memset(( void * ) packet + packet->src_addr + addr_len, 0, padding ); |
bzero(( void * ) packet + packet->src_addr + addr_len, padding ); |
}else{ |
memset(( void * ) packet + packet->src_addr + addr_len, 0, packet->addr_len ); |
bzero(( void * ) packet + packet->src_addr + addr_len, packet->addr_len ); |
} |
if( dest ){ |
memcpy(( void * ) packet + packet->dest_addr, dest, addr_len ); |
memset(( void * ) packet + packet->dest_addr + addr_len, 0, padding ); |
bzero(( void * ) packet + packet->dest_addr + addr_len, padding ); |
}else{ |
memset(( void * ) packet + packet->dest_addr + addr_len, 0, packet->addr_len ); |
bzero(( void * ) packet + packet->dest_addr + addr_len, packet->addr_len ); |
} |
return EOK; |
} |
194,7 → 194,7 |
return packet; |
} |
void packet_release( int phone, packet_id_t packet_id ){ |
void pq_release( int phone, packet_id_t packet_id ){ |
async_msg_1( phone, NET_PACKET_RELEASE, packet_id ); |
} |
/branches/network/uspace/srv/net/structures/packet/packet.c |
---|
37,9 → 37,9 |
#include <errno.h> |
#include <malloc.h> |
#include <mem.h> |
#include <rwlock.h> |
//#include <stdio.h> |
#include <string.h> |
#include <sys/mman.h> |
148,7 → 148,7 |
rwlock_write_unlock( & pm_globals.lock ); |
return ENOMEM; |
} |
memset( map, 0, sizeof( packet_map_t )); |
bzero( map, sizeof( packet_map_t )); |
if(( ERROR_CODE = gpm_add( & pm_globals.packet_map, map )) < 0 ){ |
rwlock_write_unlock( & pm_globals.lock ); |
free( map ); |
/branches/network/uspace/srv/net/structures/packet/packet_client.h |
---|
200,7 → 200,7 |
* @param phone The packet server module phone. Input parameter. |
* @param packet_id The packet identifier. Input parameter. |
*/ |
void packet_release( int phone, packet_id_t packet_id ); |
void pq_release( int phone, packet_id_t packet_id ); |
#endif |
/branches/network/uspace/srv/net/structures/packet/packet_server.c |
---|
51,6 → 51,18 |
#include "packet_header.h" |
#include "packet_server.h" |
/** The default address length reserved for new packets. |
*/ |
#define DEFAULT_ADDR_LEN 32 |
/** The default prefix reserved for new packets. |
*/ |
#define DEFAULT_PREFIX 0 |
/** The default suffix reserved for new packets. |
*/ |
#define DEFAULT_SUFFIX 0 |
/** Returns the packet identifier message parameter. |
*/ |
#define IPC_GET_ID( call ) ( packet_id_t ) IPC_GET_ARG1( * call ) |
69,7 → 81,7 |
/** Returns the maximal suffix length message parameter. |
*/ |
#define IPC_GET_SUFIX( call ) ( size_t ) IPC_GET_ARG4( * call ) |
#define IPC_GET_SUFFIX( call ) ( size_t ) IPC_GET_ARG4( * call ) |
#define FREE_QUEUES_COUNT 7 |
155,7 → 167,7 |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_PACKET_CREATE_1: |
packet = packet_get( 0, 0, IPC_GET_CONTENT( call ), 0 ); |
packet = packet_get( DEFAULT_ADDR_LEN, DEFAULT_PREFIX, IPC_GET_CONTENT( call ), DEFAULT_SUFFIX ); |
if( ! packet ) return ENOMEM; |
* answer_count = 2; |
IPC_SET_ARG1( * answer, packet->packet_id ); |
162,7 → 174,7 |
IPC_SET_ARG2( * answer, packet->length ); |
return EOK; |
case NET_PACKET_CREATE_4: |
packet = packet_get( IPC_GET_ADDR_LEN( call ), IPC_GET_PREFIX( call ), IPC_GET_CONTENT( call ), IPC_GET_SUFIX( call )); |
packet = packet_get( IPC_GET_ADDR_LEN( call ), IPC_GET_PREFIX( call ), IPC_GET_CONTENT( call ), IPC_GET_SUFFIX( call )); |
if( ! packet ) return ENOMEM; |
* answer_count = 2; |
IPC_SET_ARG1( * answer, packet->packet_id ); |
/branches/network/uspace/srv/net/structures/module_map.h |
---|
0,0 → 1,67 |
/* |
* 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 netif |
* @{ |
*/ |
/** |
* @file |
*/ |
#ifndef __NET_MODULES_MAP_H__ |
#define __NET_MODULES_MAP_H__ |
#include <task.h> |
#include <ipc/services.h> |
#include "generic_char_map.h" |
typedef struct module_struct module_t; |
typedef module_t * module_ref; |
GENERIC_CHAR_MAP_DECLARE( modules, module_t ) |
struct module_struct{ |
task_id_t task_id; |
services_t service; |
int phone; |
int usage; |
char * name; |
char * filename; |
}; |
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id ); |
module_ref get_running_module( modules_ref modules, char * name ); |
task_id_t spawn( char * fname ); |
#endif |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/structures/char_map.c |
---|
37,8 → 37,8 |
#include <errno.h> |
#include <malloc.h> |
#include <mem.h> |
#include <unistd.h> |
#include <string.h> |
#include "char_map.h" |
/branches/network/uspace/srv/net/structures/int_map.h |
---|
38,7 → 38,7 |
#include <errno.h> |
#include <malloc.h> |
#include <string.h> |
#include <mem.h> |
#define INT_MAP_MAGIC_VALUE 0x11223344 |
#define INT_MAP_ITEM_MAGIC_VALUE 0x55667788 |