… | |
… | |
529 | /* process data */ |
529 | /* process data */ |
530 | tap_packet *pkt; |
530 | tap_packet *pkt; |
531 | |
531 | |
532 | pkt = tap->recv (); |
532 | pkt = tap->recv (); |
533 | |
533 | |
|
|
534 | if (!pkt) |
|
|
535 | return; |
|
|
536 | |
|
|
537 | if (pkt->len > 14) |
|
|
538 | { |
534 | int dst = mac2id (pkt->dst); |
539 | int dst = mac2id (pkt->dst); |
535 | int src = mac2id (pkt->src); |
540 | int src = mac2id (pkt->src); |
536 | |
541 | |
537 | if (src != THISNODE->id) |
542 | if (src != THISNODE->id) |
538 | { |
|
|
539 | slog (L_ERR, _("FATAL: tap packet not originating on current node received, exiting.")); |
|
|
540 | exit (1); |
|
|
541 | } |
|
|
542 | |
|
|
543 | if (dst == THISNODE->id) |
|
|
544 | { |
|
|
545 | slog (L_ERR, _("FATAL: tap packet destined for current node received, exiting.")); |
|
|
546 | exit (1); |
|
|
547 | } |
|
|
548 | |
|
|
549 | if (dst > conns.size ()) |
|
|
550 | slog (L_ERR, _("tap packet for unknown node %d received, ignoring."), dst); |
|
|
551 | else |
|
|
552 | { |
|
|
553 | if (dst) |
|
|
554 | { |
543 | { |
555 | // unicast |
544 | slog (L_ERR, _("FATAL: tap packet not originating on current node received, exiting.")); |
556 | if (dst != THISNODE->id) |
545 | exit (1); |
557 | conns[dst - 1]->inject_data_packet (pkt); |
|
|
558 | } |
546 | } |
|
|
547 | |
|
|
548 | if (dst == THISNODE->id) |
|
|
549 | { |
|
|
550 | slog (L_ERR, _("FATAL: tap packet destined for current node received, exiting.")); |
|
|
551 | exit (1); |
|
|
552 | } |
|
|
553 | |
|
|
554 | if (dst > conns.size ()) |
|
|
555 | slog (L_ERR, _("tap packet for unknown node %d received, ignoring."), dst); |
559 | else |
556 | else |
560 | { |
557 | { |
|
|
558 | if (dst) |
|
|
559 | { |
|
|
560 | // unicast |
|
|
561 | if (dst != THISNODE->id) |
|
|
562 | conns[dst - 1]->inject_data_packet (pkt); |
|
|
563 | } |
|
|
564 | else |
|
|
565 | { |
561 | // broadcast, this is ugly, but due to the security policy |
566 | // broadcast, this is ugly, but due to the security policy |
562 | // we have to connect to all hosts... |
567 | // we have to connect to all hosts... |
563 | for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c) |
568 | for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c) |
564 | if ((*c)->conf != THISNODE) |
569 | if ((*c)->conf != THISNODE) |
565 | (*c)->inject_data_packet (pkt); |
570 | (*c)->inject_data_packet (pkt); |
|
|
571 | } |
566 | } |
572 | } |
567 | } |
573 | } |
568 | |
574 | |
569 | delete pkt; |
575 | delete pkt; |
570 | } |
576 | } |