Changeset dd0c8a0 in mainline for uspace/lib/c/generic/iplink.c
- Timestamp:
- 2013-09-29T06:56:33Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a9bd960d
- Parents:
- 3deb0155 (diff), 13be2583 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink.c
r3deb0155 rdd0c8a0 39 39 #include <errno.h> 40 40 #include <inet/iplink.h> 41 #include <inet/addr.h> 41 42 #include <ipc/iplink.h> 42 43 #include <ipc/services.h> … … 83 84 { 84 85 async_exch_t *exch = async_exchange_begin(iplink->sess); 85 86 ipc_call_t answer; 87 aid_t req = async_send_2(exch, IPLINK_SEND, sdu->lsrc.ipv4, 88 sdu->ldest.ipv4, &answer); 86 87 ipc_call_t answer; 88 aid_t req = async_send_2(exch, IPLINK_SEND, (sysarg_t) sdu->src, 89 (sysarg_t) sdu->dest, &answer); 90 89 91 int rc = async_data_write_start(exch, sdu->data, sdu->size); 90 async_exchange_end(exch); 91 92 if (rc != EOK) { 93 async_forget(req); 94 return rc; 95 } 96 97 sysarg_t retval; 98 async_wait_for(req, &retval); 99 if (retval != EOK) 100 return retval; 101 102 return EOK; 92 93 async_exchange_end(exch); 94 95 if (rc != EOK) { 96 async_forget(req); 97 return rc; 98 } 99 100 sysarg_t retval; 101 async_wait_for(req, &retval); 102 103 return (int) retval; 104 } 105 106 int iplink_send6(iplink_t *iplink, iplink_sdu6_t *sdu) 107 { 108 async_exch_t *exch = async_exchange_begin(iplink->sess); 109 110 ipc_call_t answer; 111 aid_t req = async_send_0(exch, IPLINK_SEND6, &answer); 112 113 int rc = async_data_write_start(exch, &sdu->dest, sizeof(addr48_t)); 114 if (rc != EOK) { 115 async_exchange_end(exch); 116 async_forget(req); 117 return rc; 118 } 119 120 rc = async_data_write_start(exch, sdu->data, sdu->size); 121 122 async_exchange_end(exch); 123 124 if (rc != EOK) { 125 async_forget(req); 126 return rc; 127 } 128 129 sysarg_t retval; 130 async_wait_for(req, &retval); 131 132 return (int) retval; 103 133 } 104 134 105 135 int iplink_get_mtu(iplink_t *iplink, size_t *rmtu) 106 136 { 137 async_exch_t *exch = async_exchange_begin(iplink->sess); 138 107 139 sysarg_t mtu; 108 async_exch_t *exch = async_exchange_begin(iplink->sess);109 110 140 int rc = async_req_0_1(exch, IPLINK_GET_MTU, &mtu); 111 async_exchange_end(exch); 112 141 142 async_exchange_end(exch); 143 113 144 if (rc != EOK) 114 145 return rc; 115 146 116 147 *rmtu = mtu; 117 148 return EOK; 118 149 } 119 150 120 int iplink_addr_add(iplink_t *iplink, iplink_addr_t *addr) 121 { 122 async_exch_t *exch = async_exchange_begin(iplink->sess); 123 124 int rc = async_req_1_0(exch, IPLINK_ADDR_ADD, (sysarg_t)addr->ipv4); 125 async_exchange_end(exch); 126 127 return rc; 128 } 129 130 int iplink_addr_remove(iplink_t *iplink, iplink_addr_t *addr) 131 { 132 async_exch_t *exch = async_exchange_begin(iplink->sess); 133 134 int rc = async_req_1_0(exch, IPLINK_ADDR_REMOVE, (sysarg_t)addr->ipv4); 135 async_exchange_end(exch); 136 137 return rc; 138 } 139 140 static void iplink_ev_recv(iplink_t *iplink, ipc_callid_t callid, 141 ipc_call_t *call) 142 { 143 int rc; 144 iplink_sdu_t sdu; 145 146 sdu.lsrc.ipv4 = IPC_GET_ARG1(*call); 147 sdu.ldest.ipv4 = IPC_GET_ARG2(*call); 148 149 rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, &sdu.size); 150 if (rc != EOK) { 151 async_answer_0(callid, rc); 151 int iplink_get_mac48(iplink_t *iplink, addr48_t *mac) 152 { 153 async_exch_t *exch = async_exchange_begin(iplink->sess); 154 155 ipc_call_t answer; 156 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 157 158 int rc = async_data_read_start(exch, mac, sizeof(addr48_t)); 159 160 loc_exchange_end(exch); 161 162 if (rc != EOK) { 163 async_forget(req); 164 return rc; 165 } 166 167 sysarg_t retval; 168 async_wait_for(req, &retval); 169 170 return (int) retval; 171 } 172 173 int iplink_addr_add(iplink_t *iplink, inet_addr_t *addr) 174 { 175 async_exch_t *exch = async_exchange_begin(iplink->sess); 176 177 ipc_call_t answer; 178 aid_t req = async_send_0(exch, IPLINK_ADDR_ADD, &answer); 179 180 int rc = async_data_write_start(exch, addr, sizeof(inet_addr_t)); 181 async_exchange_end(exch); 182 183 if (rc != EOK) { 184 async_forget(req); 185 return rc; 186 } 187 188 sysarg_t retval; 189 async_wait_for(req, &retval); 190 191 return (int) retval; 192 } 193 194 int iplink_addr_remove(iplink_t *iplink, inet_addr_t *addr) 195 { 196 async_exch_t *exch = async_exchange_begin(iplink->sess); 197 198 ipc_call_t answer; 199 aid_t req = async_send_0(exch, IPLINK_ADDR_REMOVE, &answer); 200 201 int rc = async_data_write_start(exch, addr, sizeof(inet_addr_t)); 202 async_exchange_end(exch); 203 204 if (rc != EOK) { 205 async_forget(req); 206 return rc; 207 } 208 209 sysarg_t retval; 210 async_wait_for(req, &retval); 211 212 return (int) retval; 213 } 214 215 static void iplink_ev_recv(iplink_t *iplink, ipc_callid_t iid, 216 ipc_call_t *icall) 217 { 218 iplink_recv_sdu_t sdu; 219 220 uint16_t af = IPC_GET_ARG1(*icall); 221 222 int rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, 223 &sdu.size); 224 if (rc != EOK) { 225 async_answer_0(iid, rc); 152 226 return; 153 227 } 154 155 rc = iplink->ev_ops->recv(iplink, &sdu );228 229 rc = iplink->ev_ops->recv(iplink, &sdu, af); 156 230 free(sdu.data); 157 async_answer_0( callid, rc);231 async_answer_0(iid, rc); 158 232 } 159 233 160 234 static void iplink_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 161 235 { 162 iplink_t *iplink = (iplink_t *) arg;163 236 iplink_t *iplink = (iplink_t *) arg; 237 164 238 while (true) { 165 239 ipc_call_t call; 166 240 ipc_callid_t callid = async_get_call(&call); 167 241 168 242 if (!IPC_GET_IMETHOD(call)) { 169 243 /* TODO: Handle hangup */ 170 244 return; 171 245 } 172 246 173 247 switch (IPC_GET_IMETHOD(call)) { 174 248 case IPLINK_EV_RECV:
Note:
See TracChangeset
for help on using the changeset viewer.