Changes in uspace/lib/net/generic/packet_remote.c [14f1db0:849ed54] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/generic/packet_remote.c
r14f1db0 r849ed54 32 32 33 33 /** @file 34 * Packet client interface implementation for remote modules.34 * Packet client interface implementation for standalone 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>50 49 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 * 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. 65 59 */ 66 static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){ 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){ 67 63 ERROR_DECLARE; 68 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; 69 85 ipc_call_t answer; 70 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 86 ipcarg_t result; 87 88 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 71 89 *packet = (packet_t) as_get_mappable_page(size); 72 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size))73 || ERROR_OCCURRED(pm_add(*packet))){90 if(ERROR_OCCURRED(async_share_in_start_0_0(phone, * packet, size)) 91 || ERROR_OCCURRED(pm_add(*packet))){ 74 92 munmap(*packet, size); 75 93 async_wait_for(message, NULL); 76 94 return ERROR_CODE; 77 95 } 78 79 ipcarg_t result;80 96 async_wait_for(message, &result); 81 82 97 return result; 83 98 } 84 99 85 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 86 { 100 packet_t packet_get_4(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix){ 87 101 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 }107 102 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 113 103 ipcarg_t packet_id; 114 104 ipcarg_t 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)))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))){ 118 108 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))) 109 } 110 packet = pm_find(packet_id); 111 if(! packet){ 112 if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){ 124 113 return NULL; 114 } 125 115 } 126 127 116 return packet; 128 117 } 129 118 130 packet_t packet_get_1_remote(int phone, size_t content) 131 { 119 packet_t packet_get_1(int phone, size_t content){ 132 120 ERROR_DECLARE; 133 121 134 122 ipcarg_t packet_id; 135 123 ipcarg_t size; 136 137 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 138 &packet_id, &size)))124 packet_t packet; 125 126 if(ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, &size))){ 139 127 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)))128 } 129 packet = pm_find(packet_id); 130 if(! packet){ 131 if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){ 144 132 return NULL; 133 } 145 134 } 146 147 135 return packet; 148 136 } 149 137 150 void pq_release_remote(int phone, packet_id_t packet_id) 151 { 138 void pq_release(int phone, packet_id_t packet_id){ 152 139 async_msg_1(phone, NET_PACKET_RELEASE, packet_id); 153 140 }
Note:
See TracChangeset
for help on using the changeset viewer.