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