Changeset a35b458 in mainline for uspace/srv/net/inetsrv/inet_link.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/inetsrv/inet_link.c
r3061bc1 ra35b458 154 154 if (ilink->svc_name != NULL) 155 155 free(ilink->svc_name); 156 156 157 157 free(ilink); 158 158 } … … 197 197 goto error; 198 198 } 199 199 200 200 /* 201 201 * Get the MAC address of the link. If the link has a MAC … … 221 221 222 222 inet_addrobj_t *addr = NULL; 223 223 224 224 /* XXX FIXME Cannot rely on loopback being the first IP link service!! */ 225 225 if (first_link) { 226 226 addr = inet_addrobj_new(); 227 227 228 228 inet_naddr(&addr->naddr, 127, 0, 0, 1, 24); 229 229 first_link = false; 230 230 } 231 231 232 232 if (addr != NULL) { 233 233 addr->ilink = ilink; 234 234 addr->name = str_dup("v4a"); 235 235 236 236 rc = inet_addrobj_add(addr); 237 237 if (rc == EOK) { … … 249 249 } 250 250 } 251 251 252 252 inet_addrobj_t *addr6 = NULL; 253 253 254 254 if (first_link6) { 255 255 addr6 = inet_addrobj_new(); 256 256 257 257 inet_naddr6(&addr6->naddr, 0, 0, 0, 0, 0, 0, 0, 1, 128); 258 258 first_link6 = false; 259 259 } else if (ilink->mac_valid) { 260 260 addr6 = inet_addrobj_new(); 261 261 262 262 addr128_t link_local; 263 263 inet_link_local_node_ip(ilink->mac, link_local); 264 264 265 265 inet_naddr_set6(link_local, 64, &addr6->naddr); 266 266 } 267 267 268 268 if (addr6 != NULL) { 269 269 addr6->ilink = ilink; 270 270 addr6->name = str_dup("v6a"); 271 271 272 272 rc = inet_addrobj_add(addr6); 273 273 if (rc == EOK) { … … 285 285 } 286 286 } 287 287 288 288 log_msg(LOG_DEFAULT, LVL_DEBUG, "Configured link '%s'.", ilink->svc_name); 289 289 return EOK; 290 290 291 291 error: 292 292 if (ilink->iplink != NULL) 293 293 iplink_close(ilink->iplink); 294 294 295 295 inet_link_delete(ilink); 296 296 return rc; … … 319 319 if (src_ver != ip_v4) 320 320 return EINVAL; 321 321 322 322 addr32_t dest_v4; 323 323 ip_ver_t dest_ver = inet_addr_get(&dgram->dest, &dest_v4, NULL); 324 324 if (dest_ver != ip_v4) 325 325 return EINVAL; 326 326 327 327 /* 328 328 * Fill packet structure. Fragmentation is performed by 329 329 * inet_pdu_encode(). 330 330 */ 331 331 332 332 iplink_sdu_t sdu; 333 333 334 334 sdu.src = lsrc; 335 335 sdu.dest = ldest; 336 336 337 337 inet_packet_t packet; 338 338 339 339 packet.src = dgram->src; 340 340 packet.dest = dgram->dest; … … 342 342 packet.proto = proto; 343 343 packet.ttl = ttl; 344 344 345 345 /* Allocate identifier */ 346 346 fibril_mutex_lock(&ip_ident_lock); 347 347 packet.ident = ++ip_ident; 348 348 fibril_mutex_unlock(&ip_ident_lock); 349 349 350 350 packet.df = df; 351 351 packet.data = dgram->data; 352 352 packet.size = dgram->size; 353 353 354 354 errno_t rc; 355 355 size_t offs = 0; 356 356 357 357 do { 358 358 /* Encode one fragment */ 359 359 360 360 size_t roffs; 361 361 rc = inet_pdu_encode(&packet, src_v4, dest_v4, offs, ilink->def_mtu, … … 363 363 if (rc != EOK) 364 364 return rc; 365 365 366 366 /* Send the PDU */ 367 367 rc = iplink_send(ilink->iplink, &sdu); 368 368 369 369 free(sdu.data); 370 370 offs = roffs; 371 371 } while (offs < packet.size); 372 372 373 373 return rc; 374 374 } … … 394 394 if (src_ver != ip_v6) 395 395 return EINVAL; 396 396 397 397 addr128_t dest_v6; 398 398 ip_ver_t dest_ver = inet_addr_get(&dgram->dest, NULL, &dest_v6); 399 399 if (dest_ver != ip_v6) 400 400 return EINVAL; 401 401 402 402 iplink_sdu6_t sdu6; 403 403 addr48(ldest, sdu6.dest); 404 404 405 405 /* 406 406 * Fill packet structure. Fragmentation is performed by 407 407 * inet_pdu_encode6(). 408 408 */ 409 409 410 410 inet_packet_t packet; 411 411 412 412 packet.src = dgram->src; 413 413 packet.dest = dgram->dest; … … 415 415 packet.proto = proto; 416 416 packet.ttl = ttl; 417 417 418 418 /* Allocate identifier */ 419 419 fibril_mutex_lock(&ip_ident_lock); 420 420 packet.ident = ++ip_ident; 421 421 fibril_mutex_unlock(&ip_ident_lock); 422 422 423 423 packet.df = df; 424 424 packet.data = dgram->data; 425 425 packet.size = dgram->size; 426 426 427 427 errno_t rc; 428 428 size_t offs = 0; 429 429 430 430 do { 431 431 /* Encode one fragment */ 432 432 433 433 size_t roffs; 434 434 rc = inet_pdu_encode6(&packet, src_v6, dest_v6, offs, ilink->def_mtu, … … 436 436 if (rc != EOK) 437 437 return rc; 438 438 439 439 /* Send the PDU */ 440 440 rc = iplink_send6(ilink->iplink, &sdu6); 441 441 442 442 free(sdu6.data); 443 443 offs = roffs; 444 444 } while (offs < packet.size); 445 445 446 446 return rc; 447 447 }
Note:
See TracChangeset
for help on using the changeset viewer.