Changeset a46e56b in mainline for uspace/lib/c/generic/iplink_srv.c
- Timestamp:
- 2018-03-22T06:49:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77f0a1d
- Parents:
- 3e242d2
- git-author:
- Jakub Jermar <jakub@…> (2018-03-21 23:29:06)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-22 06:49:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink_srv.c
r3e242d2 ra46e56b 42 42 #include <inet/iplink_srv.h> 43 43 44 static void iplink_get_mtu_srv(iplink_srv_t *srv, cap_call_handle_t c allid,44 static void iplink_get_mtu_srv(iplink_srv_t *srv, cap_call_handle_t chandle, 45 45 ipc_call_t *call) 46 46 { 47 47 size_t mtu; 48 48 errno_t rc = srv->ops->get_mtu(srv, &mtu); 49 async_answer_1(c allid, rc, mtu);50 } 51 52 static void iplink_get_mac48_srv(iplink_srv_t *srv, cap_call_handle_t i id,49 async_answer_1(chandle, rc, mtu); 50 } 51 52 static void iplink_get_mac48_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle, 53 53 ipc_call_t *icall) 54 54 { … … 56 56 errno_t rc = srv->ops->get_mac48(srv, &mac); 57 57 if (rc != EOK) { 58 async_answer_0(i id, rc);59 return; 60 } 61 62 cap_call_handle_t c allid;63 size_t size; 64 if (!async_data_read_receive(&c allid, &size)) {65 async_answer_0(c allid, EREFUSED);66 async_answer_0(i id, EREFUSED);58 async_answer_0(icall_handle, rc); 59 return; 60 } 61 62 cap_call_handle_t chandle; 63 size_t size; 64 if (!async_data_read_receive(&chandle, &size)) { 65 async_answer_0(chandle, EREFUSED); 66 async_answer_0(icall_handle, EREFUSED); 67 67 return; 68 68 } 69 69 70 70 if (size != sizeof(addr48_t)) { 71 async_answer_0(c allid, EINVAL);72 async_answer_0(i id, EINVAL);73 return; 74 } 75 76 rc = async_data_read_finalize(c allid, &mac, size);71 async_answer_0(chandle, EINVAL); 72 async_answer_0(icall_handle, EINVAL); 73 return; 74 } 75 76 rc = async_data_read_finalize(chandle, &mac, size); 77 77 if (rc != EOK) 78 async_answer_0(c allid, rc);79 80 async_answer_0(i id, rc);81 } 82 83 static void iplink_set_mac48_srv(iplink_srv_t *srv, cap_call_handle_t i id,78 async_answer_0(chandle, rc); 79 80 async_answer_0(icall_handle, rc); 81 } 82 83 static void iplink_set_mac48_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle, 84 84 ipc_call_t *icall) 85 85 { … … 87 87 size_t size; 88 88 addr48_t mac; 89 cap_call_handle_t c allid;90 91 if (!async_data_write_receive(&c allid, &size)) {92 async_answer_0(c allid, EREFUSED);93 async_answer_0(i id, EREFUSED);89 cap_call_handle_t chandle; 90 91 if (!async_data_write_receive(&chandle, &size)) { 92 async_answer_0(chandle, EREFUSED); 93 async_answer_0(icall_handle, EREFUSED); 94 94 } 95 95 96 96 rc = srv->ops->set_mac48(srv, &mac); 97 97 if (rc != EOK) { 98 async_answer_0(i id, rc);99 return; 100 } 101 102 rc = async_data_read_finalize(c allid, &mac, sizeof(addr48_t));98 async_answer_0(icall_handle, rc); 99 return; 100 } 101 102 rc = async_data_read_finalize(chandle, &mac, sizeof(addr48_t)); 103 103 if (rc != EOK) 104 async_answer_0(c allid, rc);105 106 async_answer_0(i id, rc);107 } 108 109 static void iplink_addr_add_srv(iplink_srv_t *srv, cap_call_handle_t i id,110 ipc_call_t *icall) 111 { 112 cap_call_handle_t c allid;113 size_t size; 114 if (!async_data_write_receive(&c allid, &size)) {115 async_answer_0(c allid, EREFUSED);116 async_answer_0(i id, EREFUSED);104 async_answer_0(chandle, rc); 105 106 async_answer_0(icall_handle, rc); 107 } 108 109 static void iplink_addr_add_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle, 110 ipc_call_t *icall) 111 { 112 cap_call_handle_t chandle; 113 size_t size; 114 if (!async_data_write_receive(&chandle, &size)) { 115 async_answer_0(chandle, EREFUSED); 116 async_answer_0(icall_handle, EREFUSED); 117 117 return; 118 118 } 119 119 120 120 if (size != sizeof(inet_addr_t)) { 121 async_answer_0(c allid, EINVAL);122 async_answer_0(i id, EINVAL);121 async_answer_0(chandle, EINVAL); 122 async_answer_0(icall_handle, EINVAL); 123 123 return; 124 124 } 125 125 126 126 inet_addr_t addr; 127 errno_t rc = async_data_write_finalize(c allid, &addr, size);128 if (rc != EOK) { 129 async_answer_0(c allid, rc);130 async_answer_0(i id, rc);127 errno_t rc = async_data_write_finalize(chandle, &addr, size); 128 if (rc != EOK) { 129 async_answer_0(chandle, rc); 130 async_answer_0(icall_handle, rc); 131 131 } 132 132 133 133 rc = srv->ops->addr_add(srv, &addr); 134 async_answer_0(i id, rc);135 } 136 137 static void iplink_addr_remove_srv(iplink_srv_t *srv, cap_call_handle_t i id,138 ipc_call_t *icall) 139 { 140 cap_call_handle_t c allid;141 size_t size; 142 if (!async_data_write_receive(&c allid, &size)) {143 async_answer_0(c allid, EREFUSED);144 async_answer_0(i id, EREFUSED);134 async_answer_0(icall_handle, rc); 135 } 136 137 static void iplink_addr_remove_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle, 138 ipc_call_t *icall) 139 { 140 cap_call_handle_t chandle; 141 size_t size; 142 if (!async_data_write_receive(&chandle, &size)) { 143 async_answer_0(chandle, EREFUSED); 144 async_answer_0(icall_handle, EREFUSED); 145 145 return; 146 146 } 147 147 148 148 if (size != sizeof(inet_addr_t)) { 149 async_answer_0(c allid, EINVAL);150 async_answer_0(i id, EINVAL);149 async_answer_0(chandle, EINVAL); 150 async_answer_0(icall_handle, EINVAL); 151 151 return; 152 152 } 153 153 154 154 inet_addr_t addr; 155 errno_t rc = async_data_write_finalize(c allid, &addr, size);156 if (rc != EOK) { 157 async_answer_0(c allid, rc);158 async_answer_0(i id, rc);155 errno_t rc = async_data_write_finalize(chandle, &addr, size); 156 if (rc != EOK) { 157 async_answer_0(chandle, rc); 158 async_answer_0(icall_handle, rc); 159 159 } 160 160 161 161 rc = srv->ops->addr_remove(srv, &addr); 162 async_answer_0(i id, rc);163 } 164 165 static void iplink_send_srv(iplink_srv_t *srv, cap_call_handle_t i id,162 async_answer_0(icall_handle, rc); 163 } 164 165 static void iplink_send_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle, 166 166 ipc_call_t *icall) 167 167 { … … 174 174 &sdu.size); 175 175 if (rc != EOK) { 176 async_answer_0(i id, rc);176 async_answer_0(icall_handle, rc); 177 177 return; 178 178 } … … 180 180 rc = srv->ops->send(srv, &sdu); 181 181 free(sdu.data); 182 async_answer_0(i id, rc);183 } 184 185 static void iplink_send6_srv(iplink_srv_t *srv, cap_call_handle_t i id,182 async_answer_0(icall_handle, rc); 183 } 184 185 static void iplink_send6_srv(iplink_srv_t *srv, cap_call_handle_t icall_handle, 186 186 ipc_call_t *icall) 187 187 { 188 188 iplink_sdu6_t sdu; 189 189 190 cap_call_handle_t c allid;191 size_t size; 192 if (!async_data_write_receive(&c allid, &size)) {193 async_answer_0(c allid, EREFUSED);194 async_answer_0(i id, EREFUSED);190 cap_call_handle_t chandle; 191 size_t size; 192 if (!async_data_write_receive(&chandle, &size)) { 193 async_answer_0(chandle, EREFUSED); 194 async_answer_0(icall_handle, EREFUSED); 195 195 return; 196 196 } 197 197 198 198 if (size != sizeof(addr48_t)) { 199 async_answer_0(c allid, EINVAL);200 async_answer_0(i id, EINVAL);201 return; 202 } 203 204 errno_t rc = async_data_write_finalize(c allid, &sdu.dest, size);205 if (rc != EOK) { 206 async_answer_0(c allid, rc);207 async_answer_0(i id, rc);199 async_answer_0(chandle, EINVAL); 200 async_answer_0(icall_handle, EINVAL); 201 return; 202 } 203 204 errno_t rc = async_data_write_finalize(chandle, &sdu.dest, size); 205 if (rc != EOK) { 206 async_answer_0(chandle, rc); 207 async_answer_0(icall_handle, rc); 208 208 } 209 209 … … 211 211 &sdu.size); 212 212 if (rc != EOK) { 213 async_answer_0(i id, rc);213 async_answer_0(icall_handle, rc); 214 214 return; 215 215 } … … 217 217 rc = srv->ops->send6(srv, &sdu); 218 218 free(sdu.data); 219 async_answer_0(i id, rc);219 async_answer_0(icall_handle, rc); 220 220 } 221 221 … … 229 229 } 230 230 231 errno_t iplink_conn(cap_call_handle_t i id, ipc_call_t *icall, void *arg)231 errno_t iplink_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg) 232 232 { 233 233 iplink_srv_t *srv = (iplink_srv_t *) arg; … … 237 237 if (srv->connected) { 238 238 fibril_mutex_unlock(&srv->lock); 239 async_answer_0(i id, EBUSY);239 async_answer_0(icall_handle, EBUSY); 240 240 return EBUSY; 241 241 } … … 245 245 246 246 /* Accept the connection */ 247 async_answer_0(i id, EOK);247 async_answer_0(icall_handle, EOK); 248 248 249 249 async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE); … … 259 259 while (true) { 260 260 ipc_call_t call; 261 cap_call_handle_t c allid= async_get_call(&call);261 cap_call_handle_t chandle = async_get_call(&call); 262 262 sysarg_t method = IPC_GET_IMETHOD(call); 263 263 … … 267 267 srv->connected = false; 268 268 fibril_mutex_unlock(&srv->lock); 269 async_answer_0(c allid, EOK);269 async_answer_0(chandle, EOK); 270 270 break; 271 271 } … … 273 273 switch (method) { 274 274 case IPLINK_GET_MTU: 275 iplink_get_mtu_srv(srv, c allid, &call);275 iplink_get_mtu_srv(srv, chandle, &call); 276 276 break; 277 277 case IPLINK_GET_MAC48: 278 iplink_get_mac48_srv(srv, c allid, &call);278 iplink_get_mac48_srv(srv, chandle, &call); 279 279 break; 280 280 case IPLINK_SET_MAC48: 281 iplink_set_mac48_srv(srv, c allid, &call);281 iplink_set_mac48_srv(srv, chandle, &call); 282 282 break; 283 283 case IPLINK_SEND: 284 iplink_send_srv(srv, c allid, &call);284 iplink_send_srv(srv, chandle, &call); 285 285 break; 286 286 case IPLINK_SEND6: 287 iplink_send6_srv(srv, c allid, &call);287 iplink_send6_srv(srv, chandle, &call); 288 288 break; 289 289 case IPLINK_ADDR_ADD: 290 iplink_addr_add_srv(srv, c allid, &call);290 iplink_addr_add_srv(srv, chandle, &call); 291 291 break; 292 292 case IPLINK_ADDR_REMOVE: 293 iplink_addr_remove_srv(srv, c allid, &call);293 iplink_addr_remove_srv(srv, chandle, &call); 294 294 break; 295 295 default: 296 async_answer_0(c allid, EINVAL);296 async_answer_0(chandle, EINVAL); 297 297 } 298 298 }
Note:
See TracChangeset
for help on using the changeset viewer.