Changeset a35b458 in mainline for uspace/srv/net/loopip/loopip.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/srv/net/loopip/loopip.c
r3061bc1 ra35b458 77 77 typedef struct { 78 78 link_t link; 79 79 80 80 /* XXX Version should be part of SDU */ 81 81 ip_ver_t ver; … … 90 90 rqueue_entry_t *rqe = 91 91 list_get_instance(link, rqueue_entry_t, link); 92 92 93 93 (void) iplink_ev_recv(&loopip_iplink, &rqe->sdu, rqe->ver); 94 94 95 95 free(rqe->sdu.data); 96 96 free(rqe); 97 97 } 98 98 99 99 return 0; 100 100 } … … 103 103 { 104 104 async_set_fallback_port_handler(loopip_client_conn, NULL); 105 105 106 106 errno_t rc = loc_server_register(NAME); 107 107 if (rc != EOK) { … … 109 109 return rc; 110 110 } 111 111 112 112 iplink_srv_init(&loopip_iplink); 113 113 loopip_iplink.ops = &loopip_iplink_ops; 114 114 loopip_iplink.arg = NULL; 115 115 116 116 prodcons_initialize(&loopip_rcv_queue); 117 117 118 118 const char *svc_name = "net/loopback"; 119 119 service_id_t sid; … … 124 124 return rc; 125 125 } 126 126 127 127 category_id_t iplink_cat; 128 128 rc = loc_category_get_id("iplink", &iplink_cat, IPC_FLAG_BLOCKING); … … 131 131 return rc; 132 132 } 133 133 134 134 rc = loc_service_add_to_cat(sid, iplink_cat); 135 135 if (rc != EOK) { … … 138 138 return rc; 139 139 } 140 140 141 141 fid_t fid = fibril_create(loopip_recv_fibril, NULL); 142 142 if (fid == 0) 143 143 return ENOMEM; 144 144 145 145 fibril_add_ready(fid); 146 146 147 147 return EOK; 148 148 } … … 169 169 { 170 170 log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip_send()"); 171 171 172 172 rqueue_entry_t *rqe = calloc(1, sizeof(rqueue_entry_t)); 173 173 if (rqe == NULL) 174 174 return ENOMEM; 175 175 176 176 /* 177 177 * Clone SDU … … 183 183 return ENOMEM; 184 184 } 185 185 186 186 memcpy(rqe->sdu.data, sdu->data, sdu->size); 187 187 rqe->sdu.size = sdu->size; 188 188 189 189 /* 190 190 * Insert to receive queue 191 191 */ 192 192 prodcons_produce(&loopip_rcv_queue, &rqe->link); 193 193 194 194 return EOK; 195 195 } … … 198 198 { 199 199 log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip6_send()"); 200 200 201 201 rqueue_entry_t *rqe = calloc(1, sizeof(rqueue_entry_t)); 202 202 if (rqe == NULL) 203 203 return ENOMEM; 204 204 205 205 /* 206 206 * Clone SDU … … 212 212 return ENOMEM; 213 213 } 214 214 215 215 memcpy(rqe->sdu.data, sdu->data, sdu->size); 216 216 rqe->sdu.size = sdu->size; 217 217 218 218 /* 219 219 * Insert to receive queue 220 220 */ 221 221 prodcons_produce(&loopip_rcv_queue, &rqe->link); 222 222 223 223 return EOK; 224 224 } … … 250 250 { 251 251 printf("%s: HelenOS loopback IP link provider\n", NAME); 252 252 253 253 errno_t rc = log_init(NAME); 254 254 if (rc != EOK) { … … 256 256 return rc; 257 257 } 258 258 259 259 rc = loopip_init(); 260 260 if (rc != EOK) { … … 262 262 return rc; 263 263 } 264 264 265 265 printf("%s: Accepting connections.\n", NAME); 266 266 task_retval(0); 267 267 async_manager(); 268 268 269 269 /* Not reached */ 270 270 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.