Changes in uspace/lib/net/generic/packet_remote.c [b69ceea:ffa2c8ef] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/generic/packet_remote.c
rb69ceea rffa2c8ef 38 38 #include <async.h> 39 39 #include <errno.h> 40 #include <err.h>41 #include <ipc/ipc.h>42 40 #include <ipc/packet.h> 43 41 #include <sys/mman.h> … … 65 63 */ 66 64 static int 67 packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size) 68 { 69 ERROR_DECLARE; 70 65 packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size) 66 { 71 67 ipc_call_t answer; 72 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 73 74 *packet = (packet_t) as_get_mappable_page(size); 75 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) || 76 ERROR_OCCURRED(pm_add(*packet))) { 68 aid_t message; 69 int rc; 70 71 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 72 73 *packet = (packet_t *) as_get_mappable_page(size); 74 rc = async_share_in_start_0_0(phone, *packet, size); 75 if (rc != EOK) { 77 76 munmap(*packet, size); 78 77 async_wait_for(message, NULL); 79 return ERROR_CODE; 80 } 81 82 ipcarg_t result; 78 return rc; 79 } 80 rc = pm_add(*packet); 81 if (rc != EOK) { 82 munmap(*packet, size); 83 async_wait_for(message, NULL); 84 return rc; 85 } 86 87 sysarg_t result; 83 88 async_wait_for(message, &result); 84 89 … … 94 99 * @param[out] packet The packet reference. 95 100 * @param[in] packet_id The packet identifier. 96 * @return sEOK on success.97 * @return sEINVAL if the packet parameter is NULL.98 * @return sOther error codes as defined for the NET_PACKET_GET_SIZE101 * @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 99 104 * message. 100 * @return sOther error codes as defined for the packet_return()105 * @return Other error codes as defined for the packet_return() 101 106 * function. 102 107 */ 103 int packet_translate_remote(int phone, packet_ refpacket, packet_id_t packet_id)104 { 105 ERROR_DECLARE;108 int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id) 109 { 110 int rc; 106 111 107 112 if (!packet) … … 110 115 *packet = pm_find(packet_id); 111 116 if (!*packet) { 112 ipcarg_t size;117 sysarg_t size; 113 118 114 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, 115 packet_id, &size)); 116 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 119 rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, 120 &size); 121 if (rc != EOK) 122 return rc; 123 rc = packet_return(phone, packet, packet_id, size); 124 if (rc != EOK) 125 return rc; 117 126 } 118 127 if ((*packet)->next) { 119 packet_t next;128 packet_t *next; 120 129 121 130 return packet_translate_remote(phone, &next, (*packet)->next); … … 135 144 * @param[in] max_content The maximal content length in bytes. 136 145 * @param[in] max_suffix The maximal suffix length in bytes. 137 * @return sThe packet reference.138 * @return sNULL on error.139 */ 140 packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len,146 * @return The packet reference. 147 * @return NULL on error. 148 */ 149 packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 141 150 size_t max_prefix, size_t max_suffix) 142 151 { 143 ERROR_DECLARE;144 145 i pcarg_t packet_id;146 ipcarg_t size;147 148 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4,149 max_content, addr_len, max_prefix, max_suffix, &packet_id, &size)))152 sysarg_t packet_id; 153 sysarg_t size; 154 int rc; 155 156 rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 157 max_prefix, max_suffix, &packet_id, &size); 158 if (rc != EOK) 150 159 return NULL; 151 160 152 161 153 packet_t packet = pm_find(packet_id);162 packet_t *packet = pm_find(packet_id); 154 163 if (!packet) { 155 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,156 size)))164 rc = packet_return(phone, &packet, packet_id, size); 165 if (rc != EOK) 157 166 return NULL; 158 167 } … … 167 176 * @param[in] phone The packet server module phone. 168 177 * @param[in] content The maximal content length in bytes. 169 * @return sThe packet reference.170 * @return sNULL on error.171 */ 172 packet_t packet_get_1_remote(int phone, size_t content)173 { 174 ERROR_DECLARE;175 176 i pcarg_t packet_id;177 ipcarg_t size;178 179 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content,180 &packet_id, &size)))178 * @return The packet reference. 179 * @return NULL on error. 180 */ 181 packet_t *packet_get_1_remote(int phone, size_t content) 182 { 183 sysarg_t packet_id; 184 sysarg_t size; 185 int rc; 186 187 rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 188 &size); 189 if (rc != EOK) 181 190 return NULL; 182 191 183 packet_t packet = pm_find(packet_id);192 packet_t *packet = pm_find(packet_id); 184 193 if (!packet) { 185 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,186 size)))194 rc = packet_return(phone, &packet, packet_id, size); 195 if (rc != EOK) 187 196 return NULL; 188 197 }
Note:
See TracChangeset
for help on using the changeset viewer.