Changes in uspace/lib/net/generic/packet_remote.c [849ed54:14f1db0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/generic/packet_remote.c
r849ed54 r14f1db0 32 32 33 33 /** @file 34 * Packet client interface implementation for standaloneremote modules.34 * Packet client interface implementation for remote modules. 35 35 * @see packet_client.h 36 36 */ … … 47 47 #include <packet/packet_header.h> 48 48 #include <packet/packet_messages.h> 49 #include <packet_remote.h> 49 50 50 /** Obtains the packet from the packet server as the shared memory block. 51 * Creates the local packet mapping as well. 52 * @param[in] phone The packet server module phone. 53 * @param[out] packet The packet reference pointer to store the received packet reference. 54 * @param[in] packet_id The packet identifier. 55 * @param[in] size The packet total size in bytes. 56 * @returns EOK on success. 57 * @returns Other error codes as defined for the pm_add() function. 58 * @returns Other error codes as defined for the async_share_in_start() function. 51 /** Obtain the packet from the packet server as the shared memory block. 52 * 53 * Create the local packet mapping as well. 54 * 55 * @param[in] phone The packet server module phone. 56 * @param[out] packet The packet reference pointer to store the received 57 * packet reference. 58 * @param[in] packet_id The packet identifier. 59 * @param[in] size The packet total size in bytes. 60 * 61 * @return EOK on success. 62 * @return Other error codes as defined for the pm_add() function. 63 * @return Other error codes as defined for the async_share_in_start() function. 64 * 59 65 */ 60 int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size); 61 62 int packet_translate(int phone, packet_ref packet, packet_id_t packet_id){ 66 static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){ 63 67 ERROR_DECLARE; 64 65 ipcarg_t size; 66 packet_t next; 67 68 if(! packet){ 69 return EINVAL; 70 } 71 *packet = pm_find(packet_id); 72 if(!(*packet)){ 73 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, 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; 79 } 80 81 int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){ 82 ERROR_DECLARE; 83 84 aid_t message; 68 85 69 ipc_call_t answer; 86 ipcarg_t result; 87 88 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 70 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 89 71 *packet = (packet_t) as_get_mappable_page(size); 90 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size))91 || ERROR_OCCURRED(pm_add(*packet))){72 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) 73 || ERROR_OCCURRED(pm_add(*packet))) { 92 74 munmap(*packet, size); 93 75 async_wait_for(message, NULL); 94 76 return ERROR_CODE; 95 77 } 78 79 ipcarg_t result; 96 80 async_wait_for(message, &result); 81 97 82 return result; 98 83 } 99 84 100 packet_t packet_get_4(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix){ 85 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 86 { 101 87 ERROR_DECLARE; 88 89 if (!packet) 90 return EINVAL; 91 92 *packet = pm_find(packet_id); 93 if (!(*packet)) { 94 ipcarg_t size; 95 96 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size)); 97 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 98 } 99 if ((** packet).next) { 100 packet_t next; 101 102 return packet_translate_remote(phone, &next, (** packet).next); 103 } 104 105 return EOK; 106 } 102 107 108 packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 109 size_t max_prefix, size_t max_suffix) 110 { 111 ERROR_DECLARE; 112 103 113 ipcarg_t packet_id; 104 114 ipcarg_t size; 105 packet_t packet;106 107 if(ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))){115 116 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, 117 addr_len, max_prefix, max_suffix, &packet_id, &size))) 108 118 return NULL; 119 120 121 packet_t packet = pm_find(packet_id); 122 if (!packet) { 123 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))) 124 return NULL; 109 125 } 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 } 126 116 127 return packet; 117 128 } 118 129 119 packet_t packet_get_1(int phone, size_t content){ 130 packet_t packet_get_1_remote(int phone, size_t content) 131 { 120 132 ERROR_DECLARE; 121 133 122 134 ipcarg_t packet_id; 123 135 ipcarg_t size; 124 packet_t packet;125 126 if(ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, &size))){136 137 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 138 &packet_id, &size))) 127 139 return NULL; 140 141 packet_t packet = pm_find(packet_id); 142 if (!packet) { 143 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))) 144 return NULL; 128 145 } 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 } 146 135 147 return packet; 136 148 } 137 149 138 void pq_release(int phone, packet_id_t packet_id){ 150 void pq_release_remote(int phone, packet_id_t packet_id) 151 { 139 152 async_msg_1(phone, NET_PACKET_RELEASE, packet_id); 140 153 }
Note:
See TracChangeset
for help on using the changeset viewer.