Subversion Repositories HelenOS

Rev

Rev 4351 | Rev 4505 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4351 Rev 4395
Line 127... Line 127...
127
 *  @returns The packet of dimensions at least as given.
127
 *  @returns The packet of dimensions at least as given.
128
 *  @returns NULL if there is not enough memory left.
128
 *  @returns NULL if there is not enough memory left.
129
 */
129
 */
130
packet_t    packet_create( size_t length, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
130
packet_t    packet_create( size_t length, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
131
 
131
 
132
/** Initializes the packet according to the given dimensions.
132
/** Clears and initializes the packet according to the given dimensions.
133
 *  @param packet The packet to be initialized. Input parameter.
133
 *  @param packet The packet to be initialized. Input parameter.
134
 *  @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
134
 *  @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
135
 *  @param max_prefix The maximal prefix length in bytes. Input parameter.
135
 *  @param max_prefix The maximal prefix length in bytes. Input parameter.
136
 *  @param max_content The maximal content length in bytes. Input parameter.
136
 *  @param max_content The maximal content length in bytes. Input parameter.
137
 *  @param max_suffix The maximal suffix length in bytes. Input parameter.
137
 *  @param max_suffix The maximal suffix length in bytes. Input parameter.
Line 256... Line 256...
256
    if( packet == MAP_FAILED ) return NULL;
256
    if( packet == MAP_FAILED ) return NULL;
257
    ++ ps_globals.count;
257
    ++ ps_globals.count;
258
    packet->packet_id = ps_globals.count;
258
    packet->packet_id = ps_globals.count;
259
    packet->length = length;
259
    packet->length = length;
260
    packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
260
    packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
261
    packet->magic_value = PACKET_MAGIC_VALUE;
-
 
262
    if( ERROR_OCCURRED( pm_add( packet ))){
261
    if( ERROR_OCCURRED( pm_add( packet ))){
263
        munmap( packet, packet->length );
262
        munmap( packet, packet->length );
264
        return NULL;
263
        return NULL;
265
    }
264
    }
266
    packet_release( packet );
265
    packet_release( packet );
267
    return packet;
266
    return packet;
268
}
267
}
269
 
268
 
270
void packet_init( packet_t packet, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix ){
269
void packet_init( packet_t packet, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix ){
-
 
270
    int length;
-
 
271
 
-
 
272
    // clear whole packet
-
 
273
    length = packet->length;
-
 
274
    bzero( packet, packet->length );
-
 
275
    packet->length = length;
-
 
276
    packet->magic_value = PACKET_MAGIC_VALUE;
-
 
277
/*  // clear the packet header
271
    packet->order = 0;
278
    packet->order = 0;
272
    packet->metric = 0;
279
    packet->metric = 0;
273
    packet->previous = 0;
280
    packet->previous = 0;
274
    packet->next = 0;
281
    packet->next = 0;
275
    packet->addr_len = addr_len;
282
    packet->addr_len = 0;
276
    packet->src_addr = sizeof( struct packet );
283
*/  packet->src_addr = sizeof( struct packet );
277
    packet->dest_addr = packet->src_addr + packet->addr_len;
284
    packet->dest_addr = packet->src_addr + addr_len;
278
    packet->max_prefix = max_prefix;
285
    packet->max_prefix = max_prefix;
279
    packet->max_content = max_content;
286
    packet->max_content = max_content;
280
    packet->data_start = packet->dest_addr + packet->addr_len + packet->max_prefix;
287
    packet->data_start = packet->dest_addr + addr_len + packet->max_prefix;
281
    packet->data_end = packet->data_start;
288
    packet->data_end = packet->data_start;
282
}
289
}
283
 
290
 
284
int packet_reply( const packet_t packet ){
291
int packet_reply( const packet_t packet ){
285
    ipc_callid_t    callid;
292
    ipc_callid_t    callid;