Subversion Repositories HelenOS

Rev

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

Rev 4192 Rev 4243
Line 116... Line 116...
116
 
116
 
117
int packet_set_addr( packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len ){
117
int packet_set_addr( packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len ){
118
    size_t  padding;
118
    size_t  padding;
119
 
119
 
120
    if( ! packet_is_valid( packet )) return EINVAL;
120
    if( ! packet_is_valid( packet )) return EINVAL;
121
    if( packet->addr_len >= addr_len ) return ENOMEM;
121
    if( packet->addr_len < addr_len ) return ENOMEM;
122
    padding = packet->addr_len - addr_len;
122
    padding = packet->addr_len - addr_len;
123
    if( src ){
123
    if( src ){
124
        memcpy(( void * ) packet + packet->src_addr, src, addr_len );
124
        memcpy(( void * ) packet + packet->src_addr, src, addr_len );
125
        bzero(( void * ) packet + packet->src_addr + addr_len, padding );
125
        if( padding ) bzero(( void * ) packet + packet->src_addr + addr_len, padding );
126
    }else{
126
    }else{
127
        bzero(( void * ) packet + packet->src_addr + addr_len, packet->addr_len );
127
        bzero(( void * ) packet + packet->src_addr + addr_len, packet->addr_len );
128
    }
128
    }
129
    if( dest ){
129
    if( dest ){
130
        memcpy(( void * ) packet + packet->dest_addr, dest, addr_len );
130
        memcpy(( void * ) packet + packet->dest_addr, dest, addr_len );
131
        bzero(( void * ) packet + packet->dest_addr + addr_len, padding );
131
        if( padding ) bzero(( void * ) packet + packet->dest_addr + addr_len, padding );
132
    }else{
132
    }else{
133
        bzero(( void * ) packet + packet->dest_addr + addr_len, packet->addr_len );
133
        bzero(( void * ) packet + packet->dest_addr + addr_len, packet->addr_len );
134
    }
134
    }
135
    return EOK;
135
    return EOK;
136
}
136
}
Line 171... Line 171...
171
 
171
 
172
    packet_id_t packet_id;
172
    packet_id_t packet_id;
173
    unsigned int size;
173
    unsigned int size;
174
    packet_t packet;
174
    packet_t packet;
175
 
175
 
176
    if( ERROR_OCCURRED( async_req_4_2( phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, & packet_id, & size ))
176
    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 ))
177
    || ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
177
    || ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
178
        return NULL;
178
        return NULL;
179
    }
179
    }
180
    return packet;
180
    return packet;
181
}
181
}
Line 185... Line 185...
185
 
185
 
186
    packet_id_t packet_id;
186
    packet_id_t packet_id;
187
    unsigned int    size;
187
    unsigned int    size;
188
    packet_t    packet;
188
    packet_t    packet;
189
 
189
 
190
    if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, & packet_id, & size ))
190
    if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, ( ipcarg_t * ) & packet_id, & size ))
191
    || ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
191
    || ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
192
        return NULL;
192
        return NULL;
193
    }
193
    }
194
    return packet;
194
    return packet;
195
}
195
}