Changes in uspace/lib/c/generic/iplink_srv.c [a17356fd:02a09ed] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink_srv.c
ra17356fd r02a09ed 50 50 } 51 51 52 static void iplink_ get_mac48_srv(iplink_srv_t *srv, ipc_callid_t iid,52 static void iplink_addr_add_srv(iplink_srv_t *srv, ipc_callid_t iid, 53 53 ipc_call_t *icall) 54 54 { 55 addr48_t mac;56 int rc = srv->ops->get_mac48(srv, &mac);57 if (rc != EOK) {58 async_answer_0(iid, rc);59 return;60 }61 62 55 ipc_callid_t callid; 63 56 size_t size; 64 if (!async_data_read_receive(&callid, &size)) { 65 async_answer_0(callid, EREFUSED); 66 async_answer_0(iid, EREFUSED); 67 return; 68 } 69 70 if (size != sizeof(addr48_t)) { 71 async_answer_0(callid, EINVAL); 72 async_answer_0(iid, EINVAL); 73 return; 74 } 75 76 rc = async_data_read_finalize(callid, &mac, size); 77 if (rc != EOK) 78 async_answer_0(callid, rc); 79 57 if (!async_data_write_receive(&callid, &size)) { 58 async_answer_0(callid, EREFUSED); 59 async_answer_0(iid, EREFUSED); 60 return; 61 } 62 63 if (size != sizeof(inet_addr_t)) { 64 async_answer_0(callid, EINVAL); 65 async_answer_0(iid, EINVAL); 66 return; 67 } 68 69 inet_addr_t addr; 70 int rc = async_data_write_finalize(callid, &addr, size); 71 if (rc != EOK) { 72 async_answer_0(callid, (sysarg_t) rc); 73 async_answer_0(iid, (sysarg_t) rc); 74 } 75 76 rc = srv->ops->addr_add(srv, &addr); 80 77 async_answer_0(iid, (sysarg_t) rc); 81 78 } 82 79 83 static void iplink_addr_ add_srv(iplink_srv_t *srv, ipc_callid_t iid,80 static void iplink_addr_remove_srv(iplink_srv_t *srv, ipc_callid_t iid, 84 81 ipc_call_t *icall) 85 82 { … … 105 102 } 106 103 107 rc = srv->ops->addr_ add(srv, &addr);104 rc = srv->ops->addr_remove(srv, &addr); 108 105 async_answer_0(iid, (sysarg_t) rc); 109 106 } 110 107 111 static void iplink_ addr_remove_srv(iplink_srv_t *srv, ipc_callid_t iid,108 static void iplink_send_srv(iplink_srv_t *srv, ipc_callid_t iid, 112 109 ipc_call_t *icall) 113 110 { 111 iplink_sdu_t sdu; 112 114 113 ipc_callid_t callid; 115 114 size_t size; … … 126 125 } 127 126 128 inet_addr_t addr; 129 int rc = async_data_write_finalize(callid, &addr, size); 130 if (rc != EOK) { 131 async_answer_0(callid, (sysarg_t) rc); 132 async_answer_0(iid, (sysarg_t) rc); 133 } 134 135 rc = srv->ops->addr_remove(srv, &addr); 136 async_answer_0(iid, (sysarg_t) rc); 137 } 138 139 static void iplink_send_srv(iplink_srv_t *srv, ipc_callid_t iid, 140 ipc_call_t *icall) 141 { 142 iplink_sdu_t sdu; 143 144 sdu.src = IPC_GET_ARG1(*icall); 145 sdu.dest = IPC_GET_ARG2(*icall); 146 147 int rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, 148 &sdu.size); 149 if (rc != EOK) { 150 async_answer_0(iid, rc); 151 return; 152 } 153 154 rc = srv->ops->send(srv, &sdu); 155 free(sdu.data); 156 async_answer_0(iid, rc); 157 } 158 159 static void iplink_send6_srv(iplink_srv_t *srv, ipc_callid_t iid, 160 ipc_call_t *icall) 161 { 162 iplink_sdu6_t sdu; 163 164 ipc_callid_t callid; 165 size_t size; 166 if (!async_data_write_receive(&callid, &size)) { 167 async_answer_0(callid, EREFUSED); 168 async_answer_0(iid, EREFUSED); 169 return; 170 } 171 172 if (size != sizeof(addr48_t)) { 173 async_answer_0(callid, EINVAL); 174 async_answer_0(iid, EINVAL); 175 return; 176 } 177 178 int rc = async_data_write_finalize(callid, &sdu.dest, size); 127 int rc = async_data_write_finalize(callid, &sdu.src, size); 128 if (rc != EOK) { 129 async_answer_0(callid, (sysarg_t) rc); 130 async_answer_0(iid, (sysarg_t) rc); 131 } 132 133 if (!async_data_write_receive(&callid, &size)) { 134 async_answer_0(callid, EREFUSED); 135 async_answer_0(iid, EREFUSED); 136 return; 137 } 138 139 if (size != sizeof(inet_addr_t)) { 140 async_answer_0(callid, EINVAL); 141 async_answer_0(iid, EINVAL); 142 return; 143 } 144 145 rc = async_data_write_finalize(callid, &sdu.dest, size); 179 146 if (rc != EOK) { 180 147 async_answer_0(callid, (sysarg_t) rc); … … 184 151 rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, 185 152 &sdu.size); 186 if (rc != EOK) { 187 async_answer_0(iid, rc); 188 return; 189 } 190 191 rc = srv->ops->send6(srv, &sdu); 153 if (rc != EOK) 154 return; 155 156 rc = srv->ops->send(srv, &sdu); 192 157 free(sdu.data); 193 158 async_answer_0(iid, rc); … … 205 170 int iplink_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 206 171 { 207 iplink_srv_t *srv = (iplink_srv_t *) 172 iplink_srv_t *srv = (iplink_srv_t *)arg; 208 173 int rc; 209 174 … … 249 214 iplink_get_mtu_srv(srv, callid, &call); 250 215 break; 251 case IPLINK_GET_MAC48:252 iplink_get_mac48_srv(srv, callid, &call);253 break;254 216 case IPLINK_SEND: 255 217 iplink_send_srv(srv, callid, &call); 256 break;257 case IPLINK_SEND6:258 iplink_send6_srv(srv, callid, &call);259 218 break; 260 219 case IPLINK_ADDR_ADD:
Note:
See TracChangeset
for help on using the changeset viewer.