Subversion Repositories HelenOS

Rev

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

Rev 4351 Rev 4505
Line 34... Line 34...
34
 *  Packet client interface implementation for standalone remote modules.
34
 *  Packet client interface implementation for standalone remote modules.
35
 *  @see packet_client.h
35
 *  @see packet_client.h
36
 */
36
 */
37
 
37
 
38
#include <async.h>
38
#include <async.h>
-
 
39
#include <errno.h>
39
 
40
 
40
#include <ipc/ipc.h>
41
#include <ipc/ipc.h>
41
#include <sys/mman.h>
42
#include <sys/mman.h>
42
 
43
 
43
#include "../../err.h"
44
#include "../../err.h"
44
#include "../../messages.h"
45
#include "../../messages.h"
45
 
46
 
46
#include "packet.h"
47
#include "packet.h"
47
#include "packet_client.h"
48
#include "packet_client.h"
-
 
49
#include "packet_header.h"
48
#include "packet_messages.h"
50
#include "packet_messages.h"
49
 
51
 
50
/** Obtains the packet from the packet server as the shared memory block.
52
/** Obtains the packet from the packet server as the shared memory block.
51
 *  Creates the local packet mapping as well.
53
 *  Creates the local packet mapping as well.
52
 *  @param phone The packet server module phone. Input parameter.
54
 *  @param phone The packet server module phone. Input parameter.
Line 61... Line 63...
61
 
63
 
62
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){
64
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id ){
63
    ERROR_DECLARE;
65
    ERROR_DECLARE;
64
 
66
 
65
    unsigned int        size;
67
    unsigned int        size;
-
 
68
    packet_t            next;
66
 
69
 
67
    if( ! packet ) return EINVAL;
70
    if( ! packet ) return EINVAL;
68
    * packet = pm_find( packet_id );
71
    * packet = pm_find( packet_id );
69
    if( * packet ) return EOK;
72
    if( !( * packet )){
70
    ERROR_PROPAGATE( async_req_1_1( phone, NET_PACKET_GET_SIZE, packet_id, & size ));
73
        ERROR_PROPAGATE( async_req_1_1( phone, NET_PACKET_GET_SIZE, packet_id, & size ));
71
    return packet_return( phone, packet, packet_id, size );
74
        ERROR_PROPAGATE( packet_return( phone, packet, packet_id, size ));
-
 
75
    }
-
 
76
    if(( ** packet ).next ){
-
 
77
        return packet_translate( phone, & next, ( ** packet ).next );
-
 
78
    }else return EOK;
72
}
79
}
73
 
80
 
74
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size ){
81
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size ){
75
    ERROR_DECLARE;
82
    ERROR_DECLARE;
76
 
83
 
Line 95... Line 102...
95
 
102
 
96
    packet_id_t packet_id;
103
    packet_id_t packet_id;
97
    unsigned int size;
104
    unsigned int size;
98
    packet_t packet;
105
    packet_t packet;
99
 
106
 
100
    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 ))
107
    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 ))){
101
    || ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
-
 
102
        return NULL;
108
        return NULL;
103
    }
109
    }
-
 
110
    packet = pm_find( packet_id );
-
 
111
    if( ! packet ){
-
 
112
        if( ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
-
 
113
            return NULL;
-
 
114
        }
-
 
115
    }
104
    return packet;
116
    return packet;
105
}
117
}
106
 
118
 
107
packet_t packet_get_1( int phone, size_t content ){
119
packet_t packet_get_1( int phone, size_t content ){
108
    ERROR_DECLARE;
120
    ERROR_DECLARE;
109
 
121
 
110
    packet_id_t packet_id;
122
    packet_id_t packet_id;
111
    unsigned int    size;
123
    unsigned int    size;
112
    packet_t    packet;
124
    packet_t    packet;
113
 
125
 
114
    if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, ( ipcarg_t * ) & packet_id, & size ))
126
    if( ERROR_OCCURRED( async_req_1_2( phone, NET_PACKET_CREATE_1, content, ( ipcarg_t * ) & packet_id, & size ))){
115
    || ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
-
 
116
        return NULL;
127
        return NULL;
117
    }
128
    }
-
 
129
    packet = pm_find( packet_id );
-
 
130
    if( ! packet ){
-
 
131
        if( ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
-
 
132
            return NULL;
-
 
133
        }
-
 
134
    }
118
    return packet;
135
    return packet;
119
}
136
}
120
 
137
 
121
void pq_release( int phone, packet_id_t packet_id ){
138
void pq_release( int phone, packet_id_t packet_id ){
122
    async_msg_1( phone, NET_PACKET_RELEASE, packet_id );
139
    async_msg_1( phone, NET_PACKET_RELEASE, packet_id );