51
51
* Create the local packet mapping as well.
53
* @param[in] phone The packet server module phone.
54
* @param[out] packet The packet reference pointer to store the received
53
* @param[in] sess Packet server module session.
54
* @param[out] packet Packet reference pointer to store the received
55
55
* packet reference.
56
* @param[in] packet_id The packet identifier.
57
* @param[in] size The packet total size in bytes.
56
* @param[in] packet_id Packet identifier.
57
* @param[in] size Packet total size in bytes.
59
59
* @return EOK on success.
60
60
* @return Other error codes as defined for the pm_add() function.
61
* @return Other error codes as defined for the async_share_in_start() function.
61
* @return Other error codes as defined for the async_share_in_start()
65
packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size)
65
static int packet_return(async_sess_t *sess, packet_t **packet,
66
packet_id_t packet_id, size_t size)
68
*packet = (packet_t *) as_get_mappable_page(size);
70
async_exch_t *exch = async_exchange_begin(sess);
71
message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
73
*packet = (packet_t *) as_get_mappable_page(size);
74
rc = async_share_in_start_0_0(phone, *packet, size);
76
munmap(*packet, size);
77
async_wait_for(message, NULL);
82
munmap(*packet, size);
83
async_wait_for(message, NULL);
72
aid_t message = async_send_1(exch, NET_PACKET_GET, packet_id, &answer);
73
int rc = async_share_in_start_0_0(exch, *packet, size);
74
async_exchange_end(exch);
88
77
async_wait_for(message, &result);
80
munmap(*packet, size);
86
munmap(*packet, size);
93
/** Translates the packet identifier to the packet reference.
95
* Tries to find mapping first.
96
* Contacts the packet server to share the packet if the mapping is not present.
98
* @param[in] phone The packet server module phone.
99
* @param[out] packet The packet reference.
100
* @param[in] packet_id The packet identifier.
101
* @return EOK on success.
102
* @return EINVAL if the packet parameter is NULL.
103
* @return Other error codes as defined for the NET_PACKET_GET_SIZE
105
* @return Other error codes as defined for the packet_return()
93
/** Translate the packet identifier to the packet reference.
95
* Try to find mapping first. The packet server is asked to share
96
* the packet if the mapping is not present.
98
* @param[in] sess Packet server module session.
99
* @param[out] packet Packet reference.
100
* @param[in] packet_id Packet identifier.
102
* @return EOK on success.
103
* @return EINVAL if the packet parameter is NULL.
104
* @return Other error codes as defined for the NET_PACKET_GET_SIZE
106
* @return Other error codes as defined for the packet_return()
108
int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id)
110
int packet_translate_remote(async_sess_t *sess, packet_t **packet,
111
packet_id_t packet_id)
115
116
*packet = pm_find(packet_id);
118
async_exch_t *exch = async_exchange_begin(sess);
119
rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id,
120
int rc = async_req_1_1(exch, NET_PACKET_GET_SIZE, packet_id,
122
async_exchange_end(exch);
123
rc = packet_return(phone, packet, packet_id, size);
127
rc = packet_return(sess, packet, packet_id, size);
127
132
if ((*packet)->next) {
130
return packet_translate_remote(phone, &next, (*packet)->next);
134
return packet_translate_remote(sess, &next, (*packet)->next);
136
/** Obtains the packet of the given dimensions.
138
* Contacts the packet server to return the appropriate packet.
140
* @param[in] phone The packet server module phone.
141
* @param[in] addr_len The source and destination addresses maximal length in
143
* @param[in] max_prefix The maximal prefix length in bytes.
144
* @param[in] max_content The maximal content length in bytes.
145
* @param[in] max_suffix The maximal suffix length in bytes.
146
* @return The packet reference.
147
* @return NULL on error.
140
/** Obtain the packet of given dimensions.
142
* Contact the packet server to return the appropriate packet.
144
* @param[in] sess Packet server module session.
145
* @param[in] addr_len Source and destination addresses maximal length
147
* @param[in] max_prefix Maximal prefix length in bytes.
148
* @param[in] max_content Maximal content length in bytes.
149
* @param[in] max_suffix Maximal suffix length in bytes.
151
* @return The packet reference.
152
* @return NULL on error.
149
packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
150
size_t max_prefix, size_t max_suffix)
155
packet_t *packet_get_4_remote(async_sess_t *sess, size_t max_content,
156
size_t addr_len, size_t max_prefix, size_t max_suffix)
158
async_exch_t *exch = async_exchange_begin(sess);
152
159
sysarg_t packet_id;
156
rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len,
161
int rc = async_req_4_2(exch, NET_PACKET_CREATE_4, max_content, addr_len,
157
162
max_prefix, max_suffix, &packet_id, &size);
163
async_exchange_end(exch);
162
168
packet_t *packet = pm_find(packet_id);
164
rc = packet_return(phone, &packet, packet_id, size);
170
rc = packet_return(sess, &packet, packet_id, size);
172
/** Obtains the packet of the given content size.
174
* Contacts the packet server to return the appropriate packet.
176
* @param[in] phone The packet server module phone.
177
* @param[in] content The maximal content length in bytes.
178
* @return The packet reference.
179
* @return NULL on error.
178
/** Obtain the packet of given content size.
180
* Contact the packet server to return the appropriate packet.
182
* @param[in] sess Packet server module session.
183
* @param[in] content Maximal content length in bytes.
185
* @return The packet reference.
186
* @return NULL on error.
181
packet_t *packet_get_1_remote(int phone, size_t content)
189
packet_t *packet_get_1_remote(async_sess_t *sess, size_t content)
191
async_exch_t *exch = async_exchange_begin(sess);
183
192
sysarg_t packet_id;
187
rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id,
194
int rc = async_req_1_2(exch, NET_PACKET_CREATE_1, content, &packet_id,
196
async_exchange_end(exch);
192
201
packet_t *packet = pm_find(packet_id);
194
rc = packet_return(phone, &packet, packet_id, size);
203
rc = packet_return(sess, &packet, packet_id, size);