2 * This file is free software: you may copy, redistribute and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation, either version 2 of the License, or (at your
5 * option) any later version.
7 * This file is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 * This file incorporates work covered by the following copyright and
19 Copyright (c) 2007, 2008 by Juliusz Chroboczek
21 Permission is hereby granted, free of charge, to any person obtaining a copy
22 of this software and associated documentation files (the "Software"), to deal
23 in the Software without restriction, including without limitation the rights
24 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25 copies of the Software, and to permit persons to whom the Software is
26 furnished to do so, subject to the following conditions:
28 The above copyright notice and this permission notice shall be included in
29 all copies or substantial portions of the Software.
31 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
45 #include <netinet/in.h>
46 #include <arpa/inet.h>
54 #include "babel_interface.h"
56 #include "neighbour.h"
63 unsigned char packet_header
[4] = {42, 2};
66 int split_horizon
= 1;
68 unsigned short myseqno
= 0;
69 struct timeval seqno_time
= {0, 0};
71 #define UNICAST_BUFSIZE 1024
72 int unicast_buffered
= 0;
73 unsigned char *unicast_buffer
= NULL
;
74 struct neighbour
*unicast_neighbour
= NULL
;
75 struct timeval unicast_flush_timeout
= {0, 0};
77 static const unsigned char v4prefix
[16] =
78 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
81 network_prefix(int ae
, int plen
, unsigned int omitted
,
82 const unsigned char *p
, const unsigned char *dp
,
83 unsigned int len
, unsigned char *p_r
)
86 unsigned char prefix
[16];
98 memset(prefix
, 0, 16);
103 if(omitted
> 4 || pb
> 4 || (pb
> omitted
&& len
< pb
- omitted
))
105 memcpy(prefix
, v4prefix
, 12);
107 if (dp
== NULL
|| !v4mapped(dp
)) return -1;
108 memcpy(prefix
, dp
, 12 + omitted
);
110 if(pb
> omitted
) memcpy(prefix
+ 12 + omitted
, p
, pb
- omitted
);
113 if(omitted
> 16 || (pb
> omitted
&& len
< pb
- omitted
)) return -1;
115 if (dp
== NULL
|| v4mapped(dp
)) return -1;
116 memcpy(prefix
, dp
, omitted
);
118 if(pb
> omitted
) memcpy(prefix
+ omitted
, p
, pb
- omitted
);
121 if(pb
> 8 && len
< pb
- 8) return -1;
124 if(pb
> 8) memcpy(prefix
+ 8, p
, pb
- 8);
130 mask_prefix(p_r
, prefix
, plen
< 0 ? 128 : ae
== 1 ? plen
+ 96 : plen
);
135 network_address(int ae
, const unsigned char *a
, unsigned int len
,
138 return network_prefix(ae
, -1, 0, a
, NULL
, len
, a_r
);
142 parse_packet(const unsigned char *from
, struct interface
*ifp
,
143 const unsigned char *packet
, int packetlen
)
146 const unsigned char *message
;
147 unsigned char type
, len
;
149 struct neighbour
*neigh
;
150 int have_router_id
= 0, have_v4_prefix
= 0, have_v6_prefix
= 0,
151 have_v4_nh
= 0, have_v6_nh
= 0;
152 unsigned char router_id
[8], v4_prefix
[16], v6_prefix
[16],
153 v4_nh
[16], v6_nh
[16];
155 if(!linklocal(from
)) {
156 fprintf(stderr
, "Received packet from non-local address %s.\n",
157 format_address(from
));
161 if(packet
[0] != 42) {
162 fprintf(stderr
, "Received malformed packet on %s from %s.\n",
163 ifp
->name
, format_address(from
));
169 "Received packet with unknown version %d on %s from %s.\n",
170 packet
[1], ifp
->name
, format_address(from
));
174 neigh
= find_neighbour(from
, ifp
);
176 fprintf(stderr
, "Couldn't allocate neighbour.\n");
180 DO_NTOHS(bodylen
, packet
+ 2);
182 if(bodylen
+ 4 > packetlen
) {
183 fprintf(stderr
, "Received truncated packet (%d + 4 > %d).\n",
185 bodylen
= packetlen
- 4;
190 message
= packet
+ 4 + i
;
192 if(type
== MESSAGE_PAD1
) {
193 debugf(BABEL_DEBUG_COMMON
,"Received pad1 from %s on %s.",
194 format_address(from
), ifp
->name
);
198 if(i
+ 1 > bodylen
) {
199 fprintf(stderr
, "Received truncated message.\n");
203 if(i
+ len
> bodylen
) {
204 fprintf(stderr
, "Received truncated message.\n");
208 if(type
== MESSAGE_PADN
) {
209 debugf(BABEL_DEBUG_COMMON
,"Received pad%d from %s on %s.",
210 len
, format_address(from
), ifp
->name
);
211 } else if(type
== MESSAGE_ACK_REQ
) {
212 unsigned short nonce
, interval
;
213 if(len
< 6) goto fail
;
214 DO_NTOHS(nonce
, message
+ 4);
215 DO_NTOHS(interval
, message
+ 6);
216 debugf(BABEL_DEBUG_COMMON
,"Received ack-req (%04X %d) from %s on %s.",
217 nonce
, interval
, format_address(from
), ifp
->name
);
218 send_ack(neigh
, nonce
, interval
);
219 } else if(type
== MESSAGE_ACK
) {
220 debugf(BABEL_DEBUG_COMMON
,"Received ack from %s on %s.",
221 format_address(from
), ifp
->name
);
222 /* Nothing right now */
223 } else if(type
== MESSAGE_HELLO
) {
224 unsigned short seqno
, interval
;
226 if(len
< 6) goto fail
;
227 DO_NTOHS(seqno
, message
+ 4);
228 DO_NTOHS(interval
, message
+ 6);
229 debugf(BABEL_DEBUG_COMMON
,"Received hello %d (%d) from %s on %s.",
231 format_address(from
), ifp
->name
);
232 babel_get_if_nfo(ifp
)->activity_time
= babel_now
.tv_sec
;
233 changed
= update_neighbour(neigh
, seqno
, interval
);
234 update_neighbour_metric(neigh
, changed
);
236 schedule_neighbours_check(interval
* 10, 0);
237 } else if(type
== MESSAGE_IHU
) {
238 unsigned short txcost
, interval
;
239 unsigned char address
[16];
241 if(len
< 6) goto fail
;
242 DO_NTOHS(txcost
, message
+ 4);
243 DO_NTOHS(interval
, message
+ 6);
244 rc
= network_address(message
[2], message
+ 8, len
- 6, address
);
245 if(rc
< 0) goto fail
;
246 debugf(BABEL_DEBUG_COMMON
,"Received ihu %d (%d) from %s on %s for %s.",
248 format_address(from
), ifp
->name
,
249 format_address(address
));
250 if(message
[2] == 0 || is_interface_ll_address(ifp
, address
)) {
251 int changed
= txcost
!= neigh
->txcost
;
252 neigh
->txcost
= txcost
;
253 neigh
->ihu_time
= babel_now
;
254 neigh
->ihu_interval
= interval
;
255 update_neighbour_metric(neigh
, changed
);
257 schedule_neighbours_check(interval
* 10 * 3, 0);
259 } else if(type
== MESSAGE_ROUTER_ID
) {
264 memcpy(router_id
, message
+ 4, 8);
266 debugf(BABEL_DEBUG_COMMON
,"Received router-id %s from %s on %s.",
267 format_eui64(router_id
), format_address(from
), ifp
->name
);
268 } else if(type
== MESSAGE_NH
) {
269 unsigned char nh
[16];
276 rc
= network_address(message
[2], message
+ 4, len
- 2,
283 debugf(BABEL_DEBUG_COMMON
,"Received nh %s (%d) from %s on %s.",
284 format_address(nh
), message
[2],
285 format_address(from
), ifp
->name
);
286 if(message
[2] == 1) {
287 memcpy(v4_nh
, nh
, 16);
290 memcpy(v6_nh
, nh
, 16);
293 } else if(type
== MESSAGE_UPDATE
) {
294 unsigned char prefix
[16], *nh
;
296 unsigned short interval
, seqno
, metric
;
299 if(len
< 2 || message
[3] & 0x80)
300 have_v4_prefix
= have_v6_prefix
= 0;
303 DO_NTOHS(interval
, message
+ 6);
304 DO_NTOHS(seqno
, message
+ 8);
305 DO_NTOHS(metric
, message
+ 10);
306 if(message
[5] == 0 ||
307 (message
[3] == 1 ? have_v4_prefix
: have_v6_prefix
))
308 rc
= network_prefix(message
[2], message
[4], message
[5],
310 message
[2] == 1 ? v4_prefix
: v6_prefix
,
315 if(message
[3] & 0x80)
316 have_v4_prefix
= have_v6_prefix
= 0;
320 plen
= message
[4] + (message
[2] == 1 ? 96 : 0);
322 if(message
[3] & 0x80) {
323 if(message
[2] == 1) {
324 memcpy(v4_prefix
, prefix
, 16);
327 memcpy(v6_prefix
, prefix
, 16);
331 if(message
[3] & 0x40) {
332 if(message
[2] == 1) {
333 memset(router_id
, 0, 4);
334 memcpy(router_id
+ 4, prefix
+ 12, 4);
336 memcpy(router_id
, prefix
+ 8, 8);
340 if(!have_router_id
&& message
[2] != 0) {
341 fprintf(stderr
, "Received prefix with no router id.\n");
344 debugf(BABEL_DEBUG_COMMON
,"Received update%s%s for %s from %s on %s.",
345 (message
[3] & 0x80) ? "/prefix" : "",
346 (message
[3] & 0x40) ? "/id" : "",
347 format_prefix(prefix
, plen
),
348 format_address(from
), ifp
->name
);
350 if(message
[2] == 0) {
351 if(metric
< 0xFFFF) {
353 "Received wildcard update with finite metric.\n");
356 retract_neighbour_routes(neigh
);
358 } else if(message
[2] == 1) {
362 } else if(have_v6_nh
) {
368 if(message
[2] == 1) {
369 if(!babel_get_if_nfo(ifp
)->ipv4
)
373 update_route(router_id
, prefix
, plen
, seqno
, metric
, interval
,
375 } else if(type
== MESSAGE_REQUEST
) {
376 unsigned char prefix
[16], plen
;
378 if(len
< 2) goto fail
;
379 rc
= network_prefix(message
[2], message
[3], 0,
380 message
+ 4, NULL
, len
- 2, prefix
);
381 if(rc
< 0) goto fail
;
382 plen
= message
[3] + (message
[2] == 1 ? 96 : 0);
383 debugf(BABEL_DEBUG_COMMON
,"Received request for %s from %s on %s.",
384 message
[2] == 0 ? "any" : format_prefix(prefix
, plen
),
385 format_address(from
), ifp
->name
);
386 if(message
[2] == 0) {
387 /* If a neighbour is requesting a full route dump from us,
388 we might as well send it an IHU. */
389 send_ihu(neigh
, NULL
);
390 send_update(neigh
->ifp
, 0, NULL
, 0);
392 send_update(neigh
->ifp
, 0, prefix
, plen
);
394 } else if(type
== MESSAGE_MH_REQUEST
) {
395 unsigned char prefix
[16], plen
;
396 unsigned short seqno
;
398 if(len
< 14) goto fail
;
399 DO_NTOHS(seqno
, message
+ 4);
400 rc
= network_prefix(message
[2], message
[3], 0,
401 message
+ 16, NULL
, len
- 14, prefix
);
402 if(rc
< 0) goto fail
;
403 plen
= message
[3] + (message
[2] == 1 ? 96 : 0);
404 debugf(BABEL_DEBUG_COMMON
,"Received request (%d) for %s from %s on %s (%s, %d).",
406 format_prefix(prefix
, plen
),
407 format_address(from
), ifp
->name
,
408 format_eui64(message
+ 8), seqno
);
409 handle_request(neigh
, prefix
, plen
, message
[6],
412 debugf(BABEL_DEBUG_COMMON
,"Received unknown packet type %d from %s on %s.",
413 type
, format_address(from
), ifp
->name
);
420 fprintf(stderr
, "Couldn't parse packet (%d, %d) from %s on %s.\n",
421 message
[0], message
[1], format_address(from
), ifp
->name
);
427 /* Under normal circumstances, there are enough moderation mechanisms
428 elsewhere in the protocol to make sure that this last-ditch check
429 should never trigger. But I'm superstitious. */
432 check_bucket(struct interface
*ifp
)
434 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
435 if(babel_ifp
->bucket
<= 0) {
436 int seconds
= babel_now
.tv_sec
- babel_ifp
->bucket_time
;
438 babel_ifp
->bucket
= MIN(BUCKET_TOKENS_MAX
,
439 seconds
* BUCKET_TOKENS_PER_SEC
);
441 /* Reset bucket time unconditionally, in case clock is stepped. */
442 babel_ifp
->bucket_time
= babel_now
.tv_sec
;
445 if(babel_ifp
->bucket
> 0) {
454 flushbuf(struct interface
*ifp
)
457 struct sockaddr_in6 sin6
;
458 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
460 assert(babel_ifp
->buffered
<= babel_ifp
->bufsize
);
464 if(babel_ifp
->buffered
> 0) {
465 debugf(BABEL_DEBUG_COMMON
," (flushing %d buffered bytes on %s)",
466 babel_ifp
->buffered
, ifp
->name
);
467 if(check_bucket(ifp
)) {
468 memset(&sin6
, 0, sizeof(sin6
));
469 sin6
.sin6_family
= AF_INET6
;
470 memcpy(&sin6
.sin6_addr
, protocol_group
, 16);
471 sin6
.sin6_port
= htons(protocol_port
);
472 sin6
.sin6_scope_id
= ifp
->ifindex
;
473 DO_HTONS(packet_header
+ 2, babel_ifp
->buffered
);
474 rc
= babel_send(protocol_socket
,
475 packet_header
, sizeof(packet_header
),
476 babel_ifp
->sendbuf
, babel_ifp
->buffered
,
477 (struct sockaddr
*)&sin6
, sizeof(sin6
));
479 zlog_err("send: %s", safe_strerror(errno
));
481 fprintf(stderr
, "Warning: bucket full, dropping packet to %s.\n",
485 VALGRIND_MAKE_MEM_UNDEFINED(babel_ifp
->sendbuf
, babel_ifp
->bufsize
);
486 babel_ifp
->buffered
= 0;
487 babel_ifp
->have_buffered_hello
= 0;
488 babel_ifp
->have_buffered_id
= 0;
489 babel_ifp
->have_buffered_nh
= 0;
490 babel_ifp
->have_buffered_prefix
= 0;
491 babel_ifp
->flush_timeout
.tv_sec
= 0;
492 babel_ifp
->flush_timeout
.tv_usec
= 0;
496 schedule_flush(struct interface
*ifp
)
498 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
499 unsigned msecs
= jitter(babel_ifp
, 0);
500 if(babel_ifp
->flush_timeout
.tv_sec
!= 0 &&
501 timeval_minus_msec(&babel_ifp
->flush_timeout
, &babel_now
) < msecs
)
503 set_timeout(&babel_ifp
->flush_timeout
, msecs
);
507 schedule_flush_now(struct interface
*ifp
)
509 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
511 unsigned msecs
= roughly(10);
512 if(babel_ifp
->flush_timeout
.tv_sec
!= 0 &&
513 timeval_minus_msec(&babel_ifp
->flush_timeout
, &babel_now
) < msecs
)
515 set_timeout(&babel_ifp
->flush_timeout
, msecs
);
519 schedule_unicast_flush(unsigned msecs
)
521 if(!unicast_neighbour
)
523 if(unicast_flush_timeout
.tv_sec
!= 0 &&
524 timeval_minus_msec(&unicast_flush_timeout
, &babel_now
) < msecs
)
526 unicast_flush_timeout
.tv_usec
= (babel_now
.tv_usec
+ msecs
* 1000) %1000000;
527 unicast_flush_timeout
.tv_sec
=
528 babel_now
.tv_sec
+ (babel_now
.tv_usec
/ 1000 + msecs
) / 1000;
532 ensure_space(struct interface
*ifp
, int space
)
534 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
535 if(babel_ifp
->bufsize
- babel_ifp
->buffered
< space
)
540 start_message(struct interface
*ifp
, int type
, int len
)
542 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
543 if(babel_ifp
->bufsize
- babel_ifp
->buffered
< len
+ 2)
545 babel_ifp
->sendbuf
[babel_ifp
->buffered
++] = type
;
546 babel_ifp
->sendbuf
[babel_ifp
->buffered
++] = len
;
550 end_message(struct interface
*ifp
, int type
, int bytes
)
552 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
553 assert(babel_ifp
->buffered
>= bytes
+ 2 &&
554 babel_ifp
->sendbuf
[babel_ifp
->buffered
- bytes
- 2] == type
&&
555 babel_ifp
->sendbuf
[babel_ifp
->buffered
- bytes
- 1] == bytes
);
560 accumulate_byte(struct interface
*ifp
, unsigned char value
)
562 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
563 babel_ifp
->sendbuf
[babel_ifp
->buffered
++] = value
;
567 accumulate_short(struct interface
*ifp
, unsigned short value
)
569 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
570 DO_HTONS(babel_ifp
->sendbuf
+ babel_ifp
->buffered
, value
);
571 babel_ifp
->buffered
+= 2;
575 accumulate_bytes(struct interface
*ifp
,
576 const unsigned char *value
, unsigned len
)
578 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
579 memcpy(babel_ifp
->sendbuf
+ babel_ifp
->buffered
, value
, len
);
580 babel_ifp
->buffered
+= len
;
584 start_unicast_message(struct neighbour
*neigh
, int type
, int len
)
586 if(unicast_neighbour
) {
587 if(neigh
!= unicast_neighbour
||
588 unicast_buffered
+ len
+ 2 >=
589 MIN(UNICAST_BUFSIZE
, babel_get_if_nfo(neigh
->ifp
)->bufsize
))
593 unicast_buffer
= malloc(UNICAST_BUFSIZE
);
594 if(!unicast_buffer
) {
595 zlog_err("malloc(unicast_buffer): %s", safe_strerror(errno
));
599 unicast_neighbour
= neigh
;
601 unicast_buffer
[unicast_buffered
++] = type
;
602 unicast_buffer
[unicast_buffered
++] = len
;
607 end_unicast_message(struct neighbour
*neigh
, int type
, int bytes
)
609 assert(unicast_neighbour
== neigh
&& unicast_buffered
>= bytes
+ 2 &&
610 unicast_buffer
[unicast_buffered
- bytes
- 2] == type
&&
611 unicast_buffer
[unicast_buffered
- bytes
- 1] == bytes
);
612 schedule_unicast_flush(jitter(babel_get_if_nfo(neigh
->ifp
), 0));
616 accumulate_unicast_byte(struct neighbour
*neigh
, unsigned char value
)
618 unicast_buffer
[unicast_buffered
++] = value
;
622 accumulate_unicast_short(struct neighbour
*neigh
, unsigned short value
)
624 DO_HTONS(unicast_buffer
+ unicast_buffered
, value
);
625 unicast_buffered
+= 2;
629 accumulate_unicast_bytes(struct neighbour
*neigh
,
630 const unsigned char *value
, unsigned len
)
632 memcpy(unicast_buffer
+ unicast_buffered
, value
, len
);
633 unicast_buffered
+= len
;
637 send_ack(struct neighbour
*neigh
, unsigned short nonce
, unsigned short interval
)
640 debugf(BABEL_DEBUG_COMMON
,"Sending ack (%04x) to %s on %s.",
641 nonce
, format_address(neigh
->address
), neigh
->ifp
->name
);
642 rc
= start_unicast_message(neigh
, MESSAGE_ACK
, 2); if(rc
< 0) return;
643 accumulate_unicast_short(neigh
, nonce
);
644 end_unicast_message(neigh
, MESSAGE_ACK
, 2);
645 /* Roughly yields a value no larger than 3/2, so this meets the deadline */
646 schedule_unicast_flush(roughly(interval
* 6));
650 send_hello_noupdate(struct interface
*ifp
, unsigned interval
)
652 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
653 /* This avoids sending multiple hellos in a single packet, which breaks
654 link quality estimation. */
655 if(babel_ifp
->have_buffered_hello
)
658 babel_ifp
->hello_seqno
= seqno_plus(babel_ifp
->hello_seqno
, 1);
659 set_timeout(&babel_ifp
->hello_timeout
, babel_ifp
->hello_interval
);
664 debugf(BABEL_DEBUG_COMMON
,"Sending hello %d (%d) to %s.",
665 babel_ifp
->hello_seqno
, interval
, ifp
->name
);
667 start_message(ifp
, MESSAGE_HELLO
, 6);
668 accumulate_short(ifp
, 0);
669 accumulate_short(ifp
, babel_ifp
->hello_seqno
);
670 accumulate_short(ifp
, interval
> 0xFFFF ? 0xFFFF : interval
);
671 end_message(ifp
, MESSAGE_HELLO
, 6);
672 babel_ifp
->have_buffered_hello
= 1;
676 send_hello(struct interface
*ifp
)
678 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
679 send_hello_noupdate(ifp
, (babel_ifp
->hello_interval
+ 9) / 10);
680 /* Send full IHU every 3 hellos, and marginal IHU each time */
681 if(babel_ifp
->hello_seqno
% 3 == 0)
684 send_marginal_ihu(ifp
);
688 flush_unicast(int dofree
)
690 struct sockaddr_in6 sin6
;
693 if(unicast_buffered
== 0)
696 if(!if_up(unicast_neighbour
->ifp
))
699 /* Preserve ordering of messages */
700 flushbuf(unicast_neighbour
->ifp
);
702 if(check_bucket(unicast_neighbour
->ifp
)) {
703 memset(&sin6
, 0, sizeof(sin6
));
704 sin6
.sin6_family
= AF_INET6
;
705 memcpy(&sin6
.sin6_addr
, unicast_neighbour
->address
, 16);
706 sin6
.sin6_port
= htons(protocol_port
);
707 sin6
.sin6_scope_id
= unicast_neighbour
->ifp
->ifindex
;
708 DO_HTONS(packet_header
+ 2, unicast_buffered
);
709 rc
= babel_send(protocol_socket
,
710 packet_header
, sizeof(packet_header
),
711 unicast_buffer
, unicast_buffered
,
712 (struct sockaddr
*)&sin6
, sizeof(sin6
));
714 zlog_err("send(unicast): %s", safe_strerror(errno
));
717 "Warning: bucket full, dropping unicast packet"
719 format_address(unicast_neighbour
->address
),
720 unicast_neighbour
->ifp
->name
);
724 VALGRIND_MAKE_MEM_UNDEFINED(unicast_buffer
, UNICAST_BUFSIZE
);
725 unicast_buffered
= 0;
726 if(dofree
&& unicast_buffer
) {
727 free(unicast_buffer
);
728 unicast_buffer
= NULL
;
730 unicast_neighbour
= NULL
;
731 unicast_flush_timeout
.tv_sec
= 0;
732 unicast_flush_timeout
.tv_usec
= 0;
736 really_send_update(struct interface
*ifp
,
737 const unsigned char *id
,
738 const unsigned char *prefix
, unsigned char plen
,
739 unsigned short seqno
, unsigned short metric
)
741 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
742 int add_metric
, v4
, real_plen
, omit
= 0;
743 const unsigned char *real_prefix
;
744 unsigned short flags
= 0;
749 add_metric
= output_filter(id
, prefix
, plen
, ifp
->ifindex
);
750 if(add_metric
>= INFINITY
)
753 metric
= MIN(metric
+ add_metric
, INFINITY
);
755 ensure_space(ifp
, 20 + 12 + 28);
757 v4
= plen
>= 96 && v4mapped(prefix
);
762 if(!babel_ifp
->have_buffered_nh
||
763 memcmp(babel_ifp
->buffered_nh
, babel_ifp
->ipv4
, 4) != 0) {
764 start_message(ifp
, MESSAGE_NH
, 6);
765 accumulate_byte(ifp
, 1);
766 accumulate_byte(ifp
, 0);
767 accumulate_bytes(ifp
, babel_ifp
->ipv4
, 4);
768 end_message(ifp
, MESSAGE_NH
, 6);
769 memcpy(babel_ifp
->buffered_nh
, babel_ifp
->ipv4
, 4);
770 babel_ifp
->have_buffered_nh
= 1;
773 real_prefix
= prefix
+ 12;
774 real_plen
= plen
- 96;
776 if(babel_ifp
->have_buffered_prefix
) {
777 while(omit
< plen
/ 8 &&
778 babel_ifp
->buffered_prefix
[omit
] == prefix
[omit
])
781 if(!babel_ifp
->have_buffered_prefix
|| plen
>= 48)
783 real_prefix
= prefix
;
787 if(!babel_ifp
->have_buffered_id
788 || memcmp(id
, babel_ifp
->buffered_id
, 8) != 0) {
789 if(real_plen
== 128 && memcmp(real_prefix
+ 8, id
, 8) == 0) {
792 start_message(ifp
, MESSAGE_ROUTER_ID
, 10);
793 accumulate_short(ifp
, 0);
794 accumulate_bytes(ifp
, id
, 8);
795 end_message(ifp
, MESSAGE_ROUTER_ID
, 10);
797 memcpy(babel_ifp
->buffered_id
, id
, 16);
798 babel_ifp
->have_buffered_id
= 1;
801 start_message(ifp
, MESSAGE_UPDATE
, 10 + (real_plen
+ 7) / 8 - omit
);
802 accumulate_byte(ifp
, v4
? 1 : 2);
803 accumulate_byte(ifp
, flags
);
804 accumulate_byte(ifp
, real_plen
);
805 accumulate_byte(ifp
, omit
);
806 accumulate_short(ifp
, (babel_ifp
->update_interval
+ 5) / 10);
807 accumulate_short(ifp
, seqno
);
808 accumulate_short(ifp
, metric
);
809 accumulate_bytes(ifp
, real_prefix
+ omit
, (real_plen
+ 7) / 8 - omit
);
810 end_message(ifp
, MESSAGE_UPDATE
, 10 + (real_plen
+ 7) / 8 - omit
);
813 memcpy(babel_ifp
->buffered_prefix
, prefix
, 16);
814 babel_ifp
->have_buffered_prefix
= 1;
819 compare_buffered_updates(const void *av
, const void *bv
)
821 const struct buffered_update
*a
= av
, *b
= bv
;
822 int rc
, v4a
, v4b
, ma
, mb
;
824 rc
= memcmp(a
->id
, b
->id
, 8);
828 v4a
= (a
->plen
>= 96 && v4mapped(a
->prefix
));
829 v4b
= (b
->plen
>= 96 && v4mapped(b
->prefix
));
836 ma
= (!v4a
&& a
->plen
== 128 && memcmp(a
->prefix
+ 8, a
->id
, 8) == 0);
837 mb
= (!v4b
&& b
->plen
== 128 && memcmp(b
->prefix
+ 8, b
->id
, 8) == 0);
844 if(a
->plen
< b
->plen
)
846 else if(a
->plen
> b
->plen
)
849 return memcmp(a
->prefix
, b
->prefix
, 16);
853 flushupdates(struct interface
*ifp
)
855 babel_interface_nfo
*babel_ifp
= NULL
;
856 struct xroute
*xroute
;
858 const unsigned char *last_prefix
= NULL
;
859 unsigned char last_plen
= 0xFF;
863 struct interface
*ifp_aux
;
864 struct listnode
*linklist_node
= NULL
;
865 FOR_ALL_INTERFACES(ifp_aux
, linklist_node
)
866 flushupdates(ifp_aux
);
870 babel_ifp
= babel_get_if_nfo(ifp
);
871 if(babel_ifp
->num_buffered_updates
> 0) {
872 struct buffered_update
*b
= babel_ifp
->buffered_updates
;
873 int n
= babel_ifp
->num_buffered_updates
;
875 babel_ifp
->buffered_updates
= NULL
;
876 babel_ifp
->update_bufsize
= 0;
877 babel_ifp
->num_buffered_updates
= 0;
882 debugf(BABEL_DEBUG_COMMON
," (flushing %d buffered updates on %s (%d))",
883 n
, ifp
->name
, ifp
->ifindex
);
885 /* In order to send fewer update messages, we want to send updates
886 with the same router-id together, with IPv6 going out before IPv4. */
888 for(i
= 0; i
< n
; i
++) {
889 route
= find_installed_route(b
[i
].prefix
, b
[i
].plen
);
891 memcpy(b
[i
].id
, route
->src
->id
, 8);
893 memcpy(b
[i
].id
, myid
, 8);
896 qsort(b
, n
, sizeof(struct buffered_update
), compare_buffered_updates
);
898 for(i
= 0; i
< n
; i
++) {
899 unsigned short seqno
;
900 unsigned short metric
;
902 /* The same update may be scheduled multiple times before it is
903 sent out. Since our buffer is now sorted, it is enough to
904 compare with the previous update. */
907 if(b
[i
].plen
== last_plen
&&
908 memcmp(b
[i
].prefix
, last_prefix
, 16) == 0)
912 xroute
= find_xroute(b
[i
].prefix
, b
[i
].plen
);
913 route
= find_installed_route(b
[i
].prefix
, b
[i
].plen
);
915 if(xroute
&& (!route
|| xroute
->metric
<= kernel_metric
)) {
916 really_send_update(ifp
, myid
,
917 xroute
->prefix
, xroute
->plen
,
918 myseqno
, xroute
->metric
);
919 last_prefix
= xroute
->prefix
;
920 last_plen
= xroute
->plen
;
922 seqno
= route
->seqno
;
923 metric
= route_metric(route
);
924 if(metric
< INFINITY
)
925 satisfy_request(route
->src
->prefix
, route
->src
->plen
,
926 seqno
, route
->src
->id
, ifp
);
927 if((babel_ifp
->flags
& BABEL_IF_SPLIT_HORIZON
) &&
928 route
->neigh
->ifp
== ifp
)
930 really_send_update(ifp
, route
->src
->id
,
934 update_source(route
->src
, seqno
, metric
);
935 last_prefix
= route
->src
->prefix
;
936 last_plen
= route
->src
->plen
;
938 /* There's no route for this prefix. This can happen shortly
939 after an xroute has been retracted, so send a retraction. */
940 really_send_update(ifp
, myid
, b
[i
].prefix
, b
[i
].plen
,
944 schedule_flush_now(ifp
);
948 babel_ifp
->update_flush_timeout
.tv_sec
= 0;
949 babel_ifp
->update_flush_timeout
.tv_usec
= 0;
953 schedule_update_flush(struct interface
*ifp
, int urgent
)
955 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
957 msecs
= update_jitter(babel_ifp
, urgent
);
958 if(babel_ifp
->update_flush_timeout
.tv_sec
!= 0 &&
959 timeval_minus_msec(&babel_ifp
->update_flush_timeout
, &babel_now
) < msecs
)
961 set_timeout(&babel_ifp
->update_flush_timeout
, msecs
);
965 buffer_update(struct interface
*ifp
,
966 const unsigned char *prefix
, unsigned char plen
)
968 babel_interface_nfo
*babel_ifp
= babel_get_if_nfo(ifp
);
969 if(babel_ifp
->num_buffered_updates
> 0 &&
970 babel_ifp
->num_buffered_updates
>= babel_ifp
->update_bufsize
)
973 if(babel_ifp
->update_bufsize
== 0) {
975 assert(babel_ifp
->buffered_updates
== NULL
);
976 n
= MAX(babel_ifp
->bufsize
/ 16, 4);
978 babel_ifp
->buffered_updates
= malloc(n
*sizeof(struct buffered_update
));
979 if(babel_ifp
->buffered_updates
== NULL
) {
980 zlog_err("malloc(buffered_updates): %s", safe_strerror(errno
));
987 babel_ifp
->update_bufsize
= n
;
988 babel_ifp
->num_buffered_updates
= 0;
991 memcpy(babel_ifp
->buffered_updates
[babel_ifp
->num_buffered_updates
].prefix
,
993 babel_ifp
->buffered_updates
[babel_ifp
->num_buffered_updates
].plen
= plen
;
994 babel_ifp
->num_buffered_updates
++;
998 send_update(struct interface
*ifp
, int urgent
,
999 const unsigned char *prefix
, unsigned char plen
)
1001 babel_interface_nfo
*babel_ifp
= NULL
;
1005 struct interface
*ifp_aux
;
1006 struct listnode
*linklist_node
= NULL
;
1007 struct route
*route
;
1008 FOR_ALL_INTERFACES(ifp_aux
, linklist_node
)
1009 send_update(ifp_aux
, urgent
, prefix
, plen
);
1011 /* Since flushupdates only deals with non-wildcard interfaces, we
1012 need to do this now. */
1013 route
= find_installed_route(prefix
, plen
);
1014 if(route
&& route_metric(route
) < INFINITY
)
1015 satisfy_request(prefix
, plen
, route
->src
->seqno
, route
->src
->id
,
1024 babel_ifp
= babel_get_if_nfo(ifp
);
1026 if(!parasitic
|| find_xroute(prefix
, plen
)) {
1027 debugf(BABEL_DEBUG_COMMON
,"Sending update to %s for %s.",
1028 ifp
->name
, format_prefix(prefix
, plen
));
1029 buffer_update(ifp
, prefix
, plen
);
1032 if(!interface_idle(babel_ifp
)) {
1033 send_self_update(ifp
);
1035 debugf(BABEL_DEBUG_COMMON
,"Sending update to %s for any.", ifp
->name
);
1036 for(i
= 0; i
< numroutes
; i
++)
1037 if(routes
[i
].installed
)
1039 routes
[i
].src
->prefix
,
1040 routes
[i
].src
->plen
);
1043 set_timeout(&babel_ifp
->update_timeout
, babel_ifp
->update_interval
);
1045 schedule_update_flush(ifp
, urgent
);
1049 send_update_resend(struct interface
*ifp
,
1050 const unsigned char *prefix
, unsigned char plen
)
1054 assert(prefix
!= NULL
);
1056 send_update(ifp
, 1, prefix
, plen
);
1059 delay
= MIN(delay
, wireless_hello_interval
/ 2);
1060 delay
= MIN(delay
, wired_hello_interval
/ 2);
1061 delay
= MAX(delay
, 10);
1062 record_resend(RESEND_UPDATE
, prefix
, plen
, 0, 0, NULL
, delay
);
1066 send_wildcard_retraction(struct interface
*ifp
)
1068 babel_interface_nfo
*babel_ifp
= NULL
;
1070 struct interface
*ifp_aux
;
1071 struct listnode
*linklist_node
= NULL
;
1072 FOR_ALL_INTERFACES(ifp_aux
, linklist_node
)
1073 send_wildcard_retraction(ifp_aux
);
1080 babel_ifp
= babel_get_if_nfo(ifp
);
1081 start_message(ifp
, MESSAGE_UPDATE
, 10);
1082 accumulate_byte(ifp
, 0);
1083 accumulate_byte(ifp
, 0x40);
1084 accumulate_byte(ifp
, 0);
1085 accumulate_byte(ifp
, 0);
1086 accumulate_short(ifp
, 0xFFFF);
1087 accumulate_short(ifp
, myseqno
);
1088 accumulate_short(ifp
, 0xFFFF);
1089 end_message(ifp
, MESSAGE_UPDATE
, 10);
1091 babel_ifp
->have_buffered_id
= 0;
1097 myseqno
= seqno_plus(myseqno
, 1);
1098 seqno_time
= babel_now
;
1102 send_self_update(struct interface
*ifp
)
1107 struct interface
*ifp_aux
;
1108 struct listnode
*linklist_node
= NULL
;
1109 FOR_ALL_INTERFACES(ifp_aux
, linklist_node
) {
1112 send_self_update(ifp_aux
);
1117 if(!interface_idle(babel_get_if_nfo(ifp
))) {
1118 debugf(BABEL_DEBUG_COMMON
,"Sending self update to %s.", ifp
->name
);
1119 for(i
= 0; i
< numxroutes
; i
++)
1120 send_update(ifp
, 0, xroutes
[i
].prefix
, xroutes
[i
].plen
);
1125 send_ihu(struct neighbour
*neigh
, struct interface
*ifp
)
1127 babel_interface_nfo
*babel_ifp
= NULL
;
1128 int rxcost
, interval
;
1131 if(neigh
== NULL
&& ifp
== NULL
) {
1132 struct interface
*ifp_aux
;
1133 struct listnode
*linklist_node
= NULL
;
1134 FOR_ALL_INTERFACES(ifp_aux
, linklist_node
) {
1137 send_ihu(NULL
, ifp_aux
);
1143 struct neighbour
*ngh
;
1144 FOR_ALL_NEIGHBOURS(ngh
) {
1152 if(ifp
&& neigh
->ifp
!= ifp
)
1156 babel_ifp
= babel_get_if_nfo(ifp
);
1160 rxcost
= neighbour_rxcost(neigh
);
1161 interval
= (babel_ifp
->hello_interval
* 3 + 9) / 10;
1163 /* Conceptually, an IHU is a unicast message. We usually send them as
1164 multicast, since this allows aggregation into a single packet and
1165 avoids an ARP exchange. If we already have a unicast message queued
1166 for this neighbour, however, we might as well piggyback the IHU. */
1167 debugf(BABEL_DEBUG_COMMON
,"Sending %sihu %d on %s to %s.",
1168 unicast_neighbour
== neigh
? "unicast " : "",
1171 format_address(neigh
->address
));
1173 ll
= linklocal(neigh
->address
);
1175 if(unicast_neighbour
!= neigh
) {
1176 start_message(ifp
, MESSAGE_IHU
, ll
? 14 : 22);
1177 accumulate_byte(ifp
, ll
? 3 : 2);
1178 accumulate_byte(ifp
, 0);
1179 accumulate_short(ifp
, rxcost
);
1180 accumulate_short(ifp
, interval
);
1182 accumulate_bytes(ifp
, neigh
->address
+ 8, 8);
1184 accumulate_bytes(ifp
, neigh
->address
, 16);
1185 end_message(ifp
, MESSAGE_IHU
, ll
? 14 : 22);
1188 rc
= start_unicast_message(neigh
, MESSAGE_IHU
, ll
? 14 : 22);
1190 accumulate_unicast_byte(neigh
, ll
? 3 : 2);
1191 accumulate_unicast_byte(neigh
, 0);
1192 accumulate_unicast_short(neigh
, rxcost
);
1193 accumulate_unicast_short(neigh
, interval
);
1195 accumulate_unicast_bytes(neigh
, neigh
->address
+ 8, 8);
1197 accumulate_unicast_bytes(neigh
, neigh
->address
, 16);
1198 end_unicast_message(neigh
, MESSAGE_IHU
, ll
? 14 : 22);
1202 /* Send IHUs to all marginal neighbours */
1204 send_marginal_ihu(struct interface
*ifp
)
1206 struct neighbour
*neigh
;
1207 FOR_ALL_NEIGHBOURS(neigh
) {
1208 if(ifp
&& neigh
->ifp
!= ifp
)
1210 if(neigh
->txcost
>= 384 || (neigh
->reach
& 0xF000) != 0xF000)
1211 send_ihu(neigh
, ifp
);
1216 send_request(struct interface
*ifp
,
1217 const unsigned char *prefix
, unsigned char plen
)
1219 babel_interface_nfo
*babel_ifp
= NULL
;
1223 struct interface
*ifp_aux
;
1224 struct listnode
*linklist_node
= NULL
;
1225 FOR_ALL_INTERFACES(ifp_aux
, linklist_node
) {
1228 send_request(ifp_aux
, prefix
, plen
);
1233 /* make sure any buffered updates go out before this request. */
1239 babel_ifp
= babel_get_if_nfo(ifp
);
1240 debugf(BABEL_DEBUG_COMMON
,"sending request to %s for %s.",
1241 ifp
->name
, prefix
? format_prefix(prefix
, plen
) : "any");
1242 v4
= plen
>= 96 && v4mapped(prefix
);
1243 len
= !prefix
? 2 : v4
? 6 : 18;
1245 start_message(ifp
, MESSAGE_REQUEST
, len
);
1246 accumulate_byte(ifp
, !prefix
? 0 : v4
? 1 : 2);
1247 accumulate_byte(ifp
, !prefix
? 0 : v4
? plen
- 96 : plen
);
1250 accumulate_bytes(ifp
, prefix
+ 12, 4);
1252 accumulate_bytes(ifp
, prefix
, 16);
1254 end_message(ifp
, MESSAGE_REQUEST
, len
);
1258 send_unicast_request(struct neighbour
*neigh
,
1259 const unsigned char *prefix
, unsigned char plen
)
1263 /* make sure any buffered updates go out before this request. */
1264 flushupdates(neigh
->ifp
);
1266 debugf(BABEL_DEBUG_COMMON
,"sending unicast request to %s for %s.",
1267 format_address(neigh
->address
),
1268 prefix
? format_prefix(prefix
, plen
) : "any");
1269 v4
= plen
>= 96 && v4mapped(prefix
);
1270 len
= !prefix
? 2 : v4
? 6 : 18;
1272 rc
= start_unicast_message(neigh
, MESSAGE_REQUEST
, len
);
1274 accumulate_unicast_byte(neigh
, !prefix
? 0 : v4
? 1 : 2);
1275 accumulate_unicast_byte(neigh
, !prefix
? 0 : v4
? plen
- 96 : plen
);
1278 accumulate_unicast_bytes(neigh
, prefix
+ 12, 4);
1280 accumulate_unicast_bytes(neigh
, prefix
, 16);
1282 end_unicast_message(neigh
, MESSAGE_REQUEST
, len
);
1286 send_multihop_request(struct interface
*ifp
,
1287 const unsigned char *prefix
, unsigned char plen
,
1288 unsigned short seqno
, const unsigned char *id
,
1289 unsigned short hop_count
)
1291 babel_interface_nfo
*babel_ifp
= NULL
;
1294 /* Make sure any buffered updates go out before this request. */
1298 struct interface
*ifp_aux
;
1299 struct listnode
*linklist_node
= NULL
;
1300 FOR_ALL_INTERFACES(ifp_aux
, linklist_node
) {
1303 send_multihop_request(ifp_aux
, prefix
, plen
, seqno
, id
, hop_count
);
1311 babel_ifp
= babel_get_if_nfo(ifp
);
1312 debugf(BABEL_DEBUG_COMMON
,"Sending request (%d) on %s for %s.",
1313 hop_count
, ifp
->name
, format_prefix(prefix
, plen
));
1314 v4
= plen
>= 96 && v4mapped(prefix
);
1315 pb
= v4
? ((plen
- 96) + 7) / 8 : (plen
+ 7) / 8;
1318 start_message(ifp
, MESSAGE_MH_REQUEST
, len
);
1319 accumulate_byte(ifp
, v4
? 1 : 2);
1320 accumulate_byte(ifp
, v4
? plen
- 96 : plen
);
1321 accumulate_short(ifp
, seqno
);
1322 accumulate_byte(ifp
, hop_count
);
1323 accumulate_byte(ifp
, 0);
1324 accumulate_bytes(ifp
, id
, 8);
1327 accumulate_bytes(ifp
, prefix
+ 12, pb
);
1329 accumulate_bytes(ifp
, prefix
, pb
);
1331 end_message(ifp
, MESSAGE_MH_REQUEST
, len
);
1335 send_unicast_multihop_request(struct neighbour
*neigh
,
1336 const unsigned char *prefix
, unsigned char plen
,
1337 unsigned short seqno
, const unsigned char *id
,
1338 unsigned short hop_count
)
1340 int rc
, v4
, pb
, len
;
1342 /* Make sure any buffered updates go out before this request. */
1343 flushupdates(neigh
->ifp
);
1345 debugf(BABEL_DEBUG_COMMON
,"Sending multi-hop request to %s for %s (%d hops).",
1346 format_address(neigh
->address
),
1347 format_prefix(prefix
, plen
), hop_count
);
1348 v4
= plen
>= 96 && v4mapped(prefix
);
1349 pb
= v4
? ((plen
- 96) + 7) / 8 : (plen
+ 7) / 8;
1352 rc
= start_unicast_message(neigh
, MESSAGE_MH_REQUEST
, len
);
1354 accumulate_unicast_byte(neigh
, v4
? 1 : 2);
1355 accumulate_unicast_byte(neigh
, v4
? plen
- 96 : plen
);
1356 accumulate_unicast_short(neigh
, seqno
);
1357 accumulate_unicast_byte(neigh
, hop_count
);
1358 accumulate_unicast_byte(neigh
, 0);
1359 accumulate_unicast_bytes(neigh
, id
, 8);
1362 accumulate_unicast_bytes(neigh
, prefix
+ 12, pb
);
1364 accumulate_unicast_bytes(neigh
, prefix
, pb
);
1366 end_unicast_message(neigh
, MESSAGE_MH_REQUEST
, len
);
1370 send_request_resend(struct neighbour
*neigh
,
1371 const unsigned char *prefix
, unsigned char plen
,
1372 unsigned short seqno
, unsigned char *id
)
1377 send_unicast_multihop_request(neigh
, prefix
, plen
, seqno
, id
, 127);
1379 send_multihop_request(NULL
, prefix
, plen
, seqno
, id
, 127);
1382 delay
= MIN(delay
, wireless_hello_interval
/ 2);
1383 delay
= MIN(delay
, wired_hello_interval
/ 2);
1384 delay
= MAX(delay
, 10);
1385 record_resend(RESEND_REQUEST
, prefix
, plen
, seqno
, id
,
1386 neigh
? neigh
->ifp
: NULL
, delay
);
1390 handle_request(struct neighbour
*neigh
, const unsigned char *prefix
,
1391 unsigned char plen
, unsigned char hop_count
,
1392 unsigned short seqno
, const unsigned char *id
)
1394 struct xroute
*xroute
;
1395 struct route
*route
;
1396 struct neighbour
*successor
= NULL
;
1398 xroute
= find_xroute(prefix
, plen
);
1399 route
= find_installed_route(prefix
, plen
);
1401 if(xroute
&& (!route
|| xroute
->metric
<= kernel_metric
)) {
1402 if(hop_count
> 0 && memcmp(id
, myid
, 8) == 0) {
1403 if(seqno_compare(seqno
, myseqno
) > 0) {
1404 if(seqno_minus(seqno
, myseqno
) > 100) {
1405 /* Hopelessly out-of-date request */
1411 send_update(neigh
->ifp
, 1, prefix
, plen
);
1416 (memcmp(id
, route
->src
->id
, 8) != 0 ||
1417 seqno_compare(seqno
, route
->seqno
) <= 0)) {
1418 send_update(neigh
->ifp
, 1, prefix
, plen
);
1425 if(route
&& memcmp(id
, route
->src
->id
, 8) == 0 &&
1426 seqno_minus(seqno
, route
->seqno
) > 100) {
1427 /* Hopelessly out-of-date */
1431 if(request_redundant(neigh
->ifp
, prefix
, plen
, seqno
, id
))
1434 /* Let's try to forward this request. */
1435 if(route
&& route_metric(route
) < INFINITY
)
1436 successor
= route
->neigh
;
1438 if(!successor
|| successor
== neigh
) {
1439 /* We were about to forward a request to its requestor. Try to
1440 find a different neighbour to forward the request to. */
1441 struct route
*other_route
;
1443 other_route
= find_best_route(prefix
, plen
, 0, neigh
);
1444 if(other_route
&& route_metric(other_route
) < INFINITY
)
1445 successor
= other_route
->neigh
;
1448 if(!successor
|| successor
== neigh
)
1452 send_unicast_multihop_request(successor
, prefix
, plen
, seqno
, id
,
1454 record_resend(RESEND_REQUEST
, prefix
, plen
, seqno
, id
,