Changeset a35b458 in mainline for uspace/lib/c/generic/inet.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet.c
r3061bc1 ra35b458 45 45 { 46 46 async_exch_t *exch = async_exchange_begin(inet_sess); 47 47 48 48 ipc_call_t answer; 49 49 aid_t req = async_send_0(exch, INET_CALLBACK_CREATE, &answer); 50 50 51 51 port_id_t port; 52 52 errno_t rc = async_create_callback_port(exch, INTERFACE_INET_CB, 0, 0, 53 53 inet_cb_conn, NULL, &port); 54 55 async_exchange_end(exch); 56 54 55 async_exchange_end(exch); 56 57 57 if (rc != EOK) 58 58 return rc; 59 59 60 60 errno_t retval; 61 61 async_wait_for(req, &retval); 62 62 63 63 return retval; 64 64 } … … 69 69 errno_t rc = async_req_1_0(exch, INET_SET_PROTO, protocol); 70 70 async_exchange_end(exch); 71 71 72 72 return rc; 73 73 } … … 81 81 assert(inet_ev_ops == NULL); 82 82 assert(inet_protocol == 0); 83 83 84 84 rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc, 85 85 IPC_FLAG_BLOCKING); 86 86 if (rc != EOK) 87 87 return ENOENT; 88 88 89 89 inet_sess = loc_service_connect(inet_svc, INTERFACE_INET, 90 90 IPC_FLAG_BLOCKING); 91 91 if (inet_sess == NULL) 92 92 return ENOENT; 93 93 94 94 if (inet_set_proto(protocol) != EOK) { 95 95 async_hangup(inet_sess); … … 97 97 return EIO; 98 98 } 99 99 100 100 if (inet_callback_create() != EOK) { 101 101 async_hangup(inet_sess); … … 103 103 return EIO; 104 104 } 105 105 106 106 inet_protocol = protocol; 107 107 inet_ev_ops = ev_ops; … … 113 113 { 114 114 async_exch_t *exch = async_exchange_begin(inet_sess); 115 115 116 116 ipc_call_t answer; 117 117 aid_t req = async_send_4(exch, INET_SEND, dgram->iplink, dgram->tos, 118 118 ttl, df, &answer); 119 119 120 120 errno_t rc = async_data_write_start(exch, &dgram->src, sizeof(inet_addr_t)); 121 121 if (rc != EOK) { … … 124 124 return rc; 125 125 } 126 126 127 127 rc = async_data_write_start(exch, &dgram->dest, sizeof(inet_addr_t)); 128 128 if (rc != EOK) { … … 131 131 return rc; 132 132 } 133 133 134 134 rc = async_data_write_start(exch, dgram->data, dgram->size); 135 136 async_exchange_end(exch); 137 138 if (rc != EOK) { 139 async_forget(req); 140 return rc; 141 } 142 135 136 async_exchange_end(exch); 137 138 if (rc != EOK) { 139 async_forget(req); 140 return rc; 141 } 142 143 143 errno_t retval; 144 144 async_wait_for(req, &retval); 145 145 146 146 return retval; 147 147 } … … 150 150 { 151 151 async_exch_t *exch = async_exchange_begin(inet_sess); 152 152 153 153 ipc_call_t answer; 154 154 aid_t req = async_send_1(exch, INET_GET_SRCADDR, tos, &answer); 155 155 156 156 errno_t rc = async_data_write_start(exch, remote, sizeof(inet_addr_t)); 157 157 if (rc != EOK) { … … 160 160 return rc; 161 161 } 162 162 163 163 rc = async_data_read_start(exch, local, sizeof(inet_addr_t)); 164 165 async_exchange_end(exch); 166 167 if (rc != EOK) { 168 async_forget(req); 169 return rc; 170 } 171 164 165 async_exchange_end(exch); 166 167 if (rc != EOK) { 168 async_forget(req); 169 return rc; 170 } 171 172 172 errno_t retval; 173 173 async_wait_for(req, &retval); 174 174 175 175 return retval; 176 176 } … … 179 179 { 180 180 inet_dgram_t dgram; 181 181 182 182 dgram.tos = IPC_GET_ARG1(*icall); 183 183 dgram.iplink = IPC_GET_ARG2(*icall); 184 184 185 185 ipc_callid_t callid; 186 186 size_t size; … … 190 190 return; 191 191 } 192 192 193 193 if (size != sizeof(inet_addr_t)) { 194 194 async_answer_0(callid, EINVAL); … … 196 196 return; 197 197 } 198 198 199 199 errno_t rc = async_data_write_finalize(callid, &dgram.src, size); 200 200 if (rc != EOK) { … … 203 203 return; 204 204 } 205 205 206 206 if (!async_data_write_receive(&callid, &size)) { 207 207 async_answer_0(callid, EINVAL); … … 209 209 return; 210 210 } 211 211 212 212 if (size != sizeof(inet_addr_t)) { 213 213 async_answer_0(callid, EINVAL); … … 215 215 return; 216 216 } 217 217 218 218 rc = async_data_write_finalize(callid, &dgram.dest, size); 219 219 if (rc != EOK) { … … 222 222 return; 223 223 } 224 224 225 225 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size); 226 226 if (rc != EOK) { … … 228 228 return; 229 229 } 230 230 231 231 rc = inet_ev_ops->recv(&dgram); 232 232 free(dgram.data); … … 239 239 ipc_call_t call; 240 240 ipc_callid_t callid = async_get_call(&call); 241 241 242 242 if (!IPC_GET_IMETHOD(call)) { 243 243 /* TODO: Handle hangup */ 244 244 return; 245 245 } 246 246 247 247 switch (IPC_GET_IMETHOD(call)) { 248 248 case INET_EV_RECV:
Note:
See TracChangeset
for help on using the changeset viewer.