Subversion Repositories HelenOS

Rev

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

Rev 4395 Rev 4505
Line 192... Line 192...
192
            if( ! packet_is_valid( packet )) return ENOENT;
192
            if( ! packet_is_valid( packet )) return ENOENT;
193
            return packet_reply( packet );
193
            return packet_reply( packet );
194
        case NET_PACKET_GET_SIZE:
194
        case NET_PACKET_GET_SIZE:
195
            packet = pm_find( IPC_GET_ID( call ));
195
            packet = pm_find( IPC_GET_ID( call ));
196
            if( ! packet_is_valid( packet )) return ENOENT;
196
            if( ! packet_is_valid( packet )) return ENOENT;
197
            * answer_count = 1;
-
 
198
            IPC_SET_ARG1( * answer, packet->length );
197
            IPC_SET_ARG1( * answer, packet->length );
-
 
198
            * answer_count = 1;
199
            return EOK;
199
            return EOK;
200
        case NET_PACKET_RELEASE:
200
        case NET_PACKET_RELEASE:
201
            return packet_release_wrapper( IPC_GET_ID( call ));
201
            return packet_release_wrapper( IPC_GET_ID( call ));
202
    }
202
    }
203
    return ENOTSUP;
203
    return ENOTSUP;
Line 232... Line 232...
232
        if( length <= ps_globals.sizes[ index ] ){
232
        if( length <= ps_globals.sizes[ index ] ){
233
            packet = ps_globals.free[ index ];
233
            packet = ps_globals.free[ index ];
234
            while( packet_is_valid( packet ) && ( packet->length < length )){
234
            while( packet_is_valid( packet ) && ( packet->length < length )){
235
                packet = pm_find( packet->next );
235
                packet = pm_find( packet->next );
236
            }
236
            }
-
 
237
            if( packet_is_valid( packet )){
-
 
238
                if( packet == ps_globals.free[ index ] ){
-
 
239
                    ps_globals.free[ index ] = pq_detach( packet );
-
 
240
                }else{
237
            if( packet ){
241
                    pq_detach( packet );
-
 
242
                }
238
                packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
243
                packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
239
                futex_up( & ps_globals.lock );
244
                futex_up( & ps_globals.lock );
240
                return packet;
245
                return packet;
241
            }
246
            }
242
        }
247
        }
Line 256... Line 261...
256
    if( packet == MAP_FAILED ) return NULL;
261
    if( packet == MAP_FAILED ) return NULL;
257
    ++ ps_globals.count;
262
    ++ ps_globals.count;
258
    packet->packet_id = ps_globals.count;
263
    packet->packet_id = ps_globals.count;
259
    packet->length = length;
264
    packet->length = length;
260
    packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
265
    packet_init( packet, addr_len, max_prefix, max_content, max_suffix );
-
 
266
    packet->magic_value = PACKET_MAGIC_VALUE;
261
    if( ERROR_OCCURRED( pm_add( packet ))){
267
    if( ERROR_OCCURRED( pm_add( packet ))){
262
        munmap( packet, packet->length );
268
        munmap( packet, packet->length );
263
        return NULL;
269
        return NULL;
264
    }
270
    }
265
    packet_release( packet );
-
 
266
    return packet;
271
    return packet;
267
}
272
}
268
 
273
 
269
void packet_init( packet_t packet, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix ){
274
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
275
    // clear the packet content
273
    length = packet->length;
-
 
274
    bzero( packet, packet->length );
276
    bzero((( void * ) packet ) + sizeof( struct packet ), packet->length - sizeof( struct packet ));
275
    packet->length = length;
-
 
276
    packet->magic_value = PACKET_MAGIC_VALUE;
-
 
277
/*  // clear the packet header
277
    // clear the packet header
278
    packet->order = 0;
278
    packet->order = 0;
279
    packet->metric = 0;
279
    packet->metric = 0;
280
    packet->previous = 0;
280
    packet->previous = 0;
281
    packet->next = 0;
281
    packet->next = 0;
282
    packet->addr_len = 0;
282
    packet->addr_len = 0;
283
*/  packet->src_addr = sizeof( struct packet );
283
    packet->src_addr = sizeof( struct packet );
284
    packet->dest_addr = packet->src_addr + addr_len;
284
    packet->dest_addr = packet->src_addr + addr_len;
285
    packet->max_prefix = max_prefix;
285
    packet->max_prefix = max_prefix;
286
    packet->max_content = max_content;
286
    packet->max_content = max_content;
287
    packet->data_start = packet->dest_addr + addr_len + packet->max_prefix;
287
    packet->data_start = packet->dest_addr + addr_len + packet->max_prefix;
288
    packet->data_end = packet->data_start;
288
    packet->data_end = packet->data_start;