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