Changeset 32663


Ignore:
Timestamp:
Jul 10, 2017, 11:43:42 PM (2 weeks ago)
Author:
brainslayer
Message:

update radvd

Location:
src/router/radvd
Files:
39 edited

Legend:

Unmodified
Added
Removed
  • src/router/radvd/CHANGES

    r32089 r32663  
     12017/07/03      Release v2.17
     2
     32017/07/01      Fix STDERR_SYSLOG log level bug.
     4                Always close stdout and stderr when daemonizing.
     5
     62017/03/15      Implement RFC 7772 Section 5.1.1, 5.1.2, defaulted to on. <Robin H. Johnson>
     7
     82017/02/04      clang-format the code
     9
    1102017/02/01      Release v2.16
    211
  • src/router/radvd/Makefile.am

    r32089 r32663  
    139139
    140140indent:
    141         indent -linux -l125 *.c *.h
     141        clang-format -i *.c *.h test/*.c test/*.h
    142142
    143143EXTRA_DIST = \
  • src/router/radvd/Makefile.in

    r32089 r32663  
    586586program_transform_name = @program_transform_name@
    587587psdir = @psdir@
     588runstatedir = @runstatedir@
    588589sbindir = @sbindir@
    589590sharedstatedir = @sharedstatedir@
     
    18051806
    18061807indent:
    1807         indent -linux -l125 *.c *.h
     1808        clang-format -i *.c *.h test/*.c test/*.h
    18081809
    18091810sign:
  • src/router/radvd/TODO

    r32089 r32663  
    5959   More: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508466
    6060
     61AdvRASolicitedUnicast: Further improvement is possible.
     62- If we get a RS and are about to send a multicast RA, then we can further save
     63  battery on the client device by NOT sending a unicast response, and just
     64  letting the client wait for the multicast response. This should be
     65  implemented as a new time value, specifying the maximum amount of time
     66  remaining to as a deciding factor between send-solicited-RA-now vs
     67  wait-for-next-multicast.
     68- The above can also form part of rate-limiting of unicast RA responses when
     69  network topology has recently changed.
     70
     71The following parts of RFC7222 are not yet implemented:
     72- Section 5.1.3: Networks that serve battery-powered devices SHOULD NOT send
     73  multicast RAs too frequently (see Section 4) unless the information in the RA
     74  packet has substantially changed.  If there is a desire to ensure that hosts
     75  pick up configuration changes quickly, those networks MAY send frequent
     76  Router Advertisements for a limited period of time (e.g., not more than one
     77  minute) immediately after a configuration change.
  • src/router/radvd/aclocal.m4

    r32089 r32663  
    2121To do so, use the procedure documented by the package, typically 'autoreconf'.])])
    2222
    23 # pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
    24 # serial 1 (pkg-config-0.24)
    25 #
    26 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
    27 #
    28 # This program is free software; you can redistribute it and/or modify
    29 # it under the terms of the GNU General Public License as published by
    30 # the Free Software Foundation; either version 2 of the License, or
    31 # (at your option) any later version.
    32 #
    33 # This program is distributed in the hope that it will be useful, but
    34 # WITHOUT ANY WARRANTY; without even the implied warranty of
    35 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    36 # General Public License for more details.
    37 #
    38 # You should have received a copy of the GNU General Public License
    39 # along with this program; if not, write to the Free Software
    40 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    41 #
    42 # As a special exception to the GNU General Public License, if you
    43 # distribute this file as part of a program that contains a
    44 # configuration script generated by Autoconf, you may include it under
    45 # the same distribution terms that you use for the rest of that program.
    46 
    47 # PKG_PROG_PKG_CONFIG([MIN-VERSION])
    48 # ----------------------------------
     23dnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
     24dnl serial 11 (pkg-config-0.29.1)
     25dnl
     26dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
     27dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
     28dnl
     29dnl This program is free software; you can redistribute it and/or modify
     30dnl it under the terms of the GNU General Public License as published by
     31dnl the Free Software Foundation; either version 2 of the License, or
     32dnl (at your option) any later version.
     33dnl
     34dnl This program is distributed in the hope that it will be useful, but
     35dnl WITHOUT ANY WARRANTY; without even the implied warranty of
     36dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
     37dnl General Public License for more details.
     38dnl
     39dnl You should have received a copy of the GNU General Public License
     40dnl along with this program; if not, write to the Free Software
     41dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
     42dnl 02111-1307, USA.
     43dnl
     44dnl As a special exception to the GNU General Public License, if you
     45dnl distribute this file as part of a program that contains a
     46dnl configuration script generated by Autoconf, you may include it under
     47dnl the same distribution terms that you use for the rest of that
     48dnl program.
     49
     50dnl PKG_PREREQ(MIN-VERSION)
     51dnl -----------------------
     52dnl Since: 0.29
     53dnl
     54dnl Verify that the version of the pkg-config macros are at least
     55dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
     56dnl installed version of pkg-config, this checks the developer's version
     57dnl of pkg.m4 when generating configure.
     58dnl
     59dnl To ensure that this macro is defined, also add:
     60dnl m4_ifndef([PKG_PREREQ],
     61dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
     62dnl
     63dnl See the "Since" comment for each macro you use to see what version
     64dnl of the macros you require.
     65m4_defun([PKG_PREREQ],
     66[m4_define([PKG_MACROS_VERSION], [0.29.1])
     67m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
     68    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
     69])dnl PKG_PREREQ
     70
     71dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
     72dnl ----------------------------------
     73dnl Since: 0.16
     74dnl
     75dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
     76dnl first found in the path. Checks that the version of pkg-config found
     77dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
     78dnl used since that's the first version where most current features of
     79dnl pkg-config existed.
    4980AC_DEFUN([PKG_PROG_PKG_CONFIG],
    5081[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
     
    6899        fi
    69100fi[]dnl
    70 ])# PKG_PROG_PKG_CONFIG
    71 
    72 # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
    73 #
    74 # Check to see whether a particular set of modules exists.  Similar
    75 # to PKG_CHECK_MODULES(), but does not set variables or print errors.
    76 #
    77 # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
    78 # only at the first occurence in configure.ac, so if the first place
    79 # it's called might be skipped (such as if it is within an "if", you
    80 # have to call PKG_CHECK_EXISTS manually
    81 # --------------------------------------------------------------
     101])dnl PKG_PROG_PKG_CONFIG
     102
     103dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     104dnl -------------------------------------------------------------------
     105dnl Since: 0.18
     106dnl
     107dnl Check to see whether a particular set of modules exists. Similar to
     108dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
     109dnl
     110dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
     111dnl only at the first occurence in configure.ac, so if the first place
     112dnl it's called might be skipped (such as if it is within an "if", you
     113dnl have to call PKG_CHECK_EXISTS manually
    82114AC_DEFUN([PKG_CHECK_EXISTS],
    83115[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     
    89121fi])
    90122
    91 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
    92 # ---------------------------------------------
     123dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
     124dnl ---------------------------------------------
     125dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
     126dnl pkg_failed based on the result.
    93127m4_define([_PKG_CONFIG],
    94128[if test -n "$$1"; then
     
    102136    pkg_failed=untried
    103137fi[]dnl
    104 ])# _PKG_CONFIG
    105 
    106 # _PKG_SHORT_ERRORS_SUPPORTED
    107 # -----------------------------
     138])dnl _PKG_CONFIG
     139
     140dnl _PKG_SHORT_ERRORS_SUPPORTED
     141dnl ---------------------------
     142dnl Internal check to see if pkg-config supports short errors.
    108143AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
    109144[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
     
    113148        _pkg_short_errors_supported=no
    114149fi[]dnl
    115 ])# _PKG_SHORT_ERRORS_SUPPORTED
    116 
    117 
    118 # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
    119 # [ACTION-IF-NOT-FOUND])
    120 #
    121 #
    122 # Note that if there is a possibility the first call to
    123 # PKG_CHECK_MODULES might not happen, you should be sure to include an
    124 # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
    125 #
    126 #
    127 # --------------------------------------------------------------
     150])dnl _PKG_SHORT_ERRORS_SUPPORTED
     151
     152
     153dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
     154dnl   [ACTION-IF-NOT-FOUND])
     155dnl --------------------------------------------------------------
     156dnl Since: 0.4.0
     157dnl
     158dnl Note that if there is a possibility the first call to
     159dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
     160dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
    128161AC_DEFUN([PKG_CHECK_MODULES],
    129162[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     
    179212        $3
    180213fi[]dnl
    181 ])# PKG_CHECK_MODULES
    182 
    183 
    184 # PKG_INSTALLDIR(DIRECTORY)
    185 # -------------------------
    186 # Substitutes the variable pkgconfigdir as the location where a module
    187 # should install pkg-config .pc files. By default the directory is
    188 # $libdir/pkgconfig, but the default can be changed by passing
    189 # DIRECTORY. The user can override through the --with-pkgconfigdir
    190 # parameter.
     214])dnl PKG_CHECK_MODULES
     215
     216
     217dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
     218dnl   [ACTION-IF-NOT-FOUND])
     219dnl ---------------------------------------------------------------------
     220dnl Since: 0.29
     221dnl
     222dnl Checks for existence of MODULES and gathers its build flags with
     223dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
     224dnl and VARIABLE-PREFIX_LIBS from --libs.
     225dnl
     226dnl Note that if there is a possibility the first call to
     227dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
     228dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
     229dnl configure.ac.
     230AC_DEFUN([PKG_CHECK_MODULES_STATIC],
     231[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     232_save_PKG_CONFIG=$PKG_CONFIG
     233PKG_CONFIG="$PKG_CONFIG --static"
     234PKG_CHECK_MODULES($@)
     235PKG_CONFIG=$_save_PKG_CONFIG[]dnl
     236])dnl PKG_CHECK_MODULES_STATIC
     237
     238
     239dnl PKG_INSTALLDIR([DIRECTORY])
     240dnl -------------------------
     241dnl Since: 0.27
     242dnl
     243dnl Substitutes the variable pkgconfigdir as the location where a module
     244dnl should install pkg-config .pc files. By default the directory is
     245dnl $libdir/pkgconfig, but the default can be changed by passing
     246dnl DIRECTORY. The user can override through the --with-pkgconfigdir
     247dnl parameter.
    191248AC_DEFUN([PKG_INSTALLDIR],
    192249[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
     
    199256m4_popdef([pkg_default])
    200257m4_popdef([pkg_description])
    201 ]) dnl PKG_INSTALLDIR
    202 
    203 
    204 # PKG_NOARCH_INSTALLDIR(DIRECTORY)
    205 # -------------------------
    206 # Substitutes the variable noarch_pkgconfigdir as the location where a
    207 # module should install arch-independent pkg-config .pc files. By
    208 # default the directory is $datadir/pkgconfig, but the default can be
    209 # changed by passing DIRECTORY. The user can override through the
    210 # --with-noarch-pkgconfigdir parameter.
     258])dnl PKG_INSTALLDIR
     259
     260
     261dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
     262dnl --------------------------------
     263dnl Since: 0.27
     264dnl
     265dnl Substitutes the variable noarch_pkgconfigdir as the location where a
     266dnl module should install arch-independent pkg-config .pc files. By
     267dnl default the directory is $datadir/pkgconfig, but the default can be
     268dnl changed by passing DIRECTORY. The user can override through the
     269dnl --with-noarch-pkgconfigdir parameter.
    211270AC_DEFUN([PKG_NOARCH_INSTALLDIR],
    212271[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
     
    219278m4_popdef([pkg_default])
    220279m4_popdef([pkg_description])
    221 ]) dnl PKG_NOARCH_INSTALLDIR
    222 
    223 
    224 # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
    225 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
    226 # -------------------------------------------
    227 # Retrieves the value of the pkg-config variable for the given module.
     280])dnl PKG_NOARCH_INSTALLDIR
     281
     282
     283dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
     284dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     285dnl -------------------------------------------
     286dnl Since: 0.28
     287dnl
     288dnl Retrieves the value of the pkg-config variable for the given module.
    228289AC_DEFUN([PKG_CHECK_VAR],
    229290[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     
    234295
    235296AS_VAR_IF([$1], [""], [$5], [$4])dnl
    236 ])# PKG_CHECK_VAR
     297])dnl PKG_CHECK_VAR
    237298
    238299# Copyright (C) 2002-2014 Free Software Foundation, Inc.
  • src/router/radvd/config.guess

    r29984 r32663  
    11#! /bin/sh
    22# Attempt to guess a canonical system name.
    3 #   Copyright 1992-2014 Free Software Foundation, Inc.
    4 
    5 timestamp='2014-03-23'
     3#   Copyright 1992-2015 Free Software Foundation, Inc.
     4
     5timestamp='2015-08-20'
    66
    77# This file is free software; you can redistribute it and/or modify it
     
    2525# of the GNU General Public License, version 3 ("GPLv3").
    2626#
    27 # Originally written by Per Bothner.
     27# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
    2828#
    2929# You can get the latest version of this script from:
    3030# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
    3131#
    32 # Please send patches with a ChangeLog entry to config-patches@gnu.org.
     32# Please send patches to <config-patches@gnu.org>.
    3333
    3434
     
    5151
    5252Originally written by Per Bothner.
    53 Copyright 1992-2014 Free Software Foundation, Inc.
     53Copyright 1992-2015 Free Software Foundation, Inc.
    5454
    5555This is free software; see the source for copying conditions.  There is NO
     
    169169        # portion of the name.  We always set it to "unknown".
    170170        sysctl="sysctl -n hw.machine_arch"
    171         UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
    172             /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
     171        UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
     172            /sbin/$sysctl 2>/dev/null || \
     173            /usr/sbin/$sysctl 2>/dev/null || \
     174            echo unknown)`
    173175        case "${UNAME_MACHINE_ARCH}" in
    174176            armeb) machine=armeb-unknown ;;
     
    177179            sh3eb) machine=sh-unknown ;;
    178180            sh5el) machine=sh5le-unknown ;;
     181            earmv*)
     182                arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
     183                endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
     184                machine=${arch}${endian}-unknown
     185                ;;
    179186            *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
    180187        esac
     
    182189        # to ELF recently, or will in the future.
    183190        case "${UNAME_MACHINE_ARCH}" in
    184             arm*|i386|m68k|ns32k|sh3*|sparc|vax)
     191            arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
    185192                eval $set_cc_for_build
    186193                if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
     
    198205                ;;
    199206        esac
     207        # Determine ABI tags.
     208        case "${UNAME_MACHINE_ARCH}" in
     209            earm*)
     210                expr='s/^earmv[0-9]/-eabi/;s/eb$//'
     211                abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
     212                ;;
     213        esac
    200214        # The OS release
    201215        # Debian GNU/NetBSD machines have a different userland, and
     
    208222                ;;
    209223            *)
    210                 release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
     224                release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
    211225                ;;
    212226        esac
     
    214228        # contains redundant information, the shorter form:
    215229        # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
    216         echo "${machine}-${os}${release}"
     230        echo "${machine}-${os}${release}${abi}"
    217231        exit ;;
    218232    *:Bitrig:*:*)
     
    235249    *:MirBSD:*:*)
    236250        echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
     251        exit ;;
     252    *:Sortix:*:*)
     253        echo ${UNAME_MACHINE}-unknown-sortix
    237254        exit ;;
    238255    alpha:OSF1:*:*)
     
    580597                IBM_ARCH=powerpc
    581598        fi
    582         if [ -x /usr/bin/oslevel ] ; then
    583                 IBM_REV=`/usr/bin/oslevel`
     599        if [ -x /usr/bin/lslpp ] ; then
     600                IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
     601                           awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
    584602        else
    585603                IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
     
    933951        echo ${UNAME_MACHINE}-axis-linux-${LIBC}
    934952        exit ;;
     953    e2k:Linux:*:*)
     954        echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
     955        exit ;;
    935956    frv:Linux:*:*)
    936957        echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
     
    10211042        exit ;;
    10221043    x86_64:Linux:*:*)
    1023         echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
     1044        echo ${UNAME_MACHINE}-pc-linux-${LIBC}
    10241045        exit ;;
    10251046    xtensa*:Linux:*:*)
  • src/router/radvd/config.sub

    r29984 r32663  
    11#! /bin/sh
    22# Configuration validation subroutine script.
    3 #   Copyright 1992-2014 Free Software Foundation, Inc.
    4 
    5 timestamp='2014-09-11'
     3#   Copyright 1992-2015 Free Software Foundation, Inc.
     4
     5timestamp='2015-08-20'
    66
    77# This file is free software; you can redistribute it and/or modify it
     
    2626
    2727
    28 # Please send patches with a ChangeLog entry to config-patches@gnu.org.
     28# Please send patches to <config-patches@gnu.org>.
    2929#
    3030# Configuration subroutine to validate and canonicalize a configuration type.
     
    6969GNU config.sub ($timestamp)
    7070
    71 Copyright 1992-2014 Free Software Foundation, Inc.
     71Copyright 1992-2015 Free Software Foundation, Inc.
    7272
    7373This is free software; see the source for copying conditions.  There is NO
     
    118118  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
    119119  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
    120   knetbsd*-gnu* | netbsd*-gnu* | \
     120  knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
    121121  kopensolaris*-gnu* | \
    122122  storm-chaos* | os2-emx* | rtmk-nova*)
     
    256256        | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
    257257        | avr | avr32 \
     258        | ba \
    258259        | be32 | be64 \
    259260        | bfin \
    260261        | c4x | c8051 | clipper \
    261262        | d10v | d30v | dlx | dsp16xx \
    262         | epiphany \
    263         | fido | fr30 | frv \
     263        | e2k | epiphany \
     264        | fido | fr30 | frv | ft32 \
    264265        | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
    265266        | hexagon \
     
    306307        | rl78 | rx \
    307308        | score \
    308         | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
     309        | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
    309310        | sh64 | sh64le \
    310311        | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
     
    314315        | ubicom32 \
    315316        | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
     317        | visium \
    316318        | we32k \
    317319        | x86 | xc16x | xstormy16 | xtensa \
     
    327329        c6x)
    328330                basic_machine=tic6x-unknown
     331                ;;
     332        leon|leon[3-9])
     333                basic_machine=sparc-$basic_machine
    329334                ;;
    330335        m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
     
    373378        | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
    374379        | avr-* | avr32-* \
     380        | ba-* \
    375381        | be32-* | be64-* \
    376382        | bfin-* | bs2000-* \
     
    378384        | c8051-* | clipper-* | craynv-* | cydra-* \
    379385        | d10v-* | d30v-* | dlx-* \
    380         | elxsi-* \
     386        | e2k-* | elxsi-* \
    381387        | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
    382388        | h8300-* | h8500-* \
     
    425431        | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
    426432        | pyramid-* \
     433        | riscv32-* | riscv64-* \
    427434        | rl78-* | romp-* | rs6000-* | rx-* \
    428435        | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
     
    430437        | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
    431438        | sparclite-* \
    432         | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
     439        | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
    433440        | tahoe-* \
    434441        | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
     
    438445        | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
    439446        | vax-* \
     447        | visium-* \
    440448        | we32k-* \
    441449        | x86-* | x86_64-* | xc16x-* | xps100-* \
     
    513521                basic_machine=i386-pc
    514522                os=-aros
     523                ;;
     524        asmjs)
     525                basic_machine=asmjs-unknown
    515526                ;;
    516527        aux)
     
    774785                basic_machine=m68k-isi
    775786                os=-sysv
     787                ;;
     788        leon-*|leon[3-9]-*)
     789                basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
    776790                ;;
    777791        m68knommu)
     
    13661380              | -sym* | -kopensolaris* | -plan9* \
    13671381              | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
    1368               | -aos* | -aros* \
     1382              | -aos* | -aros* | -cloudabi* | -sortix* \
    13691383              | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
    13701384              | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
  • src/router/radvd/configure

    r32089 r32663  
    11#! /bin/sh
    22# Guess values for system-dependent variables and create Makefiles.
    3 # Generated by GNU Autoconf 2.69 for radvd 2.16.
     3# Generated by GNU Autoconf 2.69 for radvd 2.17.
    44#
    55#
     
    578578PACKAGE_NAME='radvd'
    579579PACKAGE_TARNAME='radvd'
    580 PACKAGE_VERSION='2.16'
    581 PACKAGE_STRING='radvd 2.16'
     580PACKAGE_VERSION='2.17'
     581PACKAGE_STRING='radvd 2.17'
    582582PACKAGE_BUGREPORT=''
    583583PACKAGE_URL=''
     
    727727oldincludedir
    728728includedir
     729runstatedir
    729730localstatedir
    730731sharedstatedir
     
    812813sharedstatedir='${prefix}/com'
    813814localstatedir='${prefix}/var'
     815runstatedir='${localstatedir}/run'
    814816includedir='${prefix}/include'
    815817oldincludedir='/usr/include'
     
    10641066    silent=yes ;;
    10651067
     1068  -runstatedir | --runstatedir | --runstatedi | --runstated \
     1069  | --runstate | --runstat | --runsta | --runst | --runs \
     1070  | --run | --ru | --r)
     1071    ac_prev=runstatedir ;;
     1072  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
     1073  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
     1074  | --run=* | --ru=* | --r=*)
     1075    runstatedir=$ac_optarg ;;
     1076
    10661077  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
    10671078    ac_prev=sbindir ;;
     
    12011212                datadir sysconfdir sharedstatedir localstatedir includedir \
    12021213                oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
    1203                 libdir localedir mandir
     1214                libdir localedir mandir runstatedir
    12041215do
    12051216  eval ac_val=\$$ac_var
     
    13141325  # This message is too long to be a string in the A/UX 3.1 sh.
    13151326  cat <<_ACEOF
    1316 \`configure' configures radvd 2.16 to adapt to many kinds of systems.
     1327\`configure' configures radvd 2.17 to adapt to many kinds of systems.
    13171328
    13181329Usage: $0 [OPTION]... [VAR=VALUE]...
     
    13541365  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
    13551366  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
     1367  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
    13561368  --libdir=DIR            object code libraries [EPREFIX/lib]
    13571369  --includedir=DIR        C header files [PREFIX/include]
     
    13851397if test -n "$ac_init_help"; then
    13861398  case $ac_init_help in
    1387      short | recursive ) echo "Configuration of radvd 2.16:";;
     1399     short | recursive ) echo "Configuration of radvd 2.17:";;
    13881400   esac
    13891401  cat <<\_ACEOF
     
    15011513if $ac_init_version; then
    15021514  cat <<\_ACEOF
    1503 radvd configure 2.16
     1515radvd configure 2.17
    15041516generated by GNU Autoconf 2.69
    15051517
     
    18661878running configure, to aid debugging if configure makes a mistake.
    18671879
    1868 It was created by radvd $as_me 2.16, which was
     1880It was created by radvd $as_me 2.17, which was
    18691881generated by GNU Autoconf 2.69.  Invocation command line was
    18701882
     
    28412853# Define the identity of the package.
    28422854 PACKAGE='radvd'
    2843  VERSION='2.16'
     2855 VERSION='2.17'
    28442856
    28452857
     
    64846496# values after options handling.
    64856497ac_log="
    6486 This file was extended by radvd $as_me 2.16, which was
     6498This file was extended by radvd $as_me 2.17, which was
    64876499generated by GNU Autoconf 2.69.  Invocation command line was
    64886500
     
    65506562ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
    65516563ac_cs_version="\\
    6552 radvd config.status 2.16
     6564radvd config.status 2.17
    65536565configured by $0, generated by GNU Autoconf 2.69,
    65546566  with options \\"\$ac_cs_config\\"
  • src/router/radvd/configure.ac

    r32089 r32663  
    1414
    1515dnl If adding rcX to version, be sure to separate with a '-'
    16 AC_INIT(radvd, [2.16])
     16AC_INIT(radvd, [2.17])
    1717AC_CONFIG_SRCDIR(radvd.c)
    1818AC_CANONICAL_SYSTEM
  • src/router/radvd/defaults.h

    r32089 r32663  
    2121
    2222/* maximum message size for incoming and outgoing RSs and RAs */
    23 #define MSG_SIZE_RECV                   1500
    24 #define MSG_SIZE_SEND                   1452
    25 #define RFC2460_MIN_MTU                 1280 /* RFC2460 5. Packet Size Issues: lowest valid MTU supported by IPv6 */
    26 
    27 #define MAX2(X,Y) ( (( X ) >=  ( Y )) ? ( X ) : ( Y ))
     23#define MSG_SIZE_RECV 1500
     24#define MSG_SIZE_SEND 1452
     25#define RFC2460_MIN_MTU 1280 /* RFC2460 5. Packet Size Issues: lowest valid MTU supported by IPv6 */
     26
     27#define MAX2(X, Y) (((X) >= (Y)) ? (X) : (Y))
    2828
    2929/* Router Configuration Variables: */
     
    3131/* For each multicast interface: */
    3232
    33 #define DFLT_IgnoreIfMissing            1
    34 #define DFLT_AdvSendAdv                 0
    35 #define DFLT_MaxRtrAdvInterval          600
    36 #define DFLT_MinRtrAdvInterval(iface)   (0.33 * (iface)->MaxRtrAdvInterval)
    37 #define DFLT_AdvManagedFlag             0
    38 #define DFLT_AdvOtherConfigFlag         0
    39 #define DFLT_AdvLinkMTU                 0
    40 #define DFLT_AdvReachableTime           0
    41 #define DFLT_AdvRetransTimer            0
    42 #define DFLT_AdvCurHopLimit             64      /* as per RFC 1700 or the
    43                                                    next incarnation of it :) */
    44 #define DFLT_AdvDefaultLifetime(iface)  MAX2(1, (int)(3.0 * (iface)->MaxRtrAdvInterval))
    45 #define DFLT_MinDelayBetweenRAs         MIN_DELAY_BETWEEN_RAS
    46 #define DFLT_AdvDefaultPreference       0
    47 #define DFLT_AdvRAMTU                   RFC2460_MIN_MTU
     33#define DFLT_IgnoreIfMissing 1
     34#define DFLT_AdvSendAdv 0
     35#define DFLT_MaxRtrAdvInterval 600
     36#define DFLT_MinRtrAdvInterval(iface) (0.33 * (iface)->MaxRtrAdvInterval)
     37#define DFLT_AdvManagedFlag 0
     38#define DFLT_AdvOtherConfigFlag 0
     39#define DFLT_AdvLinkMTU 0
     40#define DFLT_AdvReachableTime 0
     41#define DFLT_AdvRetransTimer 0
     42#define DFLT_AdvCurHopLimit                                                                                                      \
     43        64 /* as per RFC 1700 or the                                                                                             \
     44              next incarnation of it :) */
     45#define DFLT_AdvDefaultLifetime(iface) MAX2(1, (int)(3.0 * (iface)->MaxRtrAdvInterval))
     46#define DFLT_MinDelayBetweenRAs MIN_DELAY_BETWEEN_RAS
     47#define DFLT_AdvDefaultPreference 0
     48#define DFLT_AdvRAMTU RFC2460_MIN_MTU
     49#define DFLT_UnicastOnly 0
     50#define DFLT_AdvRASolicitedUnicast 1
    4851
    4952/* Options sent with RA */
    5053
    51 #define DFLT_AdvSourceLLAddress         1
     54#define DFLT_AdvSourceLLAddress 1
    5255
    5356/* Each prefix has an associated: */
    5457
    55 #define DFLT_AdvValidLifetime           86400   /* seconds */
    56 #define DFLT_AdvOnLinkFlag              1
    57 #define DFLT_AdvPreferredLifetime       14400   /* seconds */
    58 #define DFLT_AdvAutonomousFlag          1
    59 #define DFLT_DeprecatePrefixFlag        0
    60 #define DFLT_DecrementLifetimesFlag     0
     58#define DFLT_AdvValidLifetime 86400 /* seconds */
     59#define DFLT_AdvOnLinkFlag 1
     60#define DFLT_AdvPreferredLifetime 14400 /* seconds */
     61#define DFLT_AdvAutonomousFlag 1
     62#define DFLT_DeprecatePrefixFlag 0
     63#define DFLT_DecrementLifetimesFlag 0
    6164
    6265/* Each route has an associated: */
    63 #define DFLT_AdvRouteLifetime(iface)    (3 * (iface)->MaxRtrAdvInterval)
    64 
    65 #define DFLT_AdvRoutePreference         0       /* medium */
    66 #define DFLT_RemoveRouteFlag            1
     66#define DFLT_AdvRouteLifetime(iface) (3 * (iface)->MaxRtrAdvInterval)
     67
     68#define DFLT_AdvRoutePreference 0 /* medium */
     69#define DFLT_RemoveRouteFlag 1
    6770
    6871/* RDNSS */
    69 #define DFLT_AdvRDNSSLifetime(iface)                    (iface)->MaxRtrAdvInterval
    70 #define DFLT_FlushRDNSSFlag             1
     72#define DFLT_AdvRDNSSLifetime(iface) (iface)->MaxRtrAdvInterval
     73#define DFLT_FlushRDNSSFlag 1
    7174
    7275/* DNSSL */
    73 #define DFLT_AdvDNSSLLifetime(iface)                    (iface)->MaxRtrAdvInterval
    74 #define DFLT_FlushDNSSLFlag             1
     76#define DFLT_AdvDNSSLLifetime(iface) (iface)->MaxRtrAdvInterval
     77#define DFLT_FlushDNSSLFlag 1
    7578
    7679/* Protocol (RFC4861) constants: */
     
    7881/* Router constants: */
    7982
    80 #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
    81 #define MAX_INITIAL_RTR_ADVERTISEMENTS  3
    82 #define MAX_FINAL_RTR_ADVERTISEMENTS    3
    83 #define MIN_DELAY_BETWEEN_RAS           3.0
    84 #define MIN_DELAY_BETWEEN_RAS_MIPv6     (30.0/1000.0)
    85 #define MAX_RA_DELAY_SECONDS            (0.5)
     83#define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
     84#define MAX_INITIAL_RTR_ADVERTISEMENTS 3
     85#define MAX_FINAL_RTR_ADVERTISEMENTS 3
     86#define MIN_DELAY_BETWEEN_RAS 3.0
     87#define MIN_DELAY_BETWEEN_RAS_MIPv6 (30.0 / 1000.0)
     88#define MAX_RA_DELAY_SECONDS (0.5)
    8689
    8790/* Host constants: */
    8891
    89 #define MAX_RTR_SOLICITATION_DELAY      1
    90 #define RTR_SOLICITATION_INTERVAL       4
    91 #define MAX_RTR_SOLICITATIONS           3
     92#define MAX_RTR_SOLICITATION_DELAY 1
     93#define RTR_SOLICITATION_INTERVAL 4
     94#define MAX_RTR_SOLICITATIONS 3
    9295
    9396/* Node constants: */
    9497
    95 #define MAX_MULTICAST_SOLICIT           3
    96 #define MAX_UNICAST_SOLICIT             3
    97 #define MAX_ANYCAST_DELAY_TIME          1
    98 #define MAX_NEIGHBOR_ADVERTISEMENT      3
    99 #define REACHABLE_TIME                  30000   /* milliseconds */
    100 #define RETRANS_TIMER                   1000    /* milliseconds */
    101 #define DELAY_FIRST_PROBE_TIME          5
    102 #define MIN_RANDOM_FACTOR               (1.0/2.0)
    103 #define MAX_RANDOM_FACTOR               (3.0/2.0)
     98#define MAX_MULTICAST_SOLICIT 3
     99#define MAX_UNICAST_SOLICIT 3
     100#define MAX_ANYCAST_DELAY_TIME 1
     101#define MAX_NEIGHBOR_ADVERTISEMENT 3
     102#define REACHABLE_TIME 30000 /* milliseconds */
     103#define RETRANS_TIMER 1000   /* milliseconds */
     104#define DELAY_FIRST_PROBE_TIME 5
     105#define MIN_RANDOM_FACTOR (1.0 / 2.0)
     106#define MAX_RANDOM_FACTOR (3.0 / 2.0)
    104107
    105108/* MAX and MIN (RFC4861), Mobile IPv6 extensions will override if in use */
    106109
    107 #define MIN_MaxRtrAdvInterval           4
    108 #define MAX_MaxRtrAdvInterval           1800
    109 
    110 #define MIN_MinRtrAdvInterval           3
    111 #define MAX_MinRtrAdvInterval(iface)    (0.75 * (iface)->MaxRtrAdvInterval)
    112 
    113 #define MIN_AdvDefaultLifetime(iface)   (MAX2(1,(iface)->MaxRtrAdvInterval))
    114 #define MAX_AdvDefaultLifetime          9000
    115 
    116 #define MIN_AdvLinkMTU                  RFC2460_MIN_MTU
    117 #define MAX_AdvLinkMTU                  131072
    118 
    119 #define MIN_AdvRAMTU                    MIN_AdvLinkMTU
    120 #define MAX_AdvRAMTU                    MAX_AdvLinkMTU
    121 
    122 #define MIN_AdvReachableTime            100
    123 #define MAX_AdvReachableTime            3600000 /* 1 hour in milliseconds */
    124 
    125 #define MIN_AdvRetransTimer             10
    126 #define MAX_AdvRetransTimer             3600000
    127 
    128 #define MIN_AdvCurHopLimit              2
    129 #define MAX_AdvCurHopLimit              255
    130 
    131 #define MAX_PrefixLen                   128
     110#define MIN_MaxRtrAdvInterval 4
     111#define MAX_MaxRtrAdvInterval 1800
     112
     113#define MIN_MinRtrAdvInterval 3
     114#define MAX_MinRtrAdvInterval(iface) (0.75 * (iface)->MaxRtrAdvInterval)
     115
     116#define MIN_AdvDefaultLifetime(iface) (MAX2(1, (iface)->MaxRtrAdvInterval))
     117#define MAX_AdvDefaultLifetime 9000
     118
     119#define MIN_AdvLinkMTU RFC2460_MIN_MTU
     120#define MAX_AdvLinkMTU 131072
     121
     122#define MIN_AdvRAMTU MIN_AdvLinkMTU
     123#define MAX_AdvRAMTU MAX_AdvLinkMTU
     124
     125#define MIN_AdvReachableTime 100
     126#define MAX_AdvReachableTime 3600000 /* 1 hour in milliseconds */
     127
     128#define MIN_AdvRetransTimer 10
     129#define MAX_AdvRetransTimer 3600000
     130
     131#define MIN_AdvCurHopLimit 2
     132#define MAX_AdvCurHopLimit 255
     133
     134#define MAX_PrefixLen 128
    132135
    133136/* SLAAC (RFC4862) Constants and Derived Values */
    134 #define MIN_AdvValidLifetime            7200    /* 2 hours in secs */
     137#define MIN_AdvValidLifetime 7200 /* 2 hours in secs */
    135138
    136139/*
     
    138141 */
    139142
    140 #define DFLT_AdvRouterAddr              0
    141 #define DFLT_AdvHomeAgentFlag           0
    142 #define DFLT_AdvIntervalOpt             0
    143 #define DFLT_AdvHomeAgentInfo           0
     143#define DFLT_AdvRouterAddr 0
     144#define DFLT_AdvHomeAgentFlag 0
     145#define DFLT_AdvIntervalOpt 0
     146#define DFLT_AdvHomeAgentInfo 0
    144147
    145148/* Option types (defined also at least in glibc 2.2's netinet/icmp6.h) */
    146149
    147150#ifndef ND_OPT_RTR_ADV_INTERVAL
    148 #define ND_OPT_RTR_ADV_INTERVAL         7
     151#define ND_OPT_RTR_ADV_INTERVAL 7
    149152#endif
    150153#ifndef ND_OPT_HOME_AGENT_INFO
    151 #define ND_OPT_HOME_AGENT_INFO          8
     154#define ND_OPT_HOME_AGENT_INFO 8
    152155#endif
    153156
     
    155158   the official IANA assignment is '24' */
    156159#undef ND_OPT_ROUTE_INFORMATION
    157 #define  ND_OPT_ROUTE_INFORMATION       24
     160#define ND_OPT_ROUTE_INFORMATION 24
    158161
    159162/* XXX: some libc's like KAME already had nd_opt_route_info! */
    160 struct nd_opt_route_info_local {        /* route information */
     163struct nd_opt_route_info_local { /* route information */
    161164        uint8_t nd_opt_ri_type;
    162165        uint8_t nd_opt_ri_len;
     
    168171
    169172/* the reserved field is 8 bits and we're interested of the middle two: 000xx000 */
    170 #define ND_OPT_RI_PRF_SHIFT     3
    171 #define ND_OPT_RI_PRF_MASK      (3 << ND_OPT_RI_PRF_SHIFT)      /* 00011000 = 0x18 */
     173#define ND_OPT_RI_PRF_SHIFT 3
     174#define ND_OPT_RI_PRF_MASK (3 << ND_OPT_RI_PRF_SHIFT) /* 00011000 = 0x18 */
    172175
    173176#undef ND_OPT_RDNSS_INFORMATION
    174 #define  ND_OPT_RDNSS_INFORMATION       25
     177#define ND_OPT_RDNSS_INFORMATION 25
    175178
    176179/* */
     
    186189/* pref/flag/reserved field : yyyyx00000000000 (big endian) - 00000000yyyyx000 (little indian); where yyyy = pref, x = flag */
    187190#if BYTE_ORDER == BIG_ENDIAN
    188 #define ND_OPT_RDNSSI_PREF_SHIFT        12
     191#define ND_OPT_RDNSSI_PREF_SHIFT 12
    189192#else
    190 #define ND_OPT_RDNSSI_PREF_SHIFT        4
    191 #endif
    192 #define ND_OPT_RDNSSI_PREF_MASK         (0xf << ND_OPT_RDNSSI_PREF_SHIFT)
     193#define ND_OPT_RDNSSI_PREF_SHIFT 4
     194#endif
     195#define ND_OPT_RDNSSI_PREF_MASK (0xf << ND_OPT_RDNSSI_PREF_SHIFT)
    193196
    194197#undef ND_OPT_DNSSL_INFORMATION
    195 #define  ND_OPT_DNSSL_INFORMATION       31
     198#define ND_OPT_DNSSL_INFORMATION 31
    196199
    197200/* */
     
    207210
    208211#ifndef ND_RA_FLAG_HOME_AGENT
    209 #define ND_RA_FLAG_HOME_AGENT           0x20
     212#define ND_RA_FLAG_HOME_AGENT 0x20
    210213#endif
    211214#ifndef ND_OPT_PI_FLAG_RADDR
    212 #define ND_OPT_PI_FLAG_RADDR            0x20
     215#define ND_OPT_PI_FLAG_RADDR 0x20
    213216#endif
    214217#ifndef ND_OPT_RDNSSI_FLAG_S
    215218#if BYTE_ORDER == BIG_ENDIAN
    216 #define ND_OPT_RDNSSI_FLAG_S         0x0800
     219#define ND_OPT_RDNSSI_FLAG_S 0x0800
    217220#else
    218 #define ND_OPT_RDNSSI_FLAG_S         0x0008
     221#define ND_OPT_RDNSSI_FLAG_S 0x0008
    219222#endif
    220223#endif
     
    222225/* Configurable values */
    223226
    224 #define DFLT_HomeAgentPreference        0
    225 #define DFLT_HomeAgentLifetime(iface)   ((iface)->ra_header_info.AdvDefaultLifetime)
     227#define DFLT_HomeAgentPreference 0
     228#define DFLT_HomeAgentLifetime(iface) ((iface)->ra_header_info.AdvDefaultLifetime)
    226229
    227230/* Other */
    228231
    229 #define MIN_MinRtrAdvInterval_MIPv6     (3.0/100.0)
    230 #define MIN_MaxRtrAdvInterval_MIPv6     (7.0/100.0)
    231 #define RTR_SOLICITATION_INTERVAL_MIPv6 1       /* Recommended value by MIPv6 */
    232 
    233 #define Cautious_MaxRtrAdvInterval      (2.0/10.0)
    234 #define Cautious_MaxRtrAdvInterval_Leeway      (2.0/100.0)
    235 
    236 #define MIN_HomeAgentLifetime           1       /* 0 must NOT be used */
    237 #define MAX_HomeAgentLifetime           65520   /* 18.2 hours in secs */
     232#define MIN_MinRtrAdvInterval_MIPv6 (3.0 / 100.0)
     233#define MIN_MaxRtrAdvInterval_MIPv6 (7.0 / 100.0)
     234#define RTR_SOLICITATION_INTERVAL_MIPv6 1 /* Recommended value by MIPv6 */
     235
     236#define Cautious_MaxRtrAdvInterval (2.0 / 10.0)
     237#define Cautious_MaxRtrAdvInterval_Leeway (2.0 / 100.0)
     238
     239#define MIN_HomeAgentLifetime 1     /* 0 must NOT be used */
     240#define MAX_HomeAgentLifetime 65520 /* 18.2 hours in secs */
    238241
    239242/* #define MAX_RTR_SOLICITATIONS This MAY be ignored by MIPv6 */
    240243
    241244/* NEMO extensions, off by default */
    242 #define DFLT_AdvMobRtrSupportFlag       0
     245#define DFLT_AdvMobRtrSupportFlag 0
    243246
    244247/* Flags */
     
    246249#ifndef ND_OPT_HAI_FLAG_SUPPORT_MR
    247250#if BYTE_ORDER == BIG_ENDIAN
    248 #define ND_OPT_HAI_FLAG_SUPPORT_MR      0x8000
    249 #else                           /* BYTE_ORDER == LITTLE_ENDIAN */
    250 #define ND_OPT_HAI_FLAG_SUPPORT_MR      0x0080
    251 #endif
    252 #endif
    253 
    254 #endif
     251#define ND_OPT_HAI_FLAG_SUPPORT_MR 0x8000
     252#else /* BYTE_ORDER == LITTLE_ENDIAN */
     253#define ND_OPT_HAI_FLAG_SUPPORT_MR 0x0080
     254#endif
     255#endif
     256
     257#endif
  • src/router/radvd/device-bsd44.c

    r32089 r32663  
    1414
    1515#include "config.h"
     16#include "defaults.h"
    1617#include "includes.h"
    1718#include "radvd.h"
    18 #include "defaults.h"
    1919
    2020/*
     
    5050        }
    5151
    52         for (struct ifaddrs * ifa = addresses; ifa != NULL; ifa = ifa->ifa_next) {
     52        for (struct ifaddrs *ifa = addresses; ifa != NULL; ifa = ifa->ifa_next) {
    5353                if (strcmp(ifa->ifa_name, iface->props.name) != 0)
    5454                        continue;
     
    102102                while (prefix) {
    103103                        if ((iface->sllao.if_prefix_len != -1) && (iface->sllao.if_prefix_len != prefix->PrefixLen)) {
    104                                 flog(LOG_WARNING, "prefix length should be %d for %s", iface->sllao.if_prefix_len, iface->props.name);
     104                                flog(LOG_WARNING, "prefix length should be %d for %s", iface->sllao.if_prefix_len,
     105                                     iface->props.name);
    105106                        }
    106107
     
    115116        }
    116117
    117  ret:
     118ret:
    118119        iface->sllao.if_maxmtu = -1;
    119120        iface->sllao.if_hwaddr_len = -1;
     
    126127}
    127128
    128 int setup_allrouters_membership(int sock, struct Interface *iface)
    129 {
    130         return 0;
    131 }
     129int setup_allrouters_membership(int sock, struct Interface *iface) { return 0; }
    132130
    133131int set_interface_linkmtu(const char *iface, uint32_t mtu)
  • src/router/radvd/device-common.c

    r32089 r32663  
    1414
    1515#include "config.h"
     16#include "defaults.h"
    1617#include "includes.h"
     18#include "pathnames.h"
    1719#include "radvd.h"
    18 #include "defaults.h"
    19 #include "pathnames.h"
    2020
    2121int check_device(int sock, struct Interface *iface)
     
    8888}
    8989
    90 
    91 static int cmp_iface_addrs(void const *a, void const *b)
    92 {
    93         return memcmp(a, b, sizeof(struct in6_addr));
    94 }
     90static int cmp_iface_addrs(void const *a, void const *b) { return memcmp(a, b, sizeof(struct in6_addr)); }
    9591
    9692/*
     
    112108                flog(LOG_ERR, "getifaddrs failed on %s: %s", name, strerror(errno));
    113109        } else {
    114                 for (struct ifaddrs * ifa = addresses; ifa != NULL; ifa = ifa->ifa_next) {
     110                for (struct ifaddrs *ifa = addresses; ifa != NULL; ifa = ifa->ifa_next) {
    115111
    116112                        if (!ifa->ifa_addr)
     
    126122                                continue;
    127123
    128                         *if_addrs = realloc(*if_addrs, (i+1) * sizeof(struct in6_addr));
     124                        *if_addrs = realloc(*if_addrs, (i + 1) * sizeof(struct in6_addr));
    129125                        (*if_addrs)[i++] = a6->sin6_addr;
    130126
    131127                        /* Skip if it is not a linklocal address or link locak address already found*/
    132                         uint8_t const ll_prefix[] = { 0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
     128                        uint8_t const ll_prefix[] = {0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
    133129                        if (link_local_set || 0 != memcmp(&(a6->sin6_addr), ll_prefix, sizeof(ll_prefix)))
    134130                                continue;
     
    145141
    146142        /* last item in the list is all zero (unspecified) address */
    147         *if_addrs = realloc(*if_addrs, (i+1) * sizeof(struct in6_addr));
     143        *if_addrs = realloc(*if_addrs, (i + 1) * sizeof(struct in6_addr));
    148144        memset(&(*if_addrs)[i], 0, sizeof(struct in6_addr));
    149145
     
    156152        return i;
    157153}
    158 
    159154
    160155/*
     
    176171                }
    177172                /* AdvRASrcAddress: allow operator selection of RA source address */
    178                 if(iface->AdvRASrcAddressList != NULL) {
     173                if (iface->AdvRASrcAddressList != NULL) {
    179174                        iface->props.if_addr_rasrc = NULL;
    180                         for (struct AdvRASrcAddress * current = iface->AdvRASrcAddressList; current; current = current->next) {
     175                        for (struct AdvRASrcAddress *current = iface->AdvRASrcAddressList; current; current = current->next) {
    181176                                for (int i = 0; i < iface->props.addrs_count; i++) {
    182177                                        struct in6_addr cmp_addr = iface->props.if_addrs[i];
     
    188183                                        }
    189184                                }
    190                                 if(NULL != iface->props.if_addr_rasrc)
     185                                if (NULL != iface->props.if_addr_rasrc)
    191186                                        break;
    192187                        }
     
    222217        return 0;
    223218}
    224 
  • src/router/radvd/device-linux.c

    r32089 r32663  
    1414
    1515#include "config.h"
     16#include "defaults.h"
    1617#include "includes.h"
     18#include "netlink.h"
     19#include "pathnames.h"
    1720#include "radvd.h"
    18 #include "defaults.h"
    19 #include "pathnames.h"
    20 #include "netlink.h"
    2121
    2222#ifndef IPV6_ADDR_LINKLOCAL
    23 #define IPV6_ADDR_LINKLOCAL   0x0020U
     23#define IPV6_ADDR_LINKLOCAL 0x0020U
    2424#endif
    2525
    2626#ifndef ARPHRD_6LOWPAN
    27 #define ARPHRD_6LOWPAN  825     /* IPv6 over LoWPAN */
     27#define ARPHRD_6LOWPAN 825 /* IPv6 over LoWPAN */
    2828#endif
    2929
     
    6363        iface->props.max_ra_option_size = iface->AdvRAMTU;
    6464        iface->props.max_ra_option_size = MIN(iface->props.max_ra_option_size, MAX(iface->sllao.if_maxmtu, RFC2460_MIN_MTU));
    65         iface->props.max_ra_option_size = MIN(iface->props.max_ra_option_size, MAX(get_interface_linkmtu(iface->props.name), RFC2460_MIN_MTU));
     65        iface->props.max_ra_option_size =
     66            MIN(iface->props.max_ra_option_size, MAX(get_interface_linkmtu(iface->props.name), RFC2460_MIN_MTU));
    6667
    6768        if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) {
     
    7677                iface->sllao.if_hwaddr_len = 48;
    7778                iface->sllao.if_prefix_len = 64;
    78                 /* *INDENT-OFF* */
    7979                char hwaddr[3 * 6];
    80                 sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
    81                         (unsigned char)ifr.ifr_hwaddr.sa_data[0],
    82                         (unsigned char)ifr.ifr_hwaddr.sa_data[1],
    83                         (unsigned char)ifr.ifr_hwaddr.sa_data[2],
    84                         (unsigned char)ifr.ifr_hwaddr.sa_data[3],
    85                         (unsigned char)ifr.ifr_hwaddr.sa_data[4],
     80                sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x", (unsigned char)ifr.ifr_hwaddr.sa_data[0],
     81                        (unsigned char)ifr.ifr_hwaddr.sa_data[1], (unsigned char)ifr.ifr_hwaddr.sa_data[2],
     82                        (unsigned char)ifr.ifr_hwaddr.sa_data[3], (unsigned char)ifr.ifr_hwaddr.sa_data[4],
    8683                        (unsigned char)ifr.ifr_hwaddr.sa_data[5]);
    87                 /* *INDENT-ON* */
    8884                dlog(LOG_DEBUG, 3, "%s hardware address: %s", iface->props.name, hwaddr);
    8985                iface->props.max_ra_option_size -= 14; /* RFC 2464 */
     
    9591                iface->props.max_ra_option_size -= 22; /* RFC 2109 */
    9692                break;
    97 #endif                          /* ARPHDR_FDDI */
     93#endif /* ARPHDR_FDDI */
    9894#ifdef ARPHRD_ARCNET
    9995        case ARPHRD_ARCNET:
     
    105101                iface->props.max_ra_option_size -= 0;
    106102                break;
    107 #endif                          /* ARPHDR_ARCNET */
     103#endif /* ARPHDR_ARCNET */
    108104        case ARPHRD_6LOWPAN:
    109105#ifdef HAVE_NETLINK
     
    207203                fclose(fp);
    208204        } else {
    209                 flog(LOG_DEBUG,
    210                      "Correct IPv6 MTU entry not found, " "perhaps the procfs is disabled, "
    211                      "or the kernel interface has changed?");
     205                flog(LOG_DEBUG, "Correct IPv6 MTU entry not found, "
     206                                "perhaps the procfs is disabled, "
     207                                "or the kernel interface has changed?");
    212208                value = 1280; /* RFC2460: section 5 */
    213209        }
     
    216212}
    217213
    218 int set_interface_linkmtu(const char *iface, uint32_t mtu)
    219 {
    220         return privsep_interface_linkmtu(iface, mtu);
    221 }
    222 
    223 int set_interface_curhlim(const char *iface, uint8_t hlim)
    224 {
    225         return privsep_interface_curhlim(iface, hlim);
    226 }
    227 
    228 int set_interface_reachtime(const char *iface, uint32_t rtime)
    229 {
    230         return privsep_interface_reachtime(iface, rtime);
    231 }
    232 
    233 int set_interface_retranstimer(const char *iface, uint32_t rettimer)
    234 {
    235         return privsep_interface_retranstimer(iface, rettimer);
    236 }
     214int set_interface_linkmtu(const char *iface, uint32_t mtu) { return privsep_interface_linkmtu(iface, mtu); }
     215
     216int set_interface_curhlim(const char *iface, uint8_t hlim) { return privsep_interface_curhlim(iface, hlim); }
     217
     218int set_interface_reachtime(const char *iface, uint32_t rtime) { return privsep_interface_reachtime(iface, rtime); }
     219
     220int set_interface_retranstimer(const char *iface, uint32_t rettimer) { return privsep_interface_retranstimer(iface, rettimer); }
    237221
    238222int check_ip6_forwarding(void)
     
    250234                fclose(fp);
    251235        } else {
    252                 flog(LOG_DEBUG,
    253                      "Correct IPv6 forwarding procfs entry not found, " "perhaps the procfs is disabled, "
    254                      "or the kernel interface has changed?");
     236                flog(LOG_DEBUG, "Correct IPv6 forwarding procfs entry not found, "
     237                                "perhaps the procfs is disabled, "
     238                                "or the kernel interface has changed?");
    255239                value = -1;
    256240        }
    257241
    258242#ifdef HAVE_SYSCTL
    259         int forw_sysctl[] = { SYSCTL_IP6_FORWARDING };
     243        int forw_sysctl[] = {SYSCTL_IP6_FORWARDING};
    260244        size_t size = sizeof(value);
    261245        if (!fp && sysctl(forw_sysctl, sizeof(forw_sysctl) / sizeof(forw_sysctl[0]), &value, &size, NULL, 0) < 0) {
    262                 flog(LOG_DEBUG,
    263                      "Correct IPv6 forwarding sysctl branch not found, " "perhaps the kernel interface has changed?");
    264                 return 0;       /* this is of advisory value only */
     246                flog(LOG_DEBUG, "Correct IPv6 forwarding sysctl branch not found, "
     247                                "perhaps the kernel interface has changed?");
     248                return 0; /* this is of advisory value only */
    265249        }
    266250#endif
  • src/router/radvd/gram.y

    r32089 r32663  
    9393%token          T_Base6to4Interface
    9494%token          T_UnicastOnly
     95%token          T_AdvRASolicitedUnicast
    9596
    9697%token          T_HomeAgentPreference
     
    332333                {
    333334                        iface->UnicastOnly = $2;
     335                }
     336                | T_AdvRASolicitedUnicast SWITCH ';'
     337                {
     338                        iface->AdvRASolicitedUnicast = $2;
    334339                }
    335340                | T_AdvMobRtrSupportFlag SWITCH ';'
  • src/router/radvd/includes.h

    r29984 r32663  
    1717#include "config.h"
    1818
    19 #include <string.h>
    20 #include <stdio.h>
    21 #include <stdarg.h>
    22 #include <stdlib.h>
    23 #include <stdint.h>
    24 #include <time.h>
    25 #include <syslog.h>
    26 #include <unistd.h>
    2719#include <errno.h>
    28 #include <signal.h>
     20#include <grp.h>
    2921#include <netdb.h>
    3022#include <pwd.h>
    31 #include <grp.h>
     23#include <signal.h>
     24#include <stdarg.h>
     25#include <stdint.h>
     26#include <stdio.h>
     27#include <stdlib.h>
     28#include <string.h>
     29#include <syslog.h>
     30#include <time.h>
     31#include <unistd.h>
    3232
    3333#include <sys/types.h>
     
    6363#include <sys/uio.h>
    6464
     65#include <fcntl.h>
    6566#include <sys/stat.h>
    66 #include <fcntl.h>
    6767
    6868#include <netinet/in.h>
    6969
     70#include <netinet/icmp6.h>
    7071#include <netinet/ip6.h>
    71 #include <netinet/icmp6.h>
    7272
    7373#include <arpa/inet.h>
     
    8787#endif
    8888
    89 #if defined(HAVE_NET_IF_ARP_H) && !defined(ARPHRD_ETHER)
     89#if defined(HAVE_NET_IF_ARP_H) && !defined(ARPHRD_ETHER) && !defined(HAVE_LINUX_IF_ARP_H)
    9090#include <net/if_arp.h>
    91 #endif                          /* defined(HAVE_NET_IF_ARP_H) && !defined(ARPHRD_ETHER) */
     91#endif /* defined(HAVE_NET_IF_ARP_H) && !defined(ARPHRD_ETHER) */
    9292
    9393#ifdef HAVE_SYS_SOCKIO_H
     
    108108#include <linux/if_arp.h>
    109109#endif
    110 
  • src/router/radvd/install-sh

    r29984 r32663  
    22# install - install a program, script, or datafile
    33
    4 scriptversion=2013-12-25.23; # UTC
     4scriptversion=2014-09-12.12; # UTC
    55
    66# This originates from X11R5 (mit/util/scripts/install.sh), which was
     
    325325            ;;
    326326          *)
     327            # $RANDOM is not portable (e.g. dash);  use it when possible to
     328            # lower collision chance
    327329            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
    328             trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
    329 
     330            trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
     331
     332            # As "mkdir -p" follows symlinks and we work in /tmp possibly;  so
     333            # create the $tmpdir first (and fail if unsuccessful) to make sure
     334            # that nobody tries to guess the $tmpdir name.
    330335            if (umask $mkdir_umask &&
    331                 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
     336                $mkdirprog $mkdir_mode "$tmpdir" &&
     337                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
    332338            then
    333339              if test -z "$dir_arg" || {
     
    336342                   # other-writable bit of parent directory when it shouldn't.
    337343                   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
    338                    ls_ld_tmpdir=`ls -ld "$tmpdir"`
     344                   test_tmpdir="$tmpdir/a"
     345                   ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
    339346                   case $ls_ld_tmpdir in
    340347                     d????-?r-*) different_mode=700;;
     
    342349                     *) false;;
    343350                   esac &&
    344                    $mkdirprog -m$different_mode -p -- "$tmpdir" && {
    345                      ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
     351                   $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
     352                     ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
    346353                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
    347354                   }
     
    349356              then posix_mkdir=:
    350357              fi
    351               rmdir "$tmpdir/d" "$tmpdir"
     358              rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
    352359            else
    353360              # Remove any dirs left behind by ancient mkdir implementations.
    354               rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
     361              rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
    355362            fi
    356363            trap '' 0;;
  • src/router/radvd/interface.c

    r32089 r32663  
    1414
    1515#include "config.h"
     16#include "defaults.h"
    1617#include "includes.h"
    1718#include "radvd.h"
    18 #include "defaults.h"
    19 
    20 #define IFACE_SETUP_DELAY       1
     19
     20#define IFACE_SETUP_DELAY 1
    2121
    2222void iface_init_defaults(struct Interface *iface)
     
    3232        iface->MinDelayBetweenRAs = DFLT_MinDelayBetweenRAs;
    3333        iface->MinRtrAdvInterval = -1;
     34        iface->UnicastOnly = DFLT_UnicastOnly;
     35        iface->AdvRASolicitedUnicast = DFLT_AdvRASolicitedUnicast;
    3436
    3537        iface->ra_header_info.AdvDefaultPreference = DFLT_AdvDefaultPreference;
     
    4850        iface->AdvLinkMTU = DFLT_AdvLinkMTU;
    4951        iface->AdvRAMTU = DFLT_AdvRAMTU;
    50 
    51 }
    52 
    53 
    54 void touch_iface(struct Interface * iface)
     52}
     53
     54void touch_iface(struct Interface *iface)
    5555{
    5656        iface->state_info.changed = 1;
     
    9393
    9494        /* Check if we a usable RA source address */
    95         if(iface->props.if_addr_rasrc == NULL) {
     95        if (iface->props.if_addr_rasrc == NULL) {
    9696                dlog(LOG_DEBUG, 5, "no configured AdvRASrcAddress present, skipping send");
    9797                return -1;
     
    176176                iface->MinRtrAdvInterval = DFLT_MinRtrAdvInterval(iface);
    177177
    178         if ((iface->MinRtrAdvInterval < (MIPv6 ? MIN_MinRtrAdvInterval_MIPv6 : MIN_MinRtrAdvInterval))
    179             || (iface->MinRtrAdvInterval > MAX_MinRtrAdvInterval(iface))) {
     178        if ((iface->MinRtrAdvInterval < (MIPv6 ? MIN_MinRtrAdvInterval_MIPv6 : MIN_MinRtrAdvInterval)) ||
     179            (iface->MinRtrAdvInterval > MAX_MinRtrAdvInterval(iface))) {
    180180                flog(LOG_ERR,
    181181                     "MinRtrAdvInterval for %s (%.2f) must be at least %.2f but no more than 3/4 of MaxRtrAdvInterval (%.2f)",
    182                      iface->props.name, iface->MinRtrAdvInterval, MIPv6 ? MIN_MinRtrAdvInterval_MIPv6 : (int)MIN_MinRtrAdvInterval,
    183                      MAX_MinRtrAdvInterval(iface));
    184                 res = -1;
    185         }
    186 
    187         if ((iface->MaxRtrAdvInterval < (MIPv6 ? MIN_MaxRtrAdvInterval_MIPv6 : MIN_MaxRtrAdvInterval))
    188             || (iface->MaxRtrAdvInterval > MAX_MaxRtrAdvInterval)) {
    189                 flog(LOG_ERR,
    190                      "MaxRtrAdvInterval for %s (%.2f) must be between %.2f and %d",
    191                      iface->props.name, iface->MaxRtrAdvInterval, MIPv6 ? MIN_MaxRtrAdvInterval_MIPv6 : (int)MIN_MaxRtrAdvInterval,
     182                     iface->props.name, iface->MinRtrAdvInterval,
     183                     MIPv6 ? MIN_MinRtrAdvInterval_MIPv6 : (int)MIN_MinRtrAdvInterval, MAX_MinRtrAdvInterval(iface));
     184                res = -1;
     185        }
     186
     187        if ((iface->MaxRtrAdvInterval < (MIPv6 ? MIN_MaxRtrAdvInterval_MIPv6 : MIN_MaxRtrAdvInterval)) ||
     188            (iface->MaxRtrAdvInterval > MAX_MaxRtrAdvInterval)) {
     189                flog(LOG_ERR, "MaxRtrAdvInterval for %s (%.2f) must be between %.2f and %d", iface->props.name,
     190                     iface->MaxRtrAdvInterval, MIPv6 ? MIN_MaxRtrAdvInterval_MIPv6 : (int)MIN_MaxRtrAdvInterval,
    192191                     MAX_MaxRtrAdvInterval);
    193192                res = -1;
     
    195194
    196195        if (iface->MinDelayBetweenRAs < (MIPv6 ? MIN_DELAY_BETWEEN_RAS_MIPv6 : MIN_DELAY_BETWEEN_RAS)) {
    197                 flog(LOG_ERR,
    198                      "MinDelayBetweenRAs for %s (%.2f) must be at least %.2f", iface->props.name, iface->MinDelayBetweenRAs,
    199                      MIPv6 ? MIN_DELAY_BETWEEN_RAS_MIPv6 : MIN_DELAY_BETWEEN_RAS);
    200                 res = -1;
    201         }
    202 
    203         if ((iface->AdvLinkMTU != 0)
    204             && ((iface->AdvLinkMTU < MIN_AdvLinkMTU)
    205                 || (iface->sllao.if_maxmtu != -1 && (iface->AdvLinkMTU > iface->sllao.if_maxmtu)))) {
     196                flog(LOG_ERR, "MinDelayBetweenRAs for %s (%.2f) must be at least %.2f", iface->props.name,
     197                     iface->MinDelayBetweenRAs, MIPv6 ? MIN_DELAY_BETWEEN_RAS_MIPv6 : MIN_DELAY_BETWEEN_RAS);
     198                res = -1;
     199        }
     200
     201        if ((iface->AdvLinkMTU != 0) && ((iface->AdvLinkMTU < MIN_AdvLinkMTU) ||
     202                                         (iface->sllao.if_maxmtu != -1 && (iface->AdvLinkMTU > iface->sllao.if_maxmtu)))) {
    206203                flog(LOG_ERR, "AdvLinkMTU for %s (%u) must be zero or between %u and %u", iface->props.name, iface->AdvLinkMTU,
    207204                     MIN_AdvLinkMTU, iface->sllao.if_maxmtu);
     
    218215                iface->ra_header_info.AdvDefaultLifetime = DFLT_AdvDefaultLifetime(iface);
    219216
    220         if ((iface->ra_header_info.AdvDefaultLifetime != 0)
    221             && ((iface->ra_header_info.AdvDefaultLifetime > MAX_AdvDefaultLifetime)
    222                 || (iface->ra_header_info.AdvDefaultLifetime < MIN_AdvDefaultLifetime(iface)))) {
     217        if ((iface->ra_header_info.AdvDefaultLifetime != 0) &&
     218            ((iface->ra_header_info.AdvDefaultLifetime > MAX_AdvDefaultLifetime) ||
     219            (iface->ra_header_info.AdvDefaultLifetime < MIN_AdvDefaultLifetime(iface)))) {
    223220                flog(LOG_ERR, "AdvDefaultLifetime for %s (%u) must be zero or between %u and %u", iface->props.name,
    224221                     iface->ra_header_info.AdvDefaultLifetime, (int)MIN_AdvDefaultLifetime(iface), MAX_AdvDefaultLifetime);
     
    232229        /* Mobile IPv6 ext */
    233230        if (iface->mipv6.AdvHomeAgentInfo) {
    234                 if ((iface->mipv6.HomeAgentLifetime > MAX_HomeAgentLifetime) || (iface->mipv6.HomeAgentLifetime < MIN_HomeAgentLifetime)) {
    235                         flog(LOG_ERR,
    236                             "HomeAgentLifetime for %s (%u) must be between %u and %u", iface->props.name,
     231                if ((iface->mipv6.HomeAgentLifetime > MAX_HomeAgentLifetime) ||
     232                    (iface->mipv6.HomeAgentLifetime < MIN_HomeAgentLifetime)) {
     233                        flog(LOG_ERR, "HomeAgentLifetime for %s (%u) must be between %u and %u", iface->props.name,
    237234                             iface->mipv6.HomeAgentLifetime, MIN_HomeAgentLifetime, MAX_HomeAgentLifetime);
    238235                        res = -1;
     
    259256
    260257                if (prefix->AdvPreferredLifetime > prefix->AdvValidLifetime) {
    261                         flog(LOG_ERR, "AdvValidLifetime for %s (%u) must be " "greater than AdvPreferredLifetime for",
     258                        flog(LOG_ERR, "AdvValidLifetime for %s (%u) must be "
     259                                      "greater than AdvPreferredLifetime for",
    262260                             iface->props.name, prefix->AdvValidLifetime);
    263261                        res = -1;
     
    285283                 * - default route is added and then deleted.
    286284                 */
    287                 if(IN6_IS_ADDR_UNSPECIFIED(&(route->Prefix))) {
     285                if (IN6_IS_ADDR_UNSPECIFIED(&(route->Prefix))) {
    288286                        int route_zerolife = (route->AdvRouteLifetime == 0);
    289287                        int defaultroute_zerolife = (iface->ra_header_info.AdvDefaultLifetime == 0);
    290                         if( route_zerolife ^ defaultroute_zerolife ) {
    291                                 flog(LOG_ERR, "route 0::/0 lifetime (%u) conflicts with AdvDefaultLifetime (%u), default routes will flap!",
    292                                                 route->AdvRouteLifetime, iface->ra_header_info.AdvDefaultLifetime);
     288                        if (route_zerolife ^ defaultroute_zerolife) {
     289                                flog(
     290                                    LOG_ERR,
     291                                    "route 0::/0 lifetime (%u) conflicts with AdvDefaultLifetime (%u), default routes will flap!",
     292                                    route->AdvRouteLifetime, iface->ra_header_info.AdvDefaultLifetime);
    293293                                // res = -1; // In some future version, abort on this configuration error.
    294294                        }
     
    356356        } else
    357357#endif
    358         if (iface->state_info.racount < MAX_INITIAL_RTR_ADVERTISEMENTS) {
     358            if (iface->state_info.racount < MAX_INITIAL_RTR_ADVERTISEMENTS) {
    359359                next = min(MAX_INITIAL_RTR_ADVERT_INTERVAL, iface->MaxRtrAdvInterval);
    360360        }
     
    365365}
    366366
    367 void for_each_iface(struct Interface *ifaces, void (*foo) (struct Interface *, void *), void *data)
     367void for_each_iface(struct Interface *ifaces, void (*foo)(struct Interface *, void *), void *data)
    368368{
    369369        for (; ifaces; ifaces = ifaces->next) {
  • src/router/radvd/log.c

    r32089 r32663  
    1717#include "radvd.h"
    1818
    19 __attribute__ ((format(printf, 2, 0)))
    20 static int vlog(int prio, char const *format, va_list ap);
     19__attribute__((format(printf, 2, 0))) static int vlog(int prio, char const *format, va_list ap);
    2120
    2221static int log_method = L_NONE;
     
    3736                break;
    3837        case L_STDERR_CLEAN:
    39                 /* fallthrough */
     38        /* fallthrough */
    4039        case L_STDERR_SYSLOG:
    41                 /* fallthrough */
     40        /* fallthrough */
    4241        case L_SYSLOG:
    4342                if (facility == -1)
     
    6867
    6968/* note: [dfv]log() is also called from root context */
    70 __attribute__ ((format(printf, 2, 0)))
    71 static int vlog(int prio, char const *format, va_list ap)
     69__attribute__((format(printf, 2, 0))) static int vlog(int prio, char const *format, va_list ap)
    7270{
    7371        char tstamp[64], buff[1024];
     
    8583        case L_STDERR_SYSLOG:
    8684                syslog(prio, "%s", buff);
    87                 if (prio > LOG_ERR)     /* fall through for messages with high priority */
     85                if (debug_level < prio) /* fall through for messages with high priority */
    8886                        break;
    8987        case L_STDERR:
     
    156154}
    157155
    158 void set_debuglevel(int level)
    159 {
    160         debug_level = level;
    161 }
     156void set_debuglevel(int level) { debug_level = level; }
    162157
    163 int get_debuglevel(void)
    164 {
    165         return debug_level;
    166 }
     158int get_debuglevel(void) { return debug_level; }
  • src/router/radvd/log.h

    r32089 r32663  
    22 *
    33 *   Authors:
    4  *    Lars Fenneberg            <lf@elemental.net>       
     4 *    Lars Fenneberg            <lf@elemental.net>
    55 *
    6  *   This software is Copyright 1996,1997 by the above mentioned author(s), 
     6 *   This software is Copyright 1996,1997 by the above mentioned author(s),
    77 *   All Rights Reserved.
    88 *
     
    1515#pragma once
    1616
    17 #define L_NONE          0
    18 #define L_SYSLOG        1
    19 #define L_STDERR        2
    20 #define L_STDERR_SYSLOG 3
    21 #define L_LOGFILE       4
    22 #define L_STDERR_CLEAN  5
     17#define L_NONE 0
     18#define L_SYSLOG 1
     19#define L_STDERR 2
     20#define L_STDERR_SYSLOG 3
     21#define L_LOGFILE 4
     22#define L_STDERR_CLEAN 5
    2323
    2424#define LOG_TIME_FORMAT "%b %d %H:%M:%S"
    2525
    2626int log_open(int, char const *, char const *, int);
    27 void flog(int, char const *, ...) __attribute__ ((format(printf, 2, 3)));
    28 void dlog(int, int, char const *, ...) __attribute__ ((format(printf, 3, 4)));
     27void flog(int, char const *, ...) __attribute__((format(printf, 2, 3)));
     28void dlog(int, int, char const *, ...) __attribute__((format(printf, 3, 4)));
    2929int log_close(void);
    3030int log_reopen(void);
    3131void set_debuglevel(int);
    3232int get_debuglevel(void);
    33 
  • src/router/radvd/netlink.c

    r32122 r32663  
    22 *
    33 *   Authors:
    4  *    Lars Fenneberg            <lf@elemental.net>       
     4 *    Lars Fenneberg            <lf@elemental.net>
    55 *    Reuben Hawkins            <reubenhwk@gmail.com>
    66 *
    7  *   This software is Copyright 1996,1997 by the above mentioned author(s), 
     7 *   This software is Copyright 1996,1997 by the above mentioned author(s),
    88 *   All Rights Reserved.
    99 *
     
    1414 */
    1515
     16#include "netlink.h"
    1617#include "config.h"
     18#include "log.h"
    1719#include "radvd.h"
    18 #include "log.h"
    19 #include "netlink.h"
    2020
    2121#include <asm/types.h>
    22 #include <sys/socket.h>
     22#include <errno.h>
    2323#include <linux/netlink.h>
    2424#include <linux/rtnetlink.h>
     
    2626#include <stdio.h>
    2727#include <stdlib.h>
    28 #include <errno.h>
    2928#include <string.h>
    30 
    31 #ifndef SOL_NETLINK
    32 #define SOL_NETLINK     270
    33 #endif
     29#include <sys/socket.h>
     30
    3431#ifndef RTM_SETLINK
    3532#define RTM_SETLINK (RTM_BASE+3)
     
    4037#endif
    4138
     39#ifndef SOL_NETLINK
     40#define SOL_NETLINK 270
     41#endif
     42
    4243struct iplink_req {
    43         struct nlmsghdr         n;
    44         struct ifinfomsg        i;
    45         char                    buf[1024];
     44        struct nlmsghdr n;
     45        struct ifinfomsg i;
     46        char buf[1024];
    4647};
    4748
     
    4950{
    5051        struct iplink_req req = {};
    51         struct iovec iov = { &req, sizeof(req) };
     52        struct iovec iov = {&req, sizeof(req)};
    5253        struct sockaddr_nl sa = {};
    53         struct msghdr msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 };
     54        struct msghdr msg = {(void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0};
    5455        int sock, len, addr_len = -1;
    5556        unsigned short type;
     
    102103}
    103104
    104 void process_netlink_msg(int sock, struct Interface * ifaces)
     105void process_netlink_msg(int sock, struct Interface *ifaces)
    105106{
    106107        char buf[4096];
    107         struct iovec iov = { buf, sizeof(buf) };
     108        struct iovec iov = {buf, sizeof(buf)};
    108109        struct sockaddr_nl sa;
    109         struct msghdr msg = {
    110                         .msg_name = (void*)&sa,
    111                         .msg_namelen = sizeof(sa),
    112                         .msg_iov = &iov,
    113                         .msg_iovlen = 1,
    114                         .msg_control = NULL,
    115                         .msg_controllen = 0,
    116                         .msg_flags = 0
    117         };
     110        struct msghdr msg = {(void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0};
    118111        int len = recvmsg(sock, &msg, 0);
    119112        if (len == -1) {
     
    121114        }
    122115
    123         for (struct nlmsghdr * nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len)) {
     116        for (struct nlmsghdr *nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len)) {
    124117                char ifnamebuf[IF_NAMESIZE];
    125118                /* The end of multipart message. */
     
    136129                        struct ifinfomsg *ifinfo = (struct ifinfomsg *)NLMSG_DATA(nh);
    137130                        const char *ifname = if_indextoname(ifinfo->ifi_index, ifnamebuf);
    138 
    139131#ifdef IFLA_LINKINFO
    140132                        struct rtattr *rta = IFLA_RTA(NLMSG_DATA(nh));
     
    154146                        }
    155147#endif
     148
    156149                        /* Reinit the interfaces which need it. */
    157150                        struct Interface *iface;
     
    193186
    194187                                if (count != iface->props.addrs_count ||
    195                                         0 != memcmp(if_addrs, iface->props.if_addrs, count * sizeof(struct in6_addr))) {
    196                                         dlog(LOG_DEBUG, 3, "netlink: %s, ifindex %d, addresses are different",
    197                                                 ifname, ifaddr->ifa_index);
     188                                    0 != memcmp(if_addrs, iface->props.if_addrs, count * sizeof(struct in6_addr))) {
     189                                        dlog(LOG_DEBUG, 3, "netlink: %s, ifindex %d, addresses are different", ifname,
     190                                            ifaddr->ifa_index);
    198191                                        touch_iface(iface);
    199192                                } else {
    200                                         dlog(LOG_DEBUG, 3, "netlink: %s, ifindex %d, addresses are the same",
    201                                                 ifname, ifaddr->ifa_index);
     193                                        dlog(LOG_DEBUG, 3, "netlink: %s, ifindex %d, addresses are the same", ifname,
     194                                            ifaddr->ifa_index);
    202195                                }
    203196                                free(if_addrs);
    204197                        }
    205 
    206198                }
    207199        }
  • src/router/radvd/netlink.h

    r32089 r32663  
    22 *
    33 *   Authors:
    4  *    Lars Fenneberg            <lf@elemental.net>       
     4 *    Lars Fenneberg            <lf@elemental.net>
    55 *    Reuben Hawkins            <reubenhwk@gmail.com>
    66 *
    7  *   This software is Copyright 1996,1997 by the above mentioned author(s), 
     7 *   This software is Copyright 1996,1997 by the above mentioned author(s),
    88 *   All Rights Reserved.
    99 *
     
    1919
    2020int netlink_get_device_addr_len(struct Interface *iface);
    21 void process_netlink_msg(int sock, struct Interface * ifaces);
     21void process_netlink_msg(int sock, struct Interface *ifaces);
    2222int netlink_socket(void);
  • src/router/radvd/pathnames.h

    r26390 r32663  
    4141#define PROC_SYS_IP6_RETRANSTIMER_MS "/proc/sys/net/ipv6/neigh/%s/retrans_time_ms"
    4242#define PROC_SYS_IP6_RETRANSTIMER "/proc/sys/net/ipv6/neigh/%s/retrans_time"
    43 #else                           /* BSD */
     43#else /* BSD */
    4444#define SYSCTL_IP6_FORWARDING CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_FORWARDING
    4545#endif
  • src/router/radvd/privsep-linux.c

    r26390 r32663  
    1717#include "config.h"
    1818#include "includes.h"
     19#include "pathnames.h"
    1920#include "radvd.h"
    20 #include "pathnames.h"
    2121
    2222static int set_interface_var(const char *iface, const char *var, const char *name, uint32_t val);
     
    2626static int pfd = -1;
    2727
    28 void privsep_set_write_fd(int fd)
    29 {
    30         pfd = fd;
    31 }
     28void privsep_set_write_fd(int fd) { pfd = fd; }
    3229
    3330/* Command types */
     
    7168                case SET_INTERFACE_LINKMTU:
    7269                        if (cmd.val < MIN_AdvLinkMTU || cmd.val > MAX_AdvLinkMTU) {
    73                                 flog(LOG_ERR, "(privsep) %s: LinkMTU (%u) is not within the defined bounds, ignoring",
    74                                      cmd.iface, cmd.val);
     70                                flog(LOG_ERR, "(privsep) %s: LinkMTU (%u) is not within the defined bounds, ignoring", cmd.iface,
     71                                     cmd.val);
    7572                                break;
    7673                        }
     
    8986                case SET_INTERFACE_REACHTIME:
    9087                        if (cmd.val < MIN_AdvReachableTime || cmd.val > MAX_AdvReachableTime) {
    91                                 flog(LOG_ERR,
    92                                      "(privsep) %s: BaseReachableTimer (%u) is not within the defined bounds, ignoring",
     88                                flog(LOG_ERR, "(privsep) %s: BaseReachableTimer (%u) is not within the defined bounds, ignoring",
    9389                                     cmd.iface, cmd.val);
    9490                                break;
    9591                        }
    96                         ret =
    97                             set_interface_var(cmd.iface, PROC_SYS_IP6_BASEREACHTIME_MS, "BaseReachableTimer (ms)", cmd.val);
     92                        ret = set_interface_var(cmd.iface, PROC_SYS_IP6_BASEREACHTIME_MS, "BaseReachableTimer (ms)", cmd.val);
    9893                        if (ret == 0)
    9994                                break;
     
    110105                        if (ret == 0)
    111106                                break;
    112                         set_interface_var(cmd.iface, PROC_SYS_IP6_RETRANSTIMER, "RetransTimer", cmd.val / 1000 * USER_HZ);      /* XXX user_hz */
     107                        set_interface_var(cmd.iface, PROC_SYS_IP6_RETRANSTIMER, "RetransTimer",
     108                                          cmd.val / 1000 * USER_HZ); /* XXX user_hz */
    113109                        break;
    114110
     
    179175{
    180176        int retval = -1;
    181         FILE * fp = 0;
    182         char * spath = strdupf(var, iface);
     177        FILE *fp = 0;
     178        char *spath = strdupf(var, iface);
    183179
    184180        /* No path traversal */
     
    210206        return retval;
    211207}
    212 
  • src/router/radvd/process.c

    r32089 r32663  
    2525             struct in6_pktinfo *pkt_info, int hoplimit)
    2626{
    27         char if_namebuf[IF_NAMESIZE] = { "" };
     27        char if_namebuf[IF_NAMESIZE] = {""};
    2828        char *if_name = if_indextoname(pkt_info->ipi6_ifindex, if_namebuf);
    2929        if (!if_name) {
     
    6262        if (icmph->icmp6_type == ND_ROUTER_ADVERT) {
    6363                if (len < sizeof(struct nd_router_advert)) {
    64                         flog(LOG_WARNING, "%s received icmpv6 RA packet with invalid length (%d) from %s", if_name, len, addr_str);
     64                        flog(LOG_WARNING, "%s received icmpv6 RA packet with invalid length (%d) from %s", if_name, len,
     65                             addr_str);
    6566                        return;
    6667                }
    6768
    6869                if (!IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr)) {
    69                         flog(LOG_WARNING, "%s received icmpv6 RA packet with non-linklocal source address from %s", if_name, addr_str);
     70                        flog(LOG_WARNING, "%s received icmpv6 RA packet with non-linklocal source address from %s", if_name,
     71                             addr_str);
    7072                        return;
    7173                }
     
    7476        if (icmph->icmp6_type == ND_ROUTER_SOLICIT) {
    7577                if (len < sizeof(struct nd_router_solicit)) {
    76                         flog(LOG_WARNING, "%s received icmpv6 RS packet with invalid length (%d) from %s", if_name, len, addr_str);
     78                        flog(LOG_WARNING, "%s received icmpv6 RS packet with invalid length (%d) from %s", if_name, len,
     79                             addr_str);
    7780                        return;
    7881                }
     
    9598
    9699        if (!iface->state_info.ready && (0 != setup_iface(sock, iface))) {
    97                 flog(LOG_WARNING, "%s received RS or RA on %s but %s is not ready and setup_iface failed", if_name, iface->props.name,
    98                      iface->props.name);
     100                flog(LOG_WARNING, "%s received RS or RA on %s but %s is not ready and setup_iface failed", if_name,
     101                     iface->props.name, iface->props.name);
    99102                return;
    100103        }
     
    120123static void process_rs(int sock, struct Interface *iface, unsigned char *msg, int len, struct sockaddr_in6 *addr)
    121124{
     125        /* RFC 7772, section 5.1:
     126         * 5.1.  Network-Side Recommendations
     127         *    1.  Router manufacturers SHOULD allow network administrators to
     128         *        configure the routers to respond to Router Solicitations with
     129         *        unicast Router Advertisements if:
     130         *        *  The Router Solicitation's source address is not the
     131         *           unspecified address, and:
     132         *        *  The solicitation contains a valid Source Link-Layer Address
     133         *           option.
     134         *
     135         * However, testing shows that many clients do not set the SLLA option:
     136         * https://github.com/reubenhwk/radvd/issues/63#issuecomment-287172252
     137         * As of 2017/03/16:
     138         * - macOS 10.12.3 sierra - sends SLLA 2 times out of 4
     139         * - iOS 10.2.1 (iPhone 5s) - no SLLA
     140         * - Android 7.0 (sony xperia phone) - sends SLLA
     141         * - Android 5.1 (nexus 7 tablet) - sends SLLA
     142         * - Ubuntu 16.04.2 LTS w/ Network Manager, running 4.9 kernel (dell laptop) - no SLLA
     143         * - Windows 10 (dell laptop) - no SLLA
     144         *
     145         * We decide to ignore the SLLA option for now, and only require the
     146         * unspecified address check. Clients that did not set the SLLA option will
     147         * trigger a neighbour solicit to the solicited-node address trying to
     148         * resolve the link-local address to, this would still be less traffic than
     149         * the all-nodes multicast.
     150         */
     151        int rfc7772_unicast_response = iface->AdvRASolicitedUnicast && !IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr);
     152
    122153        /* validation */
    123154        len -= sizeof(struct nd_router_solicit);
    124155
    125         uint8_t *opt_str = (uint8_t *) (msg + sizeof(struct nd_router_solicit));
     156        uint8_t *opt_str = (uint8_t *)(msg + sizeof(struct nd_router_solicit));
    126157
    127158        while (len > 0) {
     
    156187        double const delay = (MAX_RA_DELAY_SECONDS * rand() / (RAND_MAX + 1.0));
    157188
    158         if (iface->UnicastOnly) {
     189        if (iface->UnicastOnly || rfc7772_unicast_response) {
    159190                send_ra_forall(sock, iface, &addr->sin6_addr);
    160191        } else if (timespecdiff(&ts, &iface->times.last_multicast) / 1000.0 < iface->MinDelayBetweenRAs) {
    161192                /* last RA was sent only a few moments ago, don't send another immediately. */
    162                 double next =
    163                     iface->MinDelayBetweenRAs - (ts.tv_sec + ts.tv_nsec / 1000000000.0) + (iface->times.last_multicast.tv_sec +
    164                                                                                         iface->times.last_multicast.tv_nsec /
    165                                                                                         1000000000.0) + delay;
     193                double next = iface->MinDelayBetweenRAs - (ts.tv_sec + ts.tv_nsec / 1000000000.0) +
     194                              (iface->times.last_multicast.tv_sec + iface->times.last_multicast.tv_nsec / 1000000000.0) + delay;
    166195                dlog(LOG_DEBUG, 5, "%s: rate limiting RA's, rescheduling RA %f seconds from now", iface->props.name, next);
    167196                reschedule_iface(iface, next);
     
    185214        struct nd_router_advert *radvert = (struct nd_router_advert *)msg;
    186215
    187         if ((radvert->nd_ra_curhoplimit && iface->ra_header_info.AdvCurHopLimit) && (radvert->nd_ra_curhoplimit != iface->ra_header_info.AdvCurHopLimit)) {
     216        if ((radvert->nd_ra_curhoplimit && iface->ra_header_info.AdvCurHopLimit) &&
     217            (radvert->nd_ra_curhoplimit != iface->ra_header_info.AdvCurHopLimit)) {
    188218                flog(LOG_WARNING, "our AdvCurHopLimit on %s doesn't agree with %s", iface->props.name, addr_str);
    189219        }
     
    199229        /* note: we don't check the default router preference here, because they're likely different */
    200230
    201         if ((radvert->nd_ra_reachable && iface->ra_header_info.AdvReachableTime)
    202             && (ntohl(radvert->nd_ra_reachable) != iface->ra_header_info.AdvReachableTime)) {
     231        if ((radvert->nd_ra_reachable && iface->ra_header_info.AdvReachableTime) &&
     232            (ntohl(radvert->nd_ra_reachable) != iface->ra_header_info.AdvReachableTime)) {
    203233                flog(LOG_WARNING, "our AdvReachableTime on %s doesn't agree with %s", iface->props.name, addr_str);
    204234        }
    205235
    206         if ((radvert->nd_ra_retransmit && iface->ra_header_info.AdvRetransTimer)
    207             && (ntohl(radvert->nd_ra_retransmit) != iface->ra_header_info.AdvRetransTimer)) {
     236        if ((radvert->nd_ra_retransmit && iface->ra_header_info.AdvRetransTimer) &&
     237            (ntohl(radvert->nd_ra_retransmit) != iface->ra_header_info.AdvRetransTimer)) {
    208238                flog(LOG_WARNING, "our AdvRetransTimer on %s doesn't agree with %s", iface->props.name, addr_str);
    209239        }
     
    214244                return;
    215245
    216         uint8_t *opt_str = (uint8_t *) (msg + sizeof(struct nd_router_advert));
     246        uint8_t *opt_str = (uint8_t *)(msg + sizeof(struct nd_router_advert));
    217247
    218248        while (len > 0) {
     
    229259                        break;
    230260                } else if (optlen > len) {
    231                         flog(LOG_ERR, "option length (%d) greater than total" " length (%d) in RA on %s from %s", optlen,
    232                              len, iface->props.name, addr_str);
     261                        flog(LOG_ERR, "option length (%d) greater than total"
     262                                      " length (%d) in RA on %s from %s",
     263                             optlen, len, iface->props.name, addr_str);
    233264                        break;
    234265                }
    235266
    236267                switch (*opt_str) {
    237                 case ND_OPT_MTU:{
    238                                 struct nd_opt_mtu *mtu = (struct nd_opt_mtu *)opt_str;
    239                                 if (len < sizeof(*mtu))
    240                                         return;
    241 
    242                                 if (iface->AdvLinkMTU && (ntohl(mtu->nd_opt_mtu_mtu) != iface->AdvLinkMTU)) {
    243                                         flog(LOG_WARNING, "our AdvLinkMTU on %s doesn't agree with %s", iface->props.name,
    244                                              addr_str);
    245                                 }
    246                                 break;
     268                case ND_OPT_MTU: {
     269                        struct nd_opt_mtu *mtu = (struct nd_opt_mtu *)opt_str;
     270                        if (len < sizeof(*mtu))
     271                                return;
     272
     273                        if (iface->AdvLinkMTU && (ntohl(mtu->nd_opt_mtu_mtu) != iface->AdvLinkMTU)) {
     274                                flog(LOG_WARNING, "our AdvLinkMTU on %s doesn't agree with %s", iface->props.name, addr_str);
    247275                        }
    248                 case ND_OPT_PREFIX_INFORMATION:{
    249                                 struct nd_opt_prefix_info *pinfo = (struct nd_opt_prefix_info *)opt_str;
    250                                 if (len < sizeof(*pinfo))
    251                                         return;
    252                                 int preferred = ntohl(pinfo->nd_opt_pi_preferred_time);
    253                                 int valid = ntohl(pinfo->nd_opt_pi_valid_time);
    254 
    255                                 struct AdvPrefix *prefix = iface->AdvPrefixList;
    256                                 while (prefix) {
    257                                         char prefix_str[INET6_ADDRSTRLEN];
    258                                         if ((prefix->PrefixLen == pinfo->nd_opt_pi_prefix_len)
    259                                             && addr_match(&prefix->Prefix, &pinfo->nd_opt_pi_prefix, prefix->PrefixLen)) {
    260                                                 addrtostr(&prefix->Prefix, prefix_str, sizeof(prefix_str));
    261 
    262                                                 if (!prefix->DecrementLifetimesFlag && valid != prefix->AdvValidLifetime) {
    263                                                         flog(LOG_WARNING,
    264                                                              "our AdvValidLifetime on" " %s for %s doesn't agree with %s",
    265                                                              iface->props.name, prefix_str, addr_str);
    266                                                 }
    267                                                 if (!prefix->DecrementLifetimesFlag
    268                                                     && preferred != prefix->AdvPreferredLifetime) {
    269                                                         flog(LOG_WARNING,
    270                                                              "our AdvPreferredLifetime on"
    271                                                              " %s for %s doesn't agree with %s", iface->props.name, prefix_str,
    272                                                              addr_str);
    273                                                 }
     276                        break;
     277                }
     278                case ND_OPT_PREFIX_INFORMATION: {
     279                        struct nd_opt_prefix_info *pinfo = (struct nd_opt_prefix_info *)opt_str;
     280                        if (len < sizeof(*pinfo))
     281                                return;
     282                        int preferred = ntohl(pinfo->nd_opt_pi_preferred_time);
     283                        int valid = ntohl(pinfo->nd_opt_pi_valid_time);
     284
     285                        struct AdvPrefix *prefix = iface->AdvPrefixList;
     286                        while (prefix) {
     287                                char prefix_str[INET6_ADDRSTRLEN];
     288                                if ((prefix->PrefixLen == pinfo->nd_opt_pi_prefix_len) &&
     289                                    addr_match(&prefix->Prefix, &pinfo->nd_opt_pi_prefix, prefix->PrefixLen)) {
     290                                        addrtostr(&prefix->Prefix, prefix_str, sizeof(prefix_str));
     291
     292                                        if (!prefix->DecrementLifetimesFlag && valid != prefix->AdvValidLifetime) {
     293                                                flog(LOG_WARNING, "our AdvValidLifetime on"
     294                                                                  " %s for %s doesn't agree with %s",
     295                                                     iface->props.name, prefix_str, addr_str);
    274296                                        }
    275 
    276                                         prefix = prefix->next;
    277                                 }
    278                                 break;
     297                                        if (!prefix->DecrementLifetimesFlag && preferred != prefix->AdvPreferredLifetime) {
     298                                                flog(LOG_WARNING, "our AdvPreferredLifetime on"
     299                                                                  " %s for %s doesn't agree with %s",
     300                                                     iface->props.name, prefix_str, addr_str);
     301                                        }
     302                                }
     303
     304                                prefix = prefix->next;
    279305                        }
     306                        break;
     307                }
    280308                case ND_OPT_ROUTE_INFORMATION:
    281309                        /* not checked: these will very likely vary a lot */
     
    288316                        flog(LOG_ERR, "invalid option %d in RA on %s from %s", (int)*opt_str, iface->props.name, addr_str);
    289317                        break;
    290                         /* Mobile IPv6 extensions */
     318                /* Mobile IPv6 extensions */
    291319                case ND_OPT_RTR_ADV_INTERVAL:
    292320                case ND_OPT_HOME_AGENT_INFO:
    293321                        /* not checked */
    294322                        break;
    295                 case ND_OPT_RDNSS_INFORMATION:{
    296                                 char rdnss_str[INET6_ADDRSTRLEN];
    297                                 struct AdvRDNSS *rdnss = 0;
    298                                 struct nd_opt_rdnss_info_local *rdnssinfo = (struct nd_opt_rdnss_info_local *)opt_str;
    299                                 if (len < sizeof(*rdnssinfo))
     323                case ND_OPT_RDNSS_INFORMATION: {
     324                        char rdnss_str[INET6_ADDRSTRLEN];
     325                        struct AdvRDNSS *rdnss = 0;
     326                        struct nd_opt_rdnss_info_local *rdnssinfo = (struct nd_opt_rdnss_info_local *)opt_str;
     327                        if (len < sizeof(*rdnssinfo))
     328                                return;
     329                        int count = rdnssinfo->nd_opt_rdnssi_len;
     330
     331                        /* Check the RNDSS addresses received */
     332                        switch (count) {
     333                        case 7:
     334                                rdnss = iface->AdvRDNSSList;
     335                                if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr3)) {
     336                                        /* no match found in iface->AdvRDNSSList */
     337                                        addrtostr(&rdnssinfo->nd_opt_rdnssi_addr3, rdnss_str, sizeof(rdnss_str));
     338                                        flog(LOG_WARNING, "RDNSS address %s received on %s from %s is not advertised by us",
     339                                             rdnss_str, iface->props.name, addr_str);
     340                                }
     341                        /* FALLTHROUGH */
     342                        case 5:
     343                                rdnss = iface->AdvRDNSSList;
     344                                if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr2)) {
     345                                        /* no match found in iface->AdvRDNSSList */
     346                                        addrtostr(&rdnssinfo->nd_opt_rdnssi_addr2, rdnss_str, sizeof(rdnss_str));
     347                                        flog(LOG_WARNING, "RDNSS address %s received on %s from %s is not advertised by us",
     348                                             rdnss_str, iface->props.name, addr_str);
     349                                }
     350                        /* FALLTHROUGH */
     351                        case 3:
     352                                rdnss = iface->AdvRDNSSList;
     353                                if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr1)) {
     354                                        /* no match found in iface->AdvRDNSSList */
     355                                        addrtostr(&rdnssinfo->nd_opt_rdnssi_addr1, rdnss_str, sizeof(rdnss_str));
     356                                        flog(LOG_WARNING, "RDNSS address %s received on %s from %s is not advertised by us",
     357                                             rdnss_str, iface->props.name, addr_str);
     358                                }
     359
     360                                break;
     361                        default:
     362                                flog(LOG_ERR, "invalid len %i in RDNSS option on %s from %s", count, iface->props.name, addr_str);
     363                        }
     364
     365                        break;
     366                }
     367                case ND_OPT_DNSSL_INFORMATION: {
     368                        struct nd_opt_dnssl_info_local *dnsslinfo = (struct nd_opt_dnssl_info_local *)opt_str;
     369                        if (len < sizeof(*dnsslinfo))
     370                                return;
     371
     372                        for (int offset = 0; offset < (dnsslinfo->nd_opt_dnssli_len - 1) * 8;) {
     373                                char suffix[256] = {""};
     374                                if (&dnsslinfo->nd_opt_dnssli_suffixes[offset] - opt_str >= len)
    300375                                        return;
    301                                 int count = rdnssinfo->nd_opt_rdnssi_len;
    302 
    303                                 /* Check the RNDSS addresses received */
    304                                 switch (count) {
    305                                 case 7:
    306                                         rdnss = iface->AdvRDNSSList;
    307                                         if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr3)) {
    308                                                 /* no match found in iface->AdvRDNSSList */
    309                                                 addrtostr(&rdnssinfo->nd_opt_rdnssi_addr3, rdnss_str, sizeof(rdnss_str));
     376                                int label_len = dnsslinfo->nd_opt_dnssli_suffixes[offset++];
     377
     378                                if (label_len == 0) {
     379                                        /*
     380                                         * Ignore empty suffixes. They're
     381                                         * probably just padding...
     382                                         */
     383                                        if (suffix[0] == '\0')
     384                                                continue;
     385
     386                                        if (!check_dnssl_presence(iface->AdvDNSSLList, suffix)) {
    310387                                                flog(LOG_WARNING,
    311                                                      "RDNSS address %s received on %s from %s is not advertised by us",
    312                                                      rdnss_str, iface->props.name, addr_str);
     388                                                     "DNSSL suffix %s received on %s from %s is not advertised by us", suffix,
     389                                                     iface->props.name, addr_str);
    313390                                        }
    314                                         /* FALLTHROUGH */
    315                                 case 5:
    316                                         rdnss = iface->AdvRDNSSList;
    317                                         if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr2)) {
    318                                                 /* no match found in iface->AdvRDNSSList */
    319                                                 addrtostr(&rdnssinfo->nd_opt_rdnssi_addr2, rdnss_str, sizeof(rdnss_str));
    320                                                 flog(LOG_WARNING,
    321                                                      "RDNSS address %s received on %s from %s is not advertised by us",
    322                                                      rdnss_str, iface->props.name, addr_str);
    323                                         }
    324                                         /* FALLTHROUGH */
    325                                 case 3:
    326                                         rdnss = iface->AdvRDNSSList;
    327                                         if (!check_rdnss_presence(rdnss, &rdnssinfo->nd_opt_rdnssi_addr1)) {
    328                                                 /* no match found in iface->AdvRDNSSList */
    329                                                 addrtostr(&rdnssinfo->nd_opt_rdnssi_addr1, rdnss_str, sizeof(rdnss_str));
    330                                                 flog(LOG_WARNING,
    331                                                      "RDNSS address %s received on %s from %s is not advertised by us",
    332                                                      rdnss_str, iface->props.name, addr_str);
    333                                         }
    334 
     391
     392                                        suffix[0] = '\0';
     393                                        continue;
     394                                }
     395
     396                                /*
     397                                 * 1) must not overflow int: label + 2, offset + label_len
     398                                 * 2) last byte of dnssli_suffix must not overflow opt_str + len
     399                                 */
     400                                if ((sizeof(suffix) - strlen(suffix)) < (label_len + 2) || label_len >= (INT_MAX - 1) ||
     401                                    &dnsslinfo->nd_opt_dnssli_suffixes[offset + label_len] - opt_str >= len ||
     402                                    offset + label_len < offset) {
     403                                        flog(LOG_ERR, "oversized suffix in DNSSL option on %s from %s", iface->props.name,
     404                                             addr_str);
    335405                                        break;
    336                                 default:
    337                                         flog(LOG_ERR, "invalid len %i in RDNSS option on %s from %s", count, iface->props.name,
    338                                              addr_str);
    339                                 }
    340 
    341                                 break;
     406                                }
     407
     408                                if (suffix[0] != '\0')
     409                                        strcat(suffix, ".");
     410                                strncat(suffix, (char *)&dnsslinfo->nd_opt_dnssli_suffixes[offset], label_len);
     411                                offset += label_len;
    342412                        }
    343                 case ND_OPT_DNSSL_INFORMATION:{
    344                                 struct nd_opt_dnssl_info_local *dnsslinfo = (struct nd_opt_dnssl_info_local *)opt_str;
    345                                 if (len < sizeof(*dnsslinfo))
    346                                         return;
    347 
    348                                 for (int offset = 0; offset < (dnsslinfo->nd_opt_dnssli_len - 1) * 8;) {
    349                                         char suffix[256] = { "" };
    350                                         if (&dnsslinfo->nd_opt_dnssli_suffixes[offset] - opt_str >= len)
    351                                                 return;
    352                                         int label_len = dnsslinfo->nd_opt_dnssli_suffixes[offset++];
    353 
    354                                         if (label_len == 0) {
    355                                                 /*
    356                                                  * Ignore empty suffixes. They're
    357                                                  * probably just padding...
    358                                                  */
    359                                                 if (suffix[0] == '\0')
    360                                                         continue;
    361 
    362                                                 if (!check_dnssl_presence(iface->AdvDNSSLList, suffix)) {
    363                                                         flog(LOG_WARNING,
    364                                                              "DNSSL suffix %s received on %s from %s is not advertised by us",
    365                                                              suffix, iface->props.name, addr_str);
    366                                                 }
    367 
    368                                                 suffix[0] = '\0';
    369                                                 continue;
    370                                         }
    371 
    372                                         /*
    373                                          * 1) must not overflow int: label + 2, offset + label_len
    374                                          * 2) last byte of dnssli_suffix must not overflow opt_str + len
    375                                          */
    376                                         if ((sizeof(suffix) - strlen(suffix)) < (label_len + 2) ||
    377                                             label_len >= (INT_MAX-1)
    378                                             || &dnsslinfo->nd_opt_dnssli_suffixes[offset + label_len] - opt_str >= len
    379                                             || offset + label_len < offset) {
    380                                                 flog(LOG_ERR, "oversized suffix in DNSSL option on %s from %s", iface->props.name,
    381                                                      addr_str);
    382                                                 break;
    383                                         }
    384 
    385                                         if (suffix[0] != '\0')
    386                                                 strcat(suffix, ".");
    387                                         strncat(suffix, (char *)&dnsslinfo->nd_opt_dnssli_suffixes[offset], label_len);
    388                                         offset += label_len;
    389                                 }
    390                                 break;
    391                         }
     413                        break;
     414                }
    392415                default:
    393416                        dlog(LOG_DEBUG, 1, "unknown option %d in RA on %s from %s", (int)*opt_str, iface->props.name, addr_str);
     
    403426static int addr_match(struct in6_addr *a1, struct in6_addr *a2, int prefixlen)
    404427{
    405         unsigned int pdw = prefixlen >> 0x05;   /* num of whole uint32_t in prefix */
     428        unsigned int pdw = prefixlen >> 0x05; /* num of whole uint32_t in prefix */
    406429        if (pdw) {
    407430                if (memcmp(a1, a2, pdw << 2))
     
    409432        }
    410433
    411         unsigned int pbi = prefixlen & 0x1f;    /* num of bits in incomplete uint32_t in prefix */
     434        unsigned int pbi = prefixlen & 0x1f; /* num of bits in incomplete uint32_t in prefix */
    412435        if (pbi) {
    413                 uint32_t w1 = *((uint32_t *) a1 + pdw);
    414                 uint32_t w2 = *((uint32_t *) a2 + pdw);
    415 
    416                 uint32_t mask = htonl(((uint32_t) 0xffffffff) << (0x20 - pbi));
     436                uint32_t w1 = *((uint32_t *)a1 + pdw);
     437                uint32_t w2 = *((uint32_t *)a2 + pdw);
     438
     439                uint32_t mask = htonl(((uint32_t)0xffffffff) << (0x20 - pbi));
    417440
    418441                if ((w1 ^ w2) & mask)
  • src/router/radvd/radvd.c

    r32089 r32663  
    1414 */
    1515
     16#include "radvd.h"
    1617#include "config.h"
    1718#include "includes.h"
    18 #include "radvd.h"
    1919#include "pathnames.h"
    2020
     
    2323#endif
    2424
     25#include <libgen.h>
    2526#include <poll.h>
    2627#include <sys/file.h>
    27 #include <libgen.h>
    2828
    2929#ifdef HAVE_GETOPT_LONG
    3030
    31 /* *INDENT-OFF* */
     31/* clang-format off */
    3232static char usage_str[] = {
    3333"\n"
     
    7070
    7171};
    72 /* *INDENT-ON* */
     72/* clang-format on */
    7373
    7474#endif
     
    8181static int check_conffile_perm(const char *, const char *);
    8282static int drop_root_privileges(const char *);
    83 static int open_and_lock_pid_file(char const * daemon_pid_file_ident);
    84 static int write_pid_file(char const * daemon_pid_file_ident, pid_t pid);
    85 static pid_t daemonp(int nochdir, int noclose, char const * daemon_pid_file_ident);
    86 static pid_t do_daemonize(int log_method, char const * daemon_pid_file_ident);
    87 static struct Interface * main_loop(int sock, struct Interface *ifaces, char const *conf_path);
     83static int open_and_lock_pid_file(char const *daemon_pid_file_ident);
     84static int write_pid_file(char const *daemon_pid_file_ident, pid_t pid);
     85static pid_t daemonp(char const *daemon_pid_file_ident);
     86static pid_t do_daemonize(int log_method, char const *daemon_pid_file_ident);
     87static struct Interface *main_loop(int sock, struct Interface *ifaces, char const *conf_path);
    8888static struct Interface *reload_config(int sock, struct Interface *ifaces, char const *conf_path);
    89 static void check_pid_file(char const * daemon_pid_file_ident);
     89static void check_pid_file(char const *daemon_pid_file_ident);
    9090static void config_interface(struct Interface *iface);
    9191static void kickoff_adverts(int sock, struct Interface *iface);
     
    107107 * will be written to the pid file from the *parent* process.  This
    108108 * insures there is no race condition as described in redhat bug 664783. */
    109 static pid_t daemonp(int nochdir, int noclose, char const * daemon_pid_file_ident)
     109static pid_t daemonp(char const *daemon_pid_file_ident)
    110110{
    111111        int pipe_ends[2];
     
    139139                }
    140140
    141                 if (nochdir == 0) {
    142                         if (chdir("/") == -1) {
    143                                 perror("chdir");
    144                                 exit(1);
    145                         }
    146                 }
    147                 if (noclose == 0) {
    148                         close(STDIN_FILENO);
    149                         close(STDOUT_FILENO);
    150                         close(STDERR_FILENO);
    151                         if (open("/dev/null", O_RDONLY) == -1) {
    152                                 flog(LOG_ERR, "unable to redirect stdin to /dev/null");
    153                                 exit(-1);
    154                         }
    155                         if (open("/dev/null", O_WRONLY) == -1) {
    156                                 flog(LOG_ERR, "unable to redirect stdout to /dev/null");
    157                                 exit(-1);
    158                         }
    159                         if (open("/dev/null", O_RDWR) == -1) {
    160                                 flog(LOG_ERR, "unable to redirect stderr to /dev/null");
    161                                 exit(-1);
    162                         }
     141                if (chdir("/") == -1) {
     142                        perror("chdir");
     143                        exit(1);
     144                }
     145                close(STDIN_FILENO);
     146                close(STDOUT_FILENO);
     147                close(STDERR_FILENO);
     148                if (open("/dev/null", O_RDONLY) == -1) {
     149                        flog(LOG_ERR, "unable to redirect stdin to /dev/null");
     150                        exit(-1);
     151                }
     152                if (open("/dev/null", O_WRONLY) == -1) {
     153                        flog(LOG_ERR, "unable to redirect stdout to /dev/null");
     154                        exit(-1);
     155                }
     156                if (open("/dev/null", O_RDWR) == -1) {
     157                        flog(LOG_ERR, "unable to redirect stderr to /dev/null");
     158                        exit(-1);
    163159                }
    164160        } else {
     
    201197        char const *daemon_pid_file_ident = PATH_RADVD_PID;
    202198
    203         /* parse args */
     199/* parse args */
    204200#define OPTIONS_STR "d:C:l:m:p:t:u:vhcn"
    205201#ifdef HAVE_GETOPT_LONG
     
    294290                set_debuglevel(1);
    295291                switch (log_method) {
    296                         case L_STDERR:
    297                         case L_STDERR_CLEAN:
    298                                 break;
    299                         case L_STDERR_SYSLOG:
    300                         case L_NONE:
    301                         case L_SYSLOG:
    302                         case L_LOGFILE:
    303                         default:
    304                                 log_method = L_STDERR;
     292                case L_STDERR:
     293                case L_STDERR_CLEAN:
     294                        break;
     295                case L_STDERR_SYSLOG:
     296                case L_NONE:
     297                case L_SYSLOG:
     298                case L_LOGFILE:
     299                default:
     300                        log_method = L_STDERR;
    305301                        break;
    306302                }
     
    458454}
    459455
    460 static struct Interface * main_loop(int sock, struct Interface *ifaces, char const *conf_path)
     456static struct Interface *main_loop(int sock, struct Interface *ifaces, char const *conf_path)
    461457{
    462458        struct pollfd fds[2];
     
    524520                int rc = ppoll(fds, sizeof(fds) / sizeof(fds[0]), tsp, &sigempty);
    525521#else
    526                 int rc = poll(fds, sizeof(fds) / sizeof(fds[0]), 1000*tsp->tv_sec);
     522                int rc = poll(fds, sizeof(fds) / sizeof(fds[0]), 1000 * tsp->tv_sec);
    527523#endif
    528524
     
    582578                        sigusr1_received = 0;
    583579                }
    584 
    585580        }
    586581
     
    588583}
    589584
    590 static pid_t do_daemonize(int log_method, char const * daemon_pid_file_ident)
     585static pid_t do_daemonize(int log_method, char const *daemon_pid_file_ident)
    591586{
    592587        pid_t pid = -1;
    593588
    594         if (L_STDERR_SYSLOG == log_method || L_STDERR == log_method) {
    595                 pid = daemonp(1, 1, daemon_pid_file_ident);
    596         } else {
    597                 pid = daemonp(0, 0, daemon_pid_file_ident);
    598         }
     589        pid = daemonp(daemon_pid_file_ident);
    599590
    600591        if (-1 == pid) {
     
    605596}
    606597
    607 static int open_pid_file(char const * daemon_pid_file_ident)
     598static int open_pid_file(char const *daemon_pid_file_ident)
    608599{
    609600        int pidfd = open(daemon_pid_file_ident, O_SYNC | O_CREAT | O_RDWR, 0644);
     
    617608}
    618609
    619 static int open_and_lock_pid_file(char const * daemon_pid_file_ident)
     610static int open_and_lock_pid_file(char const *daemon_pid_file_ident)
    620611{
    621612        dlog(LOG_DEBUG, 3, "radvd startup PID is %d", getpid());
     
    634625}
    635626
    636 static int write_pid_file(char const * daemon_pid_file_ident, pid_t pid)
     627static int write_pid_file(char const *daemon_pid_file_ident, pid_t pid)
    637628{
    638629        int pidfd = open_pid_file(daemon_pid_file_ident);
     
    659650                dlog(LOG_DEBUG, 4, "failed to close pid file: %s", daemon_pid_file_ident);
    660651        }
    661         char * dirstrcopy = strdup(daemon_pid_file_ident);
    662         char * dirstr = dirname(dirstrcopy);
     652        char *dirstrcopy = strdup(daemon_pid_file_ident);
     653        char *dirstr = dirname(dirstrcopy);
    663654        int dirfd = open(dirstr, O_RDONLY);
    664655        rc = fsync(dirfd);
     
    675666}
    676667
    677 static void check_pid_file(char const * daemon_pid_file_ident)
    678 {
    679         FILE * pidfile = fopen(daemon_pid_file_ident, "r");
     668static void check_pid_file(char const *daemon_pid_file_ident)
     669{
     670        FILE *pidfile = fopen(daemon_pid_file_ident, "r");
    680671
    681672        if (!pidfile) {
     
    700691        dlog(LOG_DEBUG, 4, "validated pid file, %s: %d", daemon_pid_file_ident, pid);
    701692}
    702 
    703693
    704694static void timer_handler(int sock, struct Interface *iface)
     
    787777}
    788778
    789 static void setup_ifaces(int sock, struct Interface *ifaces)
    790 {
    791         for_each_iface(ifaces, setup_iface_foo, &sock);
    792 }
     779static void setup_ifaces(int sock, struct Interface *ifaces) { for_each_iface(ifaces, setup_iface_foo, &sock); }
    793780
    794781static struct Interface *reload_config(int sock, struct Interface *ifaces, char const *conf_path)
     
    811798}
    812799
    813 static void sighup_handler(int sig)
    814 {
    815         sighup_received = 1;
    816 }
     800static void sighup_handler(int sig) { sighup_received = 1; }
    817801
    818802static void sigterm_handler(int sig)
     
    834818}
    835819
    836 static void sigusr1_handler(int sig)
    837 {
    838         sigusr1_received = 1;
    839 }
     820static void sigusr1_handler(int sig) { sigusr1_received = 1; }
    840821
    841822static void reset_prefix_lifetimes_foo(struct Interface *iface, void *data)
     
    843824        flog(LOG_INFO, "Resetting prefix lifetimes on %s", iface->props.name);
    844825
    845         for (struct AdvPrefix * prefix = iface->AdvPrefixList; prefix; prefix = prefix->next) {
     826        for (struct AdvPrefix *prefix = iface->AdvPrefixList; prefix; prefix = prefix->next) {
    846827                if (prefix->DecrementLifetimesFlag) {
    847828                        char pfx_str[INET6_ADDRSTRLEN];
     
    857838}
    858839
    859 static void reset_prefix_lifetimes(struct Interface *ifaces)
    860 {
    861         for_each_iface(ifaces, reset_prefix_lifetimes_foo, 0);
    862 }
     840static void reset_prefix_lifetimes(struct Interface *ifaces) { for_each_iface(ifaces, reset_prefix_lifetimes_foo, 0); }
    863841
    864842static int drop_root_privileges(const char *username)
     
    905883
    906884        /* for non-root: must not be writable by self/own group */
    907         if (strncmp(username, "root", 5) != 0 && ((stbuf.st_mode & S_IWGRP && pw->pw_gid == stbuf.st_gid)
    908                                                   || (stbuf.st_mode & S_IWUSR && pw->pw_uid == stbuf.st_uid))) {
     885        if (strncmp(username, "root", 5) != 0 && ((stbuf.st_mode & S_IWGRP && pw->pw_gid == stbuf.st_gid) ||
     886                                                  (stbuf.st_mode & S_IWUSR && pw->pw_uid == stbuf.st_uid))) {
    909887                flog(LOG_ERR, "Insecure file permissions (writable by self/group): %s", conf_file);
    910888                return -1;
  • src/router/radvd/radvd.conf.5.man

    r32089 r32663  
    9494.fi
    9595
    96 By default radvd will send route advertisements so that every node on the link can use them.
     96By default radvd will send multicast route advertisements so that every node on the link can use them.
    9797The list of clients (IPv6 address) to advertise to, and accept route solicitations from can be configured.
    9898If done, radvd does not send send messages to the multicast addresses but
     
    172172
    173173Default: off
     174
     175.TP
     176.BR AdvRASolicitedUnicast " " on | off
     177
     178Indicates that router solicitations will be responded to with unicast
     179router advertisements, as recommended by RFC7772. Large networks with a
     180high concentration of mobile devices might experience like battery
     181depletion, when solicited Router Advertisement messages are multicast.
     182
     183This corresponds to the Cisco IOS option
     184.B ipv6 nd ra solicited unicast
     185
     186Default: on
    174187
    175188.TP
  • src/router/radvd/radvd.conf.example

    r17374 r32663  
    99#
    1010
    11 interface eth0
     11interface lo
    1212{
    1313        AdvSendAdvert on;
  • src/router/radvd/radvd.h

    r32089 r32663  
    1717
    1818#include "config.h"
     19#include "defaults.h"
    1920#include "includes.h"
    20 #include "defaults.h"
    2121#include "log.h"
    2222
    23 #define CONTACT_EMAIL   "Reuben Hawkins <reubenhwk@gmail.com>"
     23#define CONTACT_EMAIL "Reuben Hawkins <reubenhwk@gmail.com>"
    2424
    2525extern int sock;
     
    2727extern int disableigmp6check;
    2828
    29 #define min(a,b)        (((a) < (b)) ? (a) : (b))
     29#define min(a, b) (((a) < (b)) ? (a) : (b))
    3030
    3131struct AdvPrefix;
     
    3939        size_t allocated;
    4040        size_t used;
    41         unsigned char * buffer;
    42 };
    43 
    44 #define SAFE_BUFFER_INIT (struct safe_buffer){.should_free = 0, .allocated = 0, .used = 0, .buffer = 0}
     41        unsigned char *buffer;
     42};
     43
     44#define SAFE_BUFFER_INIT                                                                                                         \
     45        (struct safe_buffer) { .should_free = 0, .allocated = 0, .used = 0, .buffer = 0 }
    4546
    4647struct safe_buffer_list {
     
    5960        int AdvSourceLLAddress;
    6061        int UnicastOnly;
     62        int AdvRASolicitedUnicast;
    6163        struct Clients *ClientList;
    6264
    6365        struct state_info {
    64                 int ready;      /* Info whether this interface has been initialized successfully */
    65                 int changed;    /* Info whether this interface's settings have changed */
     66                int ready;   /* Info whether this interface has been initialized successfully */
     67                int changed; /* Info whether this interface's settings have changed */
    6668                int cease_adv;
    6769                uint32_t racount;
     
    6971
    7072        struct properties {
    71                 char name[IFNAMSIZ];    /* interface name */
     73                char name[IFNAMSIZ]; /* interface name */
    7274                unsigned int if_index;
    73                 struct in6_addr if_addr; /* the first link local addr */
     75                struct in6_addr if_addr;   /* the first link local addr */
    7476                struct in6_addr *if_addrs; /* all the addrs */
    7577                int addrs_count;
     
    8385                uint8_t AdvCurHopLimit;
    8486                int AdvHomeAgentFlag;
    85                 int32_t AdvDefaultLifetime;     /* XXX: really uint16_t but we need to use -1 */
     87                int32_t AdvDefaultLifetime; /* XXX: really uint16_t but we need to use -1 */
    8688                int AdvDefaultPreference;
    8789                uint32_t AdvReachableTime;
     
    101103
    102104        uint32_t AdvLinkMTU; /* XXX: sllao also has an if_maxmtu value...Why? */
    103         uint32_t AdvRAMTU; /* MTU used for RA */
     105        uint32_t AdvRAMTU;   /* MTU used for RA */
    104106
    105107        struct sllao {
     
    116118
    117119                uint16_t HomeAgentPreference;
    118                 int32_t HomeAgentLifetime;      /* XXX: really uint16_t but we need to use -1 */
     120                int32_t HomeAgentLifetime; /* XXX: really uint16_t but we need to use -1 */
    119121
    120122                /* NEMO extensions */
     
    241243
    242244/* Uclibc : include/netinet/icmpv6.h - Added by Bhadram*/
    243 #define ND_OPT_ARO      33
    244 #define ND_OPT_6CO      34
    245 #define ND_OPT_ABRO     35
     245#define ND_OPT_ARO 33
     246#define ND_OPT_6CO 34
     247#define ND_OPT_ABRO 35
    246248
    247249struct nd_opt_abro {
     
    258260        uint8_t nd_opt_6co_len;
    259261        uint8_t nd_opt_6co_context_len;
    260         uint8_t nd_opt_6co_res:3;
    261         uint8_t nd_opt_6co_c:1;
    262         uint8_t nd_opt_6co_cid:4;
     262        uint8_t nd_opt_6co_res : 3;
     263        uint8_t nd_opt_6co_c : 1;
     264        uint8_t nd_opt_6co_cid : 4;
    263265        uint16_t nd_opt_6co_reserved;
    264266        uint16_t nd_opt_6co_valid_lifetime;
    265267        struct in6_addr nd_opt_6co_con_prefix;
    266 };                              /*Added by Bhadram */
     268}; /*Added by Bhadram */
    267269
    268270/* gram.y */
     
    289291int update_device_index(struct Interface *iface);
    290292int update_device_info(int sock, struct Interface *);
    291 int get_iface_addrs(
    292         char const *name,
    293         struct in6_addr *if_addr, /* the first link local addr */
    294         struct in6_addr **if_addrs /* all the addrs */
    295         );
     293int get_iface_addrs(char const *name, struct in6_addr *if_addr, /* the first link local addr */
     294                    struct in6_addr **if_addrs                  /* all the addrs */
     295                    );
    296296
    297297/* interface.c */
     
    302302struct Interface *find_iface_by_time(struct Interface *iface_list);
    303303void dnssl_init_defaults(struct AdvDNSSL *, struct Interface *);
    304 void for_each_iface(struct Interface *ifaces, void (*foo) (struct Interface * iface, void *), void *data);
     304void for_each_iface(struct Interface *ifaces, void (*foo)(struct Interface *iface, void *), void *data);
    305305void free_ifaces(struct Interface *ifaces);
    306306void iface_init_defaults(struct Interface *);
     
    309309void reschedule_iface(struct Interface *iface, double next);
    310310void route_init_defaults(struct AdvRoute *, struct Interface *);
    311 void touch_iface(struct Interface * iface);
     311void touch_iface(struct Interface *iface);
    312312
    313313/* socket.c */
     
    321321
    322322/* recv.c */
    323 int recv_rs_ra(int sock, unsigned char *, struct sockaddr_in6 *, struct in6_pktinfo **, int *, unsigned char*);
     323int recv_rs_ra(int sock, unsigned char *, struct sockaddr_in6 *, struct in6_pktinfo **, int *, unsigned char *);
    324324
    325325/* util.c */
     
    327327int count_mask(struct sockaddr_in6 *m);
    328328struct in6_addr get_prefix6(struct in6_addr const *addr, struct in6_addr const *mask);
    329 char * strdupf(char const * format, ...) __attribute__ ((format(printf, 1, 2)));
     329char *strdupf(char const *format, ...) __attribute__((format(printf, 1, 2)));
    330330double rand_between(double, double);
    331331int check_dnssl_presence(struct AdvDNSSL *, const char *);
    332332int check_rdnss_presence(struct AdvRDNSS *, struct in6_addr *);
    333 void safe_buffer_resize(struct safe_buffer * sb, size_t new_capacity);
    334 size_t safe_buffer_append(struct safe_buffer * sb, void const * m, size_t count);
    335 size_t safe_buffer_pad(struct safe_buffer * sb, size_t count);
     333void safe_buffer_resize(struct safe_buffer *sb, size_t new_capacity);
     334size_t safe_buffer_append(struct safe_buffer *sb, void const *m, size_t count);
     335size_t safe_buffer_pad(struct safe_buffer *sb, size_t count);
    336336ssize_t readn(int fd, void *buf, size_t count);
    337337ssize_t writen(int fd, const void *buf, size_t count);
    338 struct safe_buffer * new_safe_buffer(void);
     338struct safe_buffer *new_safe_buffer(void);
    339339void addrtostr(struct in6_addr const *, char *, size_t);
    340 void safe_buffer_free(struct safe_buffer * sb);
    341 struct safe_buffer_list * new_safe_buffer_list(void);
    342 void safe_buffer_list_free(struct safe_buffer_list * sbl);
    343 struct safe_buffer_list * safe_buffer_list_append(struct safe_buffer_list * sbl);
    344 void safe_buffer_list_to_safe_buffer(struct safe_buffer_list * sbl, struct safe_buffer *sb);
     340void safe_buffer_free(struct safe_buffer *sb);
     341struct safe_buffer_list *new_safe_buffer_list(void);
     342void safe_buffer_list_free(struct safe_buffer_list *sbl);
     343struct safe_buffer_list *safe_buffer_list_append(struct safe_buffer_list *sbl);
     344void safe_buffer_list_to_safe_buffer(struct safe_buffer_list *sbl, struct safe_buffer *sb);
    345345
    346346/* privsep.c */
     
    367367#if defined IPV6_RECVHOPLIMIT || defined IPV6_RECVPKTINFO
    368368#include <linux/version.h>
    369 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
     369#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
    370370#if defined IPV6_RECVHOPLIMIT && defined IPV6_2292HOPLIMIT
    371371#undef IPV6_RECVHOPLIMIT
  • src/router/radvd/radvdump.c

    r29984 r32663  
    1414 */
    1515
     16#include "radvd.h"
    1617#include "config.h"
    1718#include "includes.h"
    18 #include "radvd.h"
    1919
    2020static char usage_str[] = "[-vhfe] [-d level]";
    2121
    2222#ifdef HAVE_GETOPT_LONG
    23 struct option prog_opt[] = {
    24         {"debug", 1, 0, 'd'},
    25         {"file-format", 0, 0, 'f'},
    26         {"exclude-defaults", 0, 0, 'e'},
    27         {"version", 0, 0, 'v'},
    28         {"help", 0, 0, 'h'},
    29         {NULL, 0, 0, 0}
    30 };
     23struct option prog_opt[] = {{"debug", 1, 0, 'd'},   {"file-format", 0, 0, 'f'}, {"exclude-defaults", 0, 0, 'e'},
     24                            {"version", 0, 0, 'v'}, {"help", 0, 0, 'h'},        {NULL, 0, 0, 0}};
    3125#endif
    3226
     
    3428
    3529static void version(void);
    36 static void usage(char const * pname);
     30static void usage(char const *pname);
    3731static void print_ff(unsigned char *, int, struct sockaddr_in6 *, int, unsigned int, int);
    3832static void print_preferences(int);
     
    4539        int opt_idx;
    4640#endif
    47         char const * pname = ((pname = strrchr(argv[0], '/')) != NULL) ? pname + 1 : argv[0];
    48 
    49         /* parse args */
     41        char const *pname = ((pname = strrchr(argv[0], '/')) != NULL) ? pname + 1 : argv[0];
     42
     43/* parse args */
    5044#ifdef HAVE_GETOPT_LONG
    5145        while ((c = getopt_long(argc, argv, "d:fehv", prog_opt, &opt_idx)) > 0)
     
    147141        printf("#\n# radvd configuration generated by radvdump %s\n", VERSION);
    148142        printf("# based on Router Advertisement from %s\n", addr_str);
    149         char if_name[IFNAMSIZ] = { "" };
     143        char if_name[IFNAMSIZ] = {""};
    150144        if_indextoname(if_index, if_name);
    151145        printf("# received by interface %s\n", if_name);
     
    175169
    176170        /* Mobile IPv6 ext */
    177         if (!edefs
    178             || DFLT_AdvHomeAgentFlag != (ND_RA_FLAG_HOME_AGENT == (radvert->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT)))
     171        if (!edefs || DFLT_AdvHomeAgentFlag != (ND_RA_FLAG_HOME_AGENT == (radvert->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT)))
    179172                printf("\tAdvHomeAgentFlag %s;\n", (radvert->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT) ? "on" : "off");
    180173
     
    192185                return;
    193186
    194         uint8_t *opt_str = (uint8_t *) (msg + sizeof(struct nd_router_advert));
     187        uint8_t *opt_str = (uint8_t *)(msg + sizeof(struct nd_router_advert));
    195188
    196189        while (len > 0) {
     
    207200                        break;
    208201                } else if (optlen > len) {
    209                         flog(LOG_ERR, "option length greater than total" " length in RA (type %d, optlen %d, len %d)",
     202                        flog(LOG_ERR, "option length greater than total"
     203                                      " length in RA (type %d, optlen %d, len %d)",
    210204                             (int)*opt_str, optlen, len);
    211205                        break;
     
    213207
    214208                switch (*opt_str) {
    215                 case ND_OPT_MTU:{
    216                                 struct nd_opt_mtu *mtu = (struct nd_opt_mtu *)opt_str;
    217 
    218                                 if (!edefs || DFLT_AdvLinkMTU != ntohl(mtu->nd_opt_mtu_mtu))
    219                                         printf("\tAdvLinkMTU %u;\n", ntohl(mtu->nd_opt_mtu_mtu));
    220                                 break;
    221                         }
     209                case ND_OPT_MTU: {
     210                        struct nd_opt_mtu *mtu = (struct nd_opt_mtu *)opt_str;
     211
     212                        if (!edefs || DFLT_AdvLinkMTU != ntohl(mtu->nd_opt_mtu_mtu))
     213                                printf("\tAdvLinkMTU %u;\n", ntohl(mtu->nd_opt_mtu_mtu));
     214                        break;
     215                }
    222216                case ND_OPT_SOURCE_LINKADDR:
    223217                        /* XXX: !DFLT depends on current DFLT_ value */
     
    225219                                printf("\tAdvSourceLLAddress on;\n");
    226220                        break;
    227                         /* Mobile IPv6 ext */
     221                /* Mobile IPv6 ext */
    228222                case ND_OPT_RTR_ADV_INTERVAL:
    229223                        /* XXX: !DFLT depends on current DFLT_ value */
     
    231225                                printf("\tAdvIntervalOpt on;\n");
    232226                        break;
    233                         /* Mobile IPv6 ext */
    234                 case ND_OPT_HOME_AGENT_INFO:{
    235                                 struct HomeAgentInfo *ha_info = (struct HomeAgentInfo *)opt_str;
    236 
    237                                 /* XXX: we check DFLT_HomeAgentInfo by interface, and it's outside
    238                                    of context here, so we always need to print it out.. */
    239                                 printf("\tAdvHomeAgentInfo on;\n");
    240 
    241                                 /* NEMO ext */
    242                                 if (!edefs
    243                                     || DFLT_AdvMobRtrSupportFlag != (ha_info->flags_reserved & ND_OPT_HAI_FLAG_SUPPORT_MR))
    244                                         printf("\tAdvMobRtrSupportFlag %s;\n",
    245                                                (ha_info->flags_reserved & ND_OPT_HAI_FLAG_SUPPORT_MR) ? "on" : "off");
    246 
    247                                 if (!edefs || DFLT_HomeAgentPreference != ntohs(ha_info->preference))
    248                                         printf("\tHomeAgentPreference %hu;\n", ntohs(ha_info->preference));
    249                                 /* Hum.. */
    250                                 if (!edefs || (3 * DFLT_MaxRtrAdvInterval) != ntohs(ha_info->lifetime))
    251                                         printf("\tHomeAgentLifetime %hu;\n", ntohs(ha_info->lifetime));
    252                                 break;
    253                         }
     227                /* Mobile IPv6 ext */
     228                case ND_OPT_HOME_AGENT_INFO: {
     229                        struct HomeAgentInfo *ha_info = (struct HomeAgentInfo *)opt_str;
     230
     231                        /* XXX: we check DFLT_HomeAgentInfo by interface, and it's outside
     232                           of context here, so we always need to print it out.. */
     233                        printf("\tAdvHomeAgentInfo on;\n");
     234
     235                        /* NEMO ext */
     236                        if (!edefs || DFLT_AdvMobRtrSupportFlag != (ha_info->flags_reserved & ND_OPT_HAI_FLAG_SUPPORT_MR))
     237                                printf("\tAdvMobRtrSupportFlag %s;\n",
     238                                       (ha_info->flags_reserved & ND_OPT_HAI_FLAG_SUPPORT_MR) ? "on" : "off");
     239
     240                        if (!edefs || DFLT_HomeAgentPreference != ntohs(ha_info->preference))
     241                                printf("\tHomeAgentPreference %hu;\n", ntohs(ha_info->preference));
     242                        /* Hum.. */
     243                        if (!edefs || (3 * DFLT_MaxRtrAdvInterval) != ntohs(ha_info->lifetime))
     244                                printf("\tHomeAgentLifetime %hu;\n", ntohs(ha_info->lifetime));
     245                        break;
     246                }
    254247                case ND_OPT_TARGET_LINKADDR:
    255248                case ND_OPT_REDIRECTED_HEADER:
     
    278271                return;
    279272
    280         opt_str = (uint8_t *) (msg + sizeof(struct nd_router_advert));
     273        opt_str = (uint8_t *)(msg + sizeof(struct nd_router_advert));
    281274
    282275        while (orig_len > 0) {
     
    294287                        break;
    295288                } else if (optlen > orig_len) {
    296                         flog(LOG_ERR, "option length greater than total" " length in RA (type %d, optlen %d, len %d)",
     289                        flog(LOG_ERR, "option length greater than total"
     290                                      " length in RA (type %d, optlen %d, len %d)",
    297291                             (int)*opt_str, optlen, orig_len);
    298292                        break;
     
    300294
    301295                switch (*opt_str) {
    302                 case ND_OPT_PREFIX_INFORMATION:{
    303                                 struct nd_opt_prefix_info *pinfo = (struct nd_opt_prefix_info *)opt_str;
    304 
    305                                 addrtostr(&pinfo->nd_opt_pi_prefix, prefix_str, sizeof(prefix_str));
    306 
    307                                 printf("\n\tprefix %s/%d\n\t{\n", prefix_str, pinfo->nd_opt_pi_prefix_len);
    308 
    309                                 if (ntohl(pinfo->nd_opt_pi_valid_time) == 0xffffffff) {
    310                                         if (!edefs || DFLT_AdvValidLifetime != 0xffffffff)
    311                                                 printf("\t\tAdvValidLifetime infinity; # (0xffffffff)\n");
    312                                 } else {
    313                                         if (!edefs || DFLT_AdvValidLifetime != ntohl(pinfo->nd_opt_pi_valid_time))
    314                                                 printf("\t\tAdvValidLifetime %u;\n", ntohl(pinfo->nd_opt_pi_valid_time));
     296                case ND_OPT_PREFIX_INFORMATION: {
     297                        struct nd_opt_prefix_info *pinfo = (struct nd_opt_prefix_info *)opt_str;
     298
     299                        addrtostr(&pinfo->nd_opt_pi_prefix, prefix_str, sizeof(prefix_str));
     300
     301                        printf("\n\tprefix %s/%d\n\t{\n", prefix_str, pinfo->nd_opt_pi_prefix_len);
     302
     303                        if (ntohl(pinfo->nd_opt_pi_valid_time) == 0xffffffff) {
     304                                if (!edefs || DFLT_AdvValidLifetime != 0xffffffff)
     305                                        printf("\t\tAdvValidLifetime infinity; # (0xffffffff)\n");
     306                        } else {
     307                                if (!edefs || DFLT_AdvValidLifetime != ntohl(pinfo->nd_opt_pi_valid_time))
     308                                        printf("\t\tAdvValidLifetime %u;\n", ntohl(pinfo->nd_opt_pi_valid_time));
     309                        }
     310                        if (ntohl(pinfo->nd_opt_pi_preferred_time) == 0xffffffff) {
     311                                if (!edefs || DFLT_AdvPreferredLifetime != 0xffffffff)
     312                                        printf("\t\tAdvPreferredLifetime infinity; # (0xffffffff)\n");
     313                        } else {
     314                                if (!edefs || DFLT_AdvPreferredLifetime != ntohl(pinfo->nd_opt_pi_preferred_time))
     315                                        printf("\t\tAdvPreferredLifetime %u;\n", ntohl(pinfo->nd_opt_pi_preferred_time));
     316                        }
     317
     318                        if (!edefs ||
     319                            DFLT_AdvOnLinkFlag !=
     320                                (ND_OPT_PI_FLAG_ONLINK == (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)))
     321                                printf("\t\tAdvOnLink %s;\n",
     322                                       (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK) ? "on" : "off");
     323
     324                        if (!edefs ||
     325                            DFLT_AdvAutonomousFlag !=
     326                                (ND_OPT_PI_FLAG_AUTO == (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)))
     327                                printf("\t\tAdvAutonomous %s;\n",
     328                                       (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO) ? "on" : "off");
     329
     330                        /* Mobile IPv6 ext */
     331                        if (!edefs ||
     332                            DFLT_AdvRouterAddr !=
     333                                (ND_OPT_PI_FLAG_RADDR == (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR)))
     334                                printf("\t\tAdvRouterAddr %s;\n",
     335                                       (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR) ? "on" : "off");
     336
     337                        printf("\t}; # End of prefix definition\n\n");
     338                        break;
     339                }
     340                case ND_OPT_ROUTE_INFORMATION: {
     341                        struct nd_opt_route_info_local *rinfo = (struct nd_opt_route_info_local *)opt_str;
     342
     343                        if (optlen == 8) {
     344                                printf("\n\troute ::/0\n\t{\n");
     345                        } else {
     346                                struct in6_addr addr;
     347                                memset(&addr, 0, sizeof(addr));
     348                                if (rinfo->nd_opt_ri_len > 1)
     349                                        memcpy(&addr, &rinfo->nd_opt_ri_prefix, (rinfo->nd_opt_ri_len - 1) * 8);
     350                                addrtostr(&addr, prefix_str, sizeof(prefix_str));
     351                                printf("\n\troute %s/%d\n\t{\n", prefix_str, rinfo->nd_opt_ri_prefix_len);
     352                        }
     353
     354                        if (!edefs || (((radvert->nd_ra_flags_reserved & 0x18) >> 3) & 0xff) != DFLT_AdvRoutePreference) {
     355                                printf("\t\tAdvRoutePreference ");
     356                                print_preferences(((rinfo->nd_opt_ri_flags_reserved & 0x18) >> 3) & 0xff);
     357                                printf(";\n");
     358                        }
     359
     360                        /* XXX: we check DFLT_AdvRouteLifetime by interface, and it's outside of context here */
     361                        if (ntohl(rinfo->nd_opt_ri_lifetime) == 0xffffffff)
     362                                printf("\t\tAdvRouteLifetime infinity; # (0xffffffff)\n");
     363                        else
     364                                printf("\t\tAdvRouteLifetime %u;\n", ntohl(rinfo->nd_opt_ri_lifetime));
     365
     366                        printf("\t}; # End of route definition\n\n");
     367                        break;
     368                }
     369                case ND_OPT_RDNSS_INFORMATION: {
     370                        struct nd_opt_rdnss_info_local *rdnss_info = (struct nd_opt_rdnss_info_local *)opt_str;
     371
     372                        printf("\n\tRDNSS");
     373
     374                        addrtostr(&rdnss_info->nd_opt_rdnssi_addr1, prefix_str, sizeof(prefix_str));
     375                        printf(" %s", prefix_str);
     376
     377                        if (rdnss_info->nd_opt_rdnssi_len >= 5) {
     378                                addrtostr(&rdnss_info->nd_opt_rdnssi_addr2, prefix_str, sizeof(prefix_str));
     379                                printf(" %s", prefix_str);
     380                        }
     381                        if (rdnss_info->nd_opt_rdnssi_len >= 7) {
     382                                addrtostr(&rdnss_info->nd_opt_rdnssi_addr3, prefix_str, sizeof(prefix_str));
     383                                printf(" %s", prefix_str);
     384                        }
     385
     386                        printf("\n\t{\n");
     387                        /* as AdvRDNSSLifetime may depend on MaxRtrAdvInterval, it could change */
     388                        if (ntohl(rdnss_info->nd_opt_rdnssi_lifetime) == 0xffffffff)
     389                                printf("\t\tAdvRDNSSLifetime infinity; # (0xffffffff)\n");
     390                        else
     391                                printf("\t\tAdvRDNSSLifetime %u;\n", ntohl(rdnss_info->nd_opt_rdnssi_lifetime));
     392
     393                        printf("\t}; # End of RDNSS definition\n\n");
     394                        break;
     395                }
     396                case ND_OPT_DNSSL_INFORMATION: {
     397                        struct nd_opt_dnssl_info_local *dnssl_info = (struct nd_opt_dnssl_info_local *)opt_str;
     398
     399                        printf("\n\tDNSSL");
     400
     401                        char suffix[256] = {""};
     402                        for (int offset = 0; offset < (dnssl_info->nd_opt_dnssli_len - 1) * 8;) {
     403                                int label_len = dnssl_info->nd_opt_dnssli_suffixes[offset++];
     404
     405                                if (label_len == 0) {
     406                                        /*
     407                                         * Ignore empty suffixes. They're
     408                                         * probably just padding...
     409                                         */
     410                                        if (suffix[0] == '\0')
     411                                                continue;
     412
     413                                        printf(" %s", suffix);
     414
     415                                        suffix[0] = '\0';
     416                                        continue;
    315417                                }
    316                                 if (ntohl(pinfo->nd_opt_pi_preferred_time) == 0xffffffff) {
    317                                         if (!edefs || DFLT_AdvPreferredLifetime != 0xffffffff)
    318                                                 printf("\t\tAdvPreferredLifetime infinity; # (0xffffffff)\n");
    319                                 } else {
    320                                         if (!edefs || DFLT_AdvPreferredLifetime != ntohl(pinfo->nd_opt_pi_preferred_time))
    321                                                 printf("\t\tAdvPreferredLifetime %u;\n",
    322                                                        ntohl(pinfo->nd_opt_pi_preferred_time));
     418
     419                                if ((sizeof(suffix) - strlen(suffix)) < (label_len + 2)) {
     420                                        flog(LOG_ERR, "oversized suffix in DNSSL option from %s", addr_str);
     421                                        break;
    323422                                }
    324423
    325                                 if (!edefs
    326                                     || DFLT_AdvOnLinkFlag != (ND_OPT_PI_FLAG_ONLINK ==
    327                                                               (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK)))
    328                                         printf("\t\tAdvOnLink %s;\n",
    329                                                (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK) ? "on" : "off");
    330 
    331                                 if (!edefs
    332                                     || DFLT_AdvAutonomousFlag != (ND_OPT_PI_FLAG_AUTO ==
    333                                                                   (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO)))
    334                                         printf("\t\tAdvAutonomous %s;\n",
    335                                                (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO) ? "on" : "off");
    336 
    337                                 /* Mobile IPv6 ext */
    338                                 if (!edefs
    339                                     || DFLT_AdvRouterAddr != (ND_OPT_PI_FLAG_RADDR ==
    340                                                               (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR)))
    341                                         printf("\t\tAdvRouterAddr %s;\n",
    342                                                (pinfo->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_RADDR) ? "on" : "off");
    343 
    344                                 printf("\t}; # End of prefix definition\n\n");
    345                                 break;
    346                         }
    347                 case ND_OPT_ROUTE_INFORMATION:{
    348                                 struct nd_opt_route_info_local *rinfo = (struct nd_opt_route_info_local *)opt_str;
    349 
    350                                 if (optlen == 8) {
    351                                         printf("\n\troute ::/0\n\t{\n");
    352                                 } else {
    353                                         struct in6_addr addr;
    354                                         memset(&addr, 0, sizeof(addr));
    355                                         if (rinfo->nd_opt_ri_len > 1)
    356                                                 memcpy(&addr, &rinfo->nd_opt_ri_prefix, (rinfo->nd_opt_ri_len - 1) * 8);
    357                                         addrtostr(&addr, prefix_str, sizeof(prefix_str));
    358                                         printf("\n\troute %s/%d\n\t{\n", prefix_str, rinfo->nd_opt_ri_prefix_len);
    359                                 }
    360 
    361                                 if (!edefs
    362                                     || (((radvert->nd_ra_flags_reserved & 0x18) >> 3) & 0xff) != DFLT_AdvRoutePreference) {
    363                                         printf("\t\tAdvRoutePreference ");
    364                                         print_preferences(((rinfo->nd_opt_ri_flags_reserved & 0x18) >> 3) & 0xff);
    365                                         printf(";\n");
    366                                 }
    367 
    368                                 /* XXX: we check DFLT_AdvRouteLifetime by interface, and it's outside of context here */
    369                                 if (ntohl(rinfo->nd_opt_ri_lifetime) == 0xffffffff)
    370                                         printf("\t\tAdvRouteLifetime infinity; # (0xffffffff)\n");
    371                                 else
    372                                         printf("\t\tAdvRouteLifetime %u;\n", ntohl(rinfo->nd_opt_ri_lifetime));
    373 
    374                                 printf("\t}; # End of route definition\n\n");
    375                                 break;
    376                         }
    377                 case ND_OPT_RDNSS_INFORMATION:{
    378                                 struct nd_opt_rdnss_info_local *rdnss_info = (struct nd_opt_rdnss_info_local *)opt_str;
    379 
    380                                 printf("\n\tRDNSS");
    381 
    382                                 addrtostr(&rdnss_info->nd_opt_rdnssi_addr1, prefix_str, sizeof(prefix_str));
    383                                 printf(" %s", prefix_str);
    384 
    385                                 if (rdnss_info->nd_opt_rdnssi_len >= 5) {
    386                                         addrtostr(&rdnss_info->nd_opt_rdnssi_addr2, prefix_str, sizeof(prefix_str));
    387                                         printf(" %s", prefix_str);
    388                                 }
    389                                 if (rdnss_info->nd_opt_rdnssi_len >= 7) {
    390                                         addrtostr(&rdnss_info->nd_opt_rdnssi_addr3, prefix_str, sizeof(prefix_str));
    391                                         printf(" %s", prefix_str);
    392                                 }
    393 
    394                                 printf("\n\t{\n");
    395                                 /* as AdvRDNSSLifetime may depend on MaxRtrAdvInterval, it could change */
    396                                 if (ntohl(rdnss_info->nd_opt_rdnssi_lifetime) == 0xffffffff)
    397                                         printf("\t\tAdvRDNSSLifetime infinity; # (0xffffffff)\n");
    398                                 else
    399                                         printf("\t\tAdvRDNSSLifetime %u;\n", ntohl(rdnss_info->nd_opt_rdnssi_lifetime));
    400 
    401                                 printf("\t}; # End of RDNSS definition\n\n");
    402                                 break;
    403                         }
    404                 case ND_OPT_DNSSL_INFORMATION:{
    405                                 struct nd_opt_dnssl_info_local *dnssl_info = (struct nd_opt_dnssl_info_local *)opt_str;
    406 
    407                                 printf("\n\tDNSSL");
    408 
    409                                 char suffix[256] = { "" };
    410                                 for (int offset = 0; offset < (dnssl_info->nd_opt_dnssli_len - 1) * 8;) {
    411                                         int label_len = dnssl_info->nd_opt_dnssli_suffixes[offset++];
    412 
    413                                         if (label_len == 0) {
    414                                                 /*
    415                                                  * Ignore empty suffixes. They're
    416                                                  * probably just padding...
    417                                                  */
    418                                                 if (suffix[0] == '\0')
    419                                                         continue;
    420 
    421                                                 printf(" %s", suffix);
    422 
    423                                                 suffix[0] = '\0';
    424                                                 continue;
    425                                         }
    426 
    427                                         if ((sizeof(suffix) - strlen(suffix)) < (label_len + 2)) {
    428                                                 flog(LOG_ERR, "oversized suffix in DNSSL option from %s", addr_str);
    429                                                 break;
    430                                         }
    431 
    432                                         if (suffix[0] != '\0')
    433                                                 strcat(suffix, ".");
    434                                         strncat(suffix, (char *)&dnssl_info->nd_opt_dnssli_suffixes[offset], label_len);
    435                                         offset += label_len;
    436                                 }
    437 
    438                                 printf("\n\t{\n");
    439                                 /* as AdvDNSSLLifetime may depend on MaxRtrAdvInterval, it could change */
    440                                 if (ntohl(dnssl_info->nd_opt_dnssli_lifetime) == 0xffffffff)
    441                                         printf("\t\tAdvDNSSLLifetime infinity; # (0xffffffff)\n");
    442                                 else
    443                                         printf("\t\tAdvDNSSLLifetime %u;\n", ntohl(dnssl_info->nd_opt_dnssli_lifetime));
    444 
    445                                 printf("\t}; # End of DNSSL definition\n\n");
    446                                 break;
    447                         }
     424                                if (suffix[0] != '\0')
     425                                        strcat(suffix, ".");
     426                                strncat(suffix, (char *)&dnssl_info->nd_opt_dnssli_suffixes[offset], label_len);
     427                                offset += label_len;
     428                        }
     429
     430                        printf("\n\t{\n");
     431                        /* as AdvDNSSLLifetime may depend on MaxRtrAdvInterval, it could change */
     432                        if (ntohl(dnssl_info->nd_opt_dnssli_lifetime) == 0xffffffff)
     433                                printf("\t\tAdvDNSSLLifetime infinity; # (0xffffffff)\n");
     434                        else
     435                                printf("\t\tAdvDNSSLLifetime %u;\n", ntohl(dnssl_info->nd_opt_dnssli_lifetime));
     436
     437                        printf("\t}; # End of DNSSL definition\n\n");
     438                        break;
     439                }
    448440                default:
    449441                        break;
     
    483475}
    484476
    485 static void usage(char const * pname)
     477static void usage(char const *pname)
    486478{
    487479        fprintf(stderr, "usage: %s %s\n", pname, usage_str);
    488480        exit(-1);
    489481}
    490 
  • src/router/radvd/recv.c

    r26390 r32663  
    1818#include "radvd.h"
    1919
    20 int recv_rs_ra(int sock, unsigned char *msg, struct sockaddr_in6 *addr, struct in6_pktinfo **pkt_info, int *hoplimit, unsigned char * chdr)
     20int recv_rs_ra(int sock, unsigned char *msg, struct sockaddr_in6 *addr, struct in6_pktinfo **pkt_info, int *hoplimit,
     21               unsigned char *chdr)
    2122{
    2223        struct iovec iov;
    2324        iov.iov_len = MSG_SIZE_RECV;
    24         iov.iov_base = (caddr_t) msg;
     25        iov.iov_base = (caddr_t)msg;
    2526
    2627        struct msghdr mhdr;
    2728        memset(&mhdr, 0, sizeof(mhdr));
    28         mhdr.msg_name = (caddr_t) addr;
     29        mhdr.msg_name = (caddr_t)addr;
    2930        mhdr.msg_namelen = sizeof(*addr);
    3031        mhdr.msg_iov = &iov;
     
    5152#ifdef IPV6_HOPLIMIT
    5253                case IPV6_HOPLIMIT:
    53                         if ((cmsg->cmsg_len == CMSG_LEN(sizeof(int))) && (*(int *)CMSG_DATA(cmsg) >= 0)
    54                             && (*(int *)CMSG_DATA(cmsg) < 256)) {
     54                        if ((cmsg->cmsg_len == CMSG_LEN(sizeof(int))) && (*(int *)CMSG_DATA(cmsg) >= 0) &&
     55                            (*(int *)CMSG_DATA(cmsg) < 256)) {
    5556                                *hoplimit = *(int *)CMSG_DATA(cmsg);
    5657                        } else {
     
    6061                        }
    6162                        break;
    62 #endif                          /* IPV6_HOPLIMIT */
     63#endif /* IPV6_HOPLIMIT */
    6364                case IPV6_PKTINFO:
    64                         if ((cmsg->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo)))
    65                             && ((struct in6_pktinfo *)CMSG_DATA(cmsg))->ipi6_ifindex) {
     65                        if ((cmsg->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) &&
     66                            ((struct in6_pktinfo *)CMSG_DATA(cmsg))->ipi6_ifindex) {
    6667                                *pkt_info = (struct in6_pktinfo *)CMSG_DATA(cmsg);
    6768                        } else {
     
    7475        }
    7576
    76         char if_namebuf[IF_NAMESIZE] = { "" };
     77        char if_namebuf[IF_NAMESIZE] = {""};
    7778        char *if_name = 0;
    7879        if (pkt_info && *pkt_info) {
  • src/router/radvd/redhat/radvd.spec

    r32089 r32663  
    66Summary: A Router Advertisement daemon
    77Name: radvd
    8 Version: 2.16
     8Version: 2.17
    99Release: 1
    1010# The code includes the advertising clause, so it's GPL-incompatible
  • src/router/radvd/scanner.l

    r32089 r32663  
    8080AdvHomeAgentInfo        { return T_AdvHomeAgentInfo; }
    8181UnicastOnly             { return T_UnicastOnly; }
     82AdvRASolicitedUnicast   { return T_AdvRASolicitedUnicast; }
    8283
    8384Base6Interface          { return T_Base6Interface; }
  • src/router/radvd/send.c

    r32089 r32663  
    2020static int really_send(int sock, struct in6_addr const *dest, struct properties const *props, struct safe_buffer const *sb);
    2121static int send_ra(int sock, struct Interface *iface, struct in6_addr const *dest);
    22 static struct safe_buffer_list * build_ra_options(struct Interface const * iface, struct in6_addr const *dest);
     22static struct safe_buffer_list *build_ra_options(struct Interface const *iface, struct in6_addr const *dest);
    2323
    2424static int ensure_iface_setup(int sock, struct Interface *iface);
    25 static void decrement_lifetime(const time_t secs, uint32_t * lifetime);
    26 static void update_iface_times(struct Interface * iface);
     25static void decrement_lifetime(const time_t secs, uint32_t *lifetime);
     26static void update_iface_times(struct Interface *iface);
    2727
    2828// Option helpers
    29 static size_t serialize_domain_names(struct safe_buffer * safe_buffer, struct AdvDNSSL const *dnssl);
     29static size_t serialize_domain_names(struct safe_buffer *safe_buffer, struct AdvDNSSL const *dnssl);
    3030
    3131// Options that only need a single block
    32 static void add_ra_header(struct safe_buffer * sb, struct ra_header_info const * ra_header_info, int cease_adv);
    33 static void add_ra_option_prefix(struct safe_buffer * sb, struct AdvPrefix const * prefix, int cease_adv);
    34 static void add_ra_option_mtu(struct safe_buffer * sb, uint32_t AdvLinkMTU);
    35 static void add_ra_option_sllao(struct safe_buffer * sb, struct sllao const *sllao);
    36 static void add_ra_option_mipv6_rtr_adv_interval(struct safe_buffer * sb, double MaxRtrAdvInterval);
    37 static void add_ra_option_mipv6_home_agent_info(struct safe_buffer * sb, struct mipv6 const * mipv6);
    38 static void add_ra_option_lowpanco(struct safe_buffer * sb, struct AdvLowpanCo const *lowpanco);
    39 static void add_ra_option_abro(struct safe_buffer * sb, struct AdvAbro const *abroo);
     32static void add_ra_header(struct safe_buffer *sb, struct ra_header_info const *ra_header_info, int cease_adv);
     33static void add_ra_option_prefix(struct safe_buffer *sb, struct AdvPrefix const *prefix, int cease_adv);
     34static void add_ra_option_mtu(struct safe_buffer *sb, uint32_t AdvLinkMTU);
     35static void add_ra_option_sllao(struct safe_buffer *sb, struct sllao const *sllao);
     36static void add_ra_option_mipv6_rtr_adv_interval(struct safe_buffer *sb, double MaxRtrAdvInterval);
     37static void add_ra_option_mipv6_home_agent_info(struct safe_buffer *sb, struct mipv6 const *mipv6);
     38static void add_ra_option_lowpanco(struct safe_buffer *sb, struct AdvLowpanCo const *lowpanco);
     39static void add_ra_option_abro(struct safe_buffer *sb, struct AdvAbro const *abroo);
    4040
    4141// Options that generate 0 or more blocks
    42 static struct safe_buffer_list* add_ra_options_prefix(struct safe_buffer_list * sbl, struct Interface const * iface, char const * ifname, struct AdvPrefix const * prefix, int cease_adv, struct in6_addr const *dest);
    43 static struct safe_buffer_list* add_ra_options_route(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvRoute const *route, int cease_adv, struct in6_addr const *dest);
    44 static struct safe_buffer_list* add_ra_options_rdnss(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvRDNSS const *rdnss, int cease_adv, struct in6_addr const *dest);
    45 static struct safe_buffer_list* add_ra_options_dnssl(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvDNSSL const *dnssl, int cease_adv, struct in6_addr const *dest);
     42static struct safe_buffer_list *add_ra_options_prefix(struct safe_buffer_list *sbl, struct Interface const *iface,
     43                                                      char const *ifname, struct AdvPrefix const *prefix, int cease_adv,
     44                                                      struct in6_addr const *dest);
     45static struct safe_buffer_list *add_ra_options_route(struct safe_buffer_list *sbl, struct Interface const *iface,
     46                                                     struct AdvRoute const *route, int cease_adv, struct in6_addr const *dest);
     47static struct safe_buffer_list *add_ra_options_rdnss(struct safe_buffer_list *sbl, struct Interface const *iface,
     48                                                     struct AdvRDNSS const *rdnss, int cease_adv, struct in6_addr const *dest);
     49static struct safe_buffer_list *add_ra_options_dnssl(struct safe_buffer_list *sbl, struct Interface const *iface,
     50                                                     struct AdvDNSSL const *dnssl, int cease_adv, struct in6_addr const *dest);
    4651
    4752// Scheduling of options per RFC7772
     
    6267#endif
    6368
    64 
    6569/*
    6670 * Sends an advertisement for all specified clients of this interface
     
    9296
    9397        /* If clients are configured, send the advertisement to all of them via unicast */
    94         for (struct Clients * current = iface->ClientList; current; current = current->next) {
     98        for (struct Clients *current = iface->ClientList; current; current = current->next) {
    9599                /* If a non-authorized client sent a solicitation, ignore it (logging later) */
    96100                if (dest != NULL && memcmp(dest, &current->Address, sizeof(struct in6_addr)) != 0)
     
    109113        /* If we refused a client's solicitation, log it if debugging is high enough */
    110114        if (get_debuglevel() >= 5) {
    111                 char address_text[INET6_ADDRSTRLEN] = { "" };
     115                char address_text[INET6_ADDRSTRLEN] = {""};
    112116                addrtostr(dest, address_text, INET6_ADDRSTRLEN);
    113117                dlog(LOG_DEBUG, 5, "Not answering request from %s, not configured", address_text);
     
    116120        return 0;
    117121}
    118 
    119 
    120 
    121122
    122123/********************************************************************************
     
    136137}
    137138
    138 static void decrement_lifetime(const time_t secs, uint32_t * lifetime)
     139static void decrement_lifetime(const time_t secs, uint32_t *lifetime)
    139140{
    140141        if (*lifetime > secs) {
     
    145146}
    146147
    147 static void update_iface_times(struct Interface * iface)
     148static void update_iface_times(struct Interface *iface)
    148149{
    149150        struct timespec last_time = iface->times.last_ra_time;
     
    168169                                                char pfx_str[INET6_ADDRSTRLEN];
    169170                                                addrtostr(&prefix->Prefix, pfx_str, sizeof(pfx_str));
    170                                                 dlog(LOG_DEBUG, 3, "Will cease advertising %s/%u%%%s, preferred lifetime is 0", pfx_str, prefix->PrefixLen, iface->props.name);
     171                                                dlog(LOG_DEBUG, 3, "Will cease advertising %s/%u%%%s, preferred lifetime is 0",
     172                                                     pfx_str, prefix->PrefixLen, iface->props.name);
    171173                                        }
    172174                                }
     
    177179}
    178180
    179 
    180181/********************************************************************************
    181182*       add_ra_*                                                                *
    182183********************************************************************************/
    183184
    184 static void add_ra_header(struct safe_buffer * sb, struct ra_header_info const * ra_header_info, int cease_adv)
     185static void add_ra_header(struct safe_buffer *sb, struct ra_header_info const *ra_header_info, int cease_adv)
    185186{
    186187        struct nd_router_advert radvert;
     
    201202        } else {
    202203                /* if forwarding is disabled, send zero router lifetime */
    203                 radvert.nd_ra_router_lifetime = !check_ip6_forwarding()? htons(ra_header_info->AdvDefaultLifetime) : 0;
     204                radvert.nd_ra_router_lifetime = !check_ip6_forwarding() ? htons(ra_header_info->AdvDefaultLifetime) : 0;
    204205        }
    205206        radvert.nd_ra_flags_reserved |= (ra_header_info->AdvDefaultPreference << ND_OPT_RI_PRF_SHIFT) & ND_OPT_RI_PRF_MASK;
     
    211212}
    212213
    213 static void add_ra_option_prefix(struct safe_buffer * sb, struct AdvPrefix const * prefix, int cease_adv)
     214static void add_ra_option_prefix(struct safe_buffer *sb, struct AdvPrefix const *prefix, int cease_adv)
    214215{
    215216        struct nd_opt_prefix_info pinfo;
     
    244245}
    245246
    246 static struct safe_buffer_list * add_auto_prefixes_6to4(struct safe_buffer_list * sbl, struct Interface const * iface, char const * ifname, struct AdvPrefix const *prefix, int cease_adv, struct in6_addr const *dest)
     247static struct safe_buffer_list *add_auto_prefixes_6to4(struct safe_buffer_list *sbl, struct Interface const *iface,
     248                                                       char const *ifname, struct AdvPrefix const *prefix, int cease_adv,
     249                                                       struct in6_addr const *dest)
    247250{
    248251#ifdef HAVE_IFADDRS_H
     
    258261                char pfx_str[INET6_ADDRSTRLEN];
    259262                addrtostr(&xprefix.Prefix, pfx_str, sizeof(pfx_str));
    260                 dlog(LOG_DEBUG, 3, "auto-selected prefix %s/%d on interface %s",
    261                         pfx_str, xprefix.PrefixLen, ifname);
     263                dlog(LOG_DEBUG, 3, "auto-selected prefix %s/%d on interface %s", pfx_str, xprefix.PrefixLen, ifname);
    262264
    263265                /* TODO: Something must be done with these. */
     
    265267                (void)xprefix.curr_preferredlft;
    266268
    267                 if(cease_adv || schedule_option_prefix(dest, iface, &xprefix)) {
     269                if (cease_adv || schedule_option_prefix(dest, iface, &xprefix)) {
    268270                        sbl = safe_buffer_list_append(sbl);
    269271                        add_ra_option_prefix(sbl->sb, &xprefix, cease_adv);
     
    274276}
    275277
    276 
    277 static struct safe_buffer_list * add_auto_prefixes(struct safe_buffer_list * sbl, struct Interface const * iface, char const * ifname, struct AdvPrefix const *prefix, int cease_adv, struct in6_addr const *dest)
     278static struct safe_buffer_list *add_auto_prefixes(struct safe_buffer_list *sbl, struct Interface const *iface, char const *ifname,
     279                                                  struct AdvPrefix const *prefix, int cease_adv, struct in6_addr const *dest)
    278280{
    279281#ifdef HAVE_IFADDRS_H
     
    304306                char pfx_str[INET6_ADDRSTRLEN];
    305307                addrtostr(&xprefix.Prefix, pfx_str, sizeof(pfx_str));
    306                 dlog(LOG_DEBUG, 3, "auto-selected prefix %s/%d on interface %s",
    307                         pfx_str, xprefix.PrefixLen, ifname);
     308                dlog(LOG_DEBUG, 3, "auto-selected prefix %s/%d on interface %s", pfx_str, xprefix.PrefixLen, ifname);
    308309
    309310                /* TODO: Something must be done with these. */
     
    311312                (void)xprefix.curr_preferredlft;
    312313
    313                 if(cease_adv || schedule_option_prefix(dest, iface, &xprefix)) {
     314                if (cease_adv || schedule_option_prefix(dest, iface, &xprefix)) {
    314315                        sbl = safe_buffer_list_append(sbl);
    315316                        add_ra_option_prefix(sbl->sb, &xprefix, cease_adv);
     
    323324}
    324325
    325 static struct safe_buffer_list* add_ra_options_prefix(struct safe_buffer_list * sbl, struct Interface const * iface, char const * ifname, struct AdvPrefix const *prefix, int cease_adv, struct in6_addr const *dest)
     326static struct safe_buffer_list *add_ra_options_prefix(struct safe_buffer_list *sbl, struct Interface const *iface,
     327                                                      char const *ifname, struct AdvPrefix const *prefix, int cease_adv,
     328                                                      struct in6_addr const *dest)
    326329{
    327330        while (prefix) {
     
    342345                                }
    343346                        } else {
    344                                 if(cease_adv || schedule_option_prefix(dest, iface, prefix)) {
     347                                if (cease_adv || schedule_option_prefix(dest, iface, prefix)) {
    345348                                        sbl = safe_buffer_list_append(sbl);
    346349                                        add_ra_option_prefix(sbl->sb, prefix, cease_adv);
     
    354357}
    355358
    356 
    357 
    358 /* *INDENT-OFF* */
     359/* clang-format off */
    359360/*
    360361 * Domain Names of DNS Search List
     
    375376 *   MUST be padded with zeros.
    376377 */
    377 /* *INDENT-ON* */
    378 static size_t serialize_domain_names(struct safe_buffer * safe_buffer, struct AdvDNSSL const *dnssl)
     378/* clang-format on */
     379static size_t serialize_domain_names(struct safe_buffer *safe_buffer, struct AdvDNSSL const *dnssl)
    379380{
    380381        size_t len = 0;
     
    411412}
    412413
    413 static struct safe_buffer_list* add_ra_options_route(struct safe_buffer_list *sbl, struct Interface const * iface, struct AdvRoute const *route, int cease_adv, struct in6_addr const *dest)
     414static struct safe_buffer_list *add_ra_options_route(struct safe_buffer_list *sbl, struct Interface const *iface,
     415                                                     struct AdvRoute const *route, int cease_adv, struct in6_addr const *dest)
    414416{
    415417        while (route) {
    416418                struct nd_opt_route_info_local rinfo;
    417419
    418                 if(!cease_adv && !schedule_option_route(dest, iface, route)) {
     420                if (!cease_adv && !schedule_option_route(dest, iface, route)) {
    419421                        route = route->next;
    420422                        continue;
     
    445447}
    446448
    447 static struct safe_buffer_list * add_ra_options_rdnss(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvRDNSS const *rdnss, int cease_adv, struct in6_addr const *dest)
     449static struct safe_buffer_list *add_ra_options_rdnss(struct safe_buffer_list *sbl, struct Interface const *iface,
     450                                                     struct AdvRDNSS const *rdnss, int cease_adv, struct in6_addr const *dest)
    448451{
    449452        while (rdnss) {
    450453                struct nd_opt_rdnss_info_local rdnssinfo;
    451454
    452                 if(!cease_adv && !schedule_option_rdnss(dest, iface, rdnss)) {
     455                if (!cease_adv && !schedule_option_rdnss(dest, iface, rdnss)) {
    453456                        rdnss = rdnss->next;
    454457                        continue;
     
    472475
    473476                sbl = safe_buffer_list_append(sbl);
    474                 safe_buffer_append(sbl->sb, &rdnssinfo, sizeof(rdnssinfo) - (3 - rdnss->AdvRDNSSNumber) * sizeof(struct in6_addr));
     477                safe_buffer_append(sbl->sb, &rdnssinfo,
     478                                   sizeof(rdnssinfo) - (3 - rdnss->AdvRDNSSNumber) * sizeof(struct in6_addr));
    475479
    476480                rdnss = rdnss->next;
     
    480484}
    481485
    482 static struct safe_buffer_list * add_ra_options_dnssl(struct safe_buffer_list * sbl, struct Interface const * iface, struct AdvDNSSL const *dnssl, int cease_adv, struct in6_addr const *dest)
     486static struct safe_buffer_list *add_ra_options_dnssl(struct safe_buffer_list *sbl, struct Interface const *iface,
     487                                                     struct AdvDNSSL const *dnssl, int cease_adv, struct in6_addr const *dest)
    483488{
    484489        struct safe_buffer *serialized_domains = new_safe_buffer();
    485490        while (dnssl) {
    486491
    487                 /* *INDENT-OFF* */
    488                 /*
    489                  * Snippet from RFC 6106...
    490                  *
    491                  *    5.2. DNS Search List Option
    492                  *
    493                  *
    494                  *    The DNSSL option contains one or more domain names of DNS suffixes.
    495                  *    All of the domain names share the same Lifetime value.  If it is
    496                  *    desirable to have different Lifetime values, multiple DNSSL options
    497                  *    can be used.  Figure 2 shows the format of the DNSSL option.
    498                  *
    499                  *       0                   1                   2                   3
    500                  *       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    501                  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    502                  *      |     Type      |     Length    |           Reserved            |
    503                  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    504                  *      |                           Lifetime                            |
    505                  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    506                  *      |                                                               |
    507                  *      :                Domain Names of DNS Search List                :
    508                  *      |                                                               |
    509                  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    510                  *
    511                  *               Figure 2: DNS Search List (DNSSL) Option Format
    512                  *
    513                  *   Fields:
    514                  *     Type          8-bit identifier of the DNSSL option type as assigned
    515                  *                   by the IANA: 31
    516                  *
    517                  *     Length        8-bit unsigned integer.  The length of the option
    518                  *                   (including the Type and Length fields) is in units of
    519                  *                   8 octets.  The minimum value is 2 if at least one
    520                  *                   domain name is contained in the option.  The Length
    521                  *                   field is set to a multiple of 8 octets to accommodate
    522                  *                   all the domain names in the field of Domain Names of
    523                  *                   DNS Search List.
    524                  *
    525                  *     Lifetime      32-bit unsigned integer.  The maximum time, in
    526                  *                   seconds (relative to the time the packet is sent),
    527                  *                   over which this DNSSL domain name MAY be used for
    528                  *                   name resolution.  The Lifetime value has the same
    529                  *                   semantics as with the RDNSS option.  That is, Lifetime
    530                  *                   SHOULD be bounded as follows:
    531                  *                   MaxRtrAdvInterval <= Lifetime <= 2*MaxRtrAdvInterval.
    532                  *                   A value of all one bits (0xffffffff) represents
    533                  *                   infinity.  A value of zero means that the DNSSL
    534                  *                   domain name MUST no longer be used.
    535                  *
    536                  *     Domain Names of DNS Search List
    537                  *                   One or more domain names of DNS Search List that MUST
    538                  *                   be encoded using the technique described in Section
    539                  *                   3.1 of [RFC1035].
    540                  *
    541                  */
    542                 /* *INDENT-ON* */
    543492                struct nd_opt_dnssl_info_local dnsslinfo;
    544493
    545                 if(!cease_adv && !schedule_option_dnssl(dest, iface, dnssl)) {
     494                if (!cease_adv && !schedule_option_dnssl(dest, iface, dnssl)) {
    546495                        dnssl = dnssl->next;
    547496                        continue;
     
    553502                size_t const domain_name_bytes = serialize_domain_names(serialized_domains, dnssl);
    554503                size_t const bytes = sizeof(dnsslinfo) + domain_name_bytes;
    555                 if(bytes > (256 * 8)) {
     504                if (bytes > (256 * 8)) {
    556505                        flog(LOG_ERR, "DNSSL too long for RA option, must be < 2048 bytes.  Exiting.");
    557506                        exit(1);
    558507                }
    559                
     508
    560509                dnsslinfo.nd_opt_dnssli_type = ND_OPT_DNSSL_INFORMATION;
    561510                dnsslinfo.nd_opt_dnssli_len = (bytes + 7) / 8;
     
    575524                safe_buffer_append(sbl->sb, serialized_domains->buffer, serialized_domains->used);
    576525                safe_buffer_pad(sbl->sb, padding);
    577                 //abort();
     526                // abort();
    578527
    579528                dnssl = dnssl->next;
     
    581530        return sbl;
    582531        safe_buffer_free(serialized_domains);
    583 
    584532}
    585533
     
    587535 * add Source Link-layer Address option
    588536 */
    589 static void add_ra_option_sllao(struct safe_buffer * sb, struct sllao const *sllao)
    590 {
    591         /* *INDENT-OFF* */
    592         /*
    593         4.6.1.  Source/Target Link-layer Address
    594 
    595               0                   1                   2                   3
    596               0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    597              +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    598              |     Type      |    Length     |    Link-Layer Address ...
    599              +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    600 
    601            Fields:
    602 
    603               Type
    604                              1 for Source Link-layer Address
    605                              2 for Target Link-layer Address
    606 
    607               Length         The length of the option (including the type and
    608                              length fields) in units of 8 octets.  For example,
    609                              the length for IEEE 802 addresses is 1 [IPv6-
    610                              ETHER].
    611 
    612               Link-Layer Address
    613                              The variable length link-layer address.
    614 
    615                              The content and format of this field (including
    616                              byte and bit ordering) is expected to be specified
    617                              in specific documents that describe how IPv6
    618                              operates over different link layers.  For instance,
    619                              [IPv6-ETHER].
    620 
    621          */
    622         /* *INDENT-ON* */
    623 
     537static void add_ra_option_sllao(struct safe_buffer *sb, struct sllao const *sllao)
     538{
    624539        /* +2 for the ND_OPT_SOURCE_LINKADDR and the length (each occupy one byte) */
    625540        size_t const sllao_bytes = (sllao->if_hwaddr_len / 8) + 2;
     
    634549}
    635550
    636 static void add_ra_option_mtu(struct safe_buffer * sb, uint32_t AdvLinkMTU)
     551static void add_ra_option_mtu(struct safe_buffer *sb, uint32_t AdvLinkMTU)
    637552{
    638553        struct nd_opt_mtu mtu;
     
    652567 * movement detection of mobile nodes
    653568 */
    654 static void add_ra_option_mipv6_rtr_adv_interval(struct safe_buffer * sb, double MaxRtrAdvInterval)
     569static void add_ra_option_mipv6_rtr_adv_interval(struct safe_buffer *sb, double MaxRtrAdvInterval)
    655570{
    656571        uint32_t ival = 1000;
     
    678593 * Dynamic Home Agent Address Discovery
    679594 */
    680 static void add_ra_option_mipv6_home_agent_info(struct safe_buffer * sb, struct mipv6 const * mipv6)
     595static void add_ra_option_mipv6_home_agent_info(struct safe_buffer *sb, struct mipv6 const *mipv6)
    681596{
    682597        struct HomeAgentInfo ha_info;
     
    696611 * Add 6co option
    697612 */
    698 static void add_ra_option_lowpanco(struct safe_buffer * sb, struct AdvLowpanCo const *lowpanco)
     613static void add_ra_option_lowpanco(struct safe_buffer *sb, struct AdvLowpanCo const *lowpanco)
    699614{
    700615        struct nd_opt_6co co;
     
    713628}
    714629
    715 static void add_ra_option_abro(struct safe_buffer * sb, struct AdvAbro const *abroo)
     630static void add_ra_option_abro(struct safe_buffer *sb, struct AdvAbro const *abroo)
    716631{
    717632        struct nd_opt_abro abro;
     
    729644}
    730645
    731 
    732 static struct safe_buffer_list * build_ra_options(struct Interface const * iface, struct in6_addr const *dest)
     646static struct safe_buffer_list *build_ra_options(struct Interface const *iface, struct in6_addr const *dest)
    733647{
    734648        struct safe_buffer_list *sbl = new_safe_buffer_list();
     
    736650
    737651        if (iface->AdvPrefixList) {
    738                 cur = add_ra_options_prefix(cur, iface, iface->props.name, iface->AdvPrefixList, iface->state_info.cease_adv, dest);
     652                cur =
     653                    add_ra_options_prefix(cur, iface, iface->props.name, iface->AdvPrefixList, iface->state_info.cease_adv, dest);
    739654        }
    740655
     
    769684        }
    770685
    771         if (iface->mipv6.AdvHomeAgentInfo && schedule_option_mipv6_home_agent_info(dest, iface)
    772             && (iface->mipv6.AdvMobRtrSupportFlag || iface->mipv6.HomeAgentPreference != 0
    773                 || iface->mipv6.HomeAgentLifetime != iface->ra_header_info.AdvDefaultLifetime)) {
     686        if (iface->mipv6.AdvHomeAgentInfo && schedule_option_mipv6_home_agent_info(dest, iface) &&
     687            (iface->mipv6.AdvMobRtrSupportFlag || iface->mipv6.HomeAgentPreference != 0 ||
     688            iface->mipv6.HomeAgentLifetime != iface->ra_header_info.AdvDefaultLifetime)) {
    774689                cur->next = new_safe_buffer_list();
    775690                cur = cur->next;
     
    801716
    802717        if (dest == NULL) {
    803                 static uint8_t const all_hosts_addr[] = { 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
     718                static uint8_t const all_hosts_addr[] = {0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
    804719                dest = (struct in6_addr const *)all_hosts_addr;
    805720                clock_gettime(CLOCK_MONOTONIC, &iface->times.last_multicast);
     
    808723        update_iface_times(iface);
    809724
    810         char dest_text[INET6_ADDRSTRLEN] = { "" };
    811         char src_text[INET6_ADDRSTRLEN] = { "" };
     725        char dest_text[INET6_ADDRSTRLEN] = {""};
     726        char src_text[INET6_ADDRSTRLEN] = {""};
    812727        addrtostr(dest, dest_text, INET6_ADDRSTRLEN);
    813728        addrtostr(iface->props.if_addr_rasrc, src_text, INET6_ADDRSTRLEN);
     
    818733        // Build RA option list
    819734        struct safe_buffer_list *ra_opts = build_ra_options(iface, dest);
    820 
    821         /* *INDENT-OFF* */
    822         /*
    823          *      RFC4861: 6.2.3.  Router Advertisement Message Content
    824          *         If including all options causes the size of an advertisement to
    825          *         exceed the link MTU, multiple advertisements can be sent, each
    826          *         containing a subset of the options.
    827          *
    828          *      RFC6980: 5.  Specification
    829          *              Nodes MUST NOT employ IPv6 fragmentation for sending any of the
    830          *              following Neighbor Discovery and SEcure Neighbor Discovery messages:
    831          *
    832          *              o  Neighbor Solicitation
    833          *              o  Neighbor Advertisement
    834          *              o  Router Solicitation
    835          *              o  Router Advertisement
    836          *              o  Redirect
    837          *              o  Certification Path Solicitation
    838          *
    839          *              Nodes SHOULD NOT employ IPv6 fragmentation for sending the following
    840          *              messages (see Section 6.4.2 of [RFC3971]):
    841          *
    842          *              o  Certification Path Advertisement
    843          *
    844         */
    845         /* *INDENT-ON* */
    846735
    847736        // Send out one or more RAs, all in the form of (hdr+options),
     
    858747                safe_buffer_append(sb, ra_hdr->buffer, ra_hdr->used);
    859748                // Copy in as many RA options as we can fit.
    860                 while(NULL != cur) {
    861                         if(sb->used == 0) {
     749                while (NULL != cur) {
     750                        if (sb->used == 0) {
    862751                                dlog(LOG_DEBUG, 5, "send_ra: Saw empty buffer!");
    863752                                cur = cur->next;
     
    867756                        total_seen_options++;
    868757                        // Not enough room for the next option in our buffer, just send the buffer now.
    869                         if(sb->used + cur->sb->used > iface->props.max_ra_option_size) {
     758                        if (sb->used + cur->sb->used > iface->props.max_ra_option_size) {
    870759                                // But make sure we send at least one option in each RA
    871760                                // TODO: a future improvement would be to optimize packing of
    872761                                // the options in the minimal number of RAs, such that each one
    873762                                // does not exceed the MTU where possible.
    874                                 if(option_count > 0)
     763                                if (option_count > 0)
    875764                                        break;
    876765                        }
     
    882771                        // ONLY the DNSSL, without other options. RFC6980-conforming nodes
    883772                        // should then ignore the DNSSL.
    884                         if(cur->sb->used > iface->props.max_ra_option_size) {
     773                        if (cur->sb->used > iface->props.max_ra_option_size) {
    885774                                flog(LOG_WARNING,
    886                                                 "send_ra: RA option (type=%hhd) too long for MTU, fragmenting anyway (violates RFC6980)",
    887                                                 (unsigned char)(cur->sb->buffer[0]));
     775                                     "send_ra: RA option (type=%hhd) too long for MTU, fragmenting anyway (violates RFC6980)",
     776                                     (unsigned char)(cur->sb->buffer[0]));
    888777                        }
    889778                        // Add this option to the buffer.
     
    898787                }
    899788
    900                 if(option_count == 0 && total_seen_options > 0) {
     789                if (option_count == 0 && total_seen_options > 0) {
    901790                        // If option_count == 0 and total_seen_options==0 we make sure to
    902791                        // send ONE RA out, so that clients get the RA header fields.
    903                 } else if(option_count == 0 && total_seen_options > 0) {
     792                } else if (option_count == 0 && total_seen_options > 0) {
    904793                        // None of the RA options are scheduled for this window.
    905                         dlog(LOG_DEBUG, 5, "No RA options scheduled in this pass, staying quiet; already sent at least one RA packet");
     794                        dlog(LOG_DEBUG, 5,
     795                             "No RA options scheduled in this pass, staying quiet; already sent at least one RA packet");
    906796                        break;
    907797                }
    908798
    909799                // RA built, now send it.
    910                 dlog(LOG_DEBUG, 5, "sending RA to %s on %s (%s), %lu options (using %lu/%u bytes)", dest_text, iface->props.name, src_text, option_count, sb->used, iface->props.max_ra_option_size);
     800                dlog(LOG_DEBUG, 5, "sending RA to %s on %s (%s), %lu options (using %lu/%u bytes)", dest_text, iface->props.name,
     801                     src_text, option_count, sb->used, iface->props.max_ra_option_size);
    911802                int err = really_send(sock, dest, &iface->props, sb);
    912803                if (err < 0) {
     
    921812                }
    922813
    923         } while(NULL != cur);
     814        } while (NULL != cur);
    924815
    925816        safe_buffer_free(sb);
     
    942833        iov.iov_base = (caddr_t)sb->buffer;
    943834
    944         char __attribute__ ((aligned(8))) chdr[CMSG_SPACE(sizeof(struct in6_pktinfo))];
     835        char __attribute__((aligned(8))) chdr[CMSG_SPACE(sizeof(struct in6_pktinfo))];
    945836        memset(chdr, 0, sizeof(chdr));
    946837        struct cmsghdr *cmsg = (struct cmsghdr *)chdr;
     
    961852        struct msghdr mhdr;
    962853        memset(&mhdr, 0, sizeof(mhdr));
    963         mhdr.msg_name = (caddr_t) & addr;
     854        mhdr.msg_name = (caddr_t)&addr;
    964855        mhdr.msg_namelen = sizeof(struct sockaddr_in6);
    965856        mhdr.msg_iov = &iov;
     
    970861        return sendmsg(sock, &mhdr, 0);
    971862}
    972 
    973863
    974864static int schedule_option_prefix(struct in6_addr const *dest, struct Interface const *iface, struct AdvPrefix const *prefix)
  • src/router/radvd/test/check.c

    r26391 r32663  
    33
    44#include <check.h>
     5#include <stdio.h>
    56#include <stdlib.h>
    6 #include <stdio.h>
     7#include <time.h>
    78#include <unistd.h>
    8 #include <time.h>
    99
    1010#ifdef HAVE_GETOPT_H
     
    1212#endif
    1313
    14 
    1514static void usage(char const *pname);
    1615static void version(void);
    17 Suite * util_suite();
    18 Suite * send_suite();
     16Suite *util_suite();
     17Suite *send_suite();
    1918
    2019#ifdef HAVE_GETOPT_LONG
    2120
    22 /* *INDENT-OFF* */
     21/* clang-format off */
    2322static char usage_str[] = {
    2423"\n"
     
    4443"[-hv] [-m mode] [-s suite] [-t test]"
    4544};
    46 /* *INDENT-ON* */
     45/* clang-format on */
    4746
    4847#endif
    4948
    5049struct options {
    51         char * suite;
    52         char * test;
     50        char *suite;
     51        char *test;
    5352        int mode;
    5453};
    5554
    56 static void process_command_line_args(int argc, char * argv[], struct options * options)
     55static void process_command_line_args(int argc, char *argv[], struct options *options)
    5756{
    5857        char const *pname = ((pname = strrchr(argv[0], '/')) != NULL) ? pname + 1 : argv[0];
    5958        int c;
    60         char * suite = 0;
    61         char * test = 0;
     59        char *suite = 0;
     60        char *test = 0;
    6261        int mode = CK_VERBOSE;
    63        
    64         /* parse args */
     62
     63/* parse args */
    6564#define OPTIONS_STR "s:t:m:vh"
    6665#ifdef HAVE_GETOPT_LONG
     
    7372                switch (c) {
    7473                case 'm':
    75                         if (0 == strcmp(optarg, "SILENT")){
     74                        if (0 == strcmp(optarg, "SILENT")) {
    7675                                mode = CK_SILENT;
    77                         }
    78                         else if (0 == strcmp(optarg, "MINIMAL")){
     76                        } else if (0 == strcmp(optarg, "MINIMAL")) {
    7977                                mode = CK_MINIMAL;
    80                         }
    81                         else if (0 == strcmp(optarg, "NORMAL")){
     78                        } else if (0 == strcmp(optarg, "NORMAL")) {
    8279                                mode = CK_NORMAL;
    83                         }
    84                         else if (0 == strcmp(optarg, "VERBOSE")){
     80                        } else if (0 == strcmp(optarg, "VERBOSE")) {
    8581                                mode = CK_VERBOSE;
    86                         }
    87                         else if (0 == strcmp(optarg, "ENV")){
     82                        } else if (0 == strcmp(optarg, "ENV")) {
    8883                                mode = CK_ENV;
    89                         }
    90                         else {
     84                        } else {
    9185                                fprintf(stderr, "%s: mode, \"%s\", unknown.\n", pname, optarg);
    9286                                exit(1);
     
    125119}
    126120
    127 
    128 int main(int argc, char * argv[])
     121int main(int argc, char *argv[])
    129122{
    130123        srand((unsigned int)time(NULL));
     
    133126        process_command_line_args(argc, argv, &options);
    134127
    135         SRunner * sr = srunner_create(util_suite());
     128        SRunner *sr = srunner_create(util_suite());
    136129        srunner_add_suite(sr, send_suite());
    137130        srunner_run(sr, options.suite, options.test, options.mode);
     
    153146        exit(0);
    154147}
    155 
  • src/router/radvd/test/print_safe_buffer.c

    r32089 r32663  
    11
     2#include "print_safe_buffer.h"
    23#include "../config.h"
    34#include "../radvd.h"
    4 #include "print_safe_buffer.h"
    55
    66#include <stdio.h>
    77
    8 void print_safe_buffer(struct safe_buffer const * sb)
     8void print_safe_buffer(struct safe_buffer const *sb)
    99{
    1010        char buf[4096];
     
    1313}
    1414
    15 size_t snprint_safe_buffer(char *s, size_t size, struct safe_buffer const * sb)
     15size_t snprint_safe_buffer(char *s, size_t size, struct safe_buffer const *sb)
    1616{
    1717        size_t count = 0;
    1818
    19         count += snprintf((s+count), (size-count), "unsigned char expected[] = {");
     19        count += snprintf((s + count), (size - count), "unsigned char expected[] = {");
    2020        count--;
    2121
    2222        for (size_t i = 0; i < sb->used; ++i) {
    2323                if (i % 8 == 0) {
    24                         count += snprintf((s+count), (size-count), "\n\t0x%02x,", sb->buffer[i]);
     24                        count += snprintf((s + count), (size - count), "\n\t0x%02x,", sb->buffer[i]);
    2525                } else {
    26                         count += snprintf((s+count), (size-count), " 0x%02x,", sb->buffer[i]);
     26                        count += snprintf((s + count), (size - count), " 0x%02x,", sb->buffer[i]);
    2727                }
    2828                count--;
    2929        }
    3030
    31         count += snprintf((s+count), (size-count), "\n};\n");
     31        count += snprintf((s + count), (size - count), "\n};\n");
    3232        return count;
    3333}
  • src/router/radvd/test/print_safe_buffer.h

    r32089 r32663  
    55#include "../radvd.h"
    66
    7 size_t snprint_safe_buffer(char *s, size_t size, struct safe_buffer const * sb);
    8 void print_safe_buffer(struct safe_buffer const * sb);
    9 
     7size_t snprint_safe_buffer(char *s, size_t size, struct safe_buffer const *sb);
     8void print_safe_buffer(struct safe_buffer const *sb);
  • src/router/radvd/test/send.c

    r32089 r32663  
    11
     2#include "test/print_safe_buffer.h"
    23#include <check.h>
    3 #include "test/print_safe_buffer.h"
    44
    55/*
     
    99 */
    1010
    11 START_TEST (test_decrement_lifetime)
     11START_TEST(test_decrement_lifetime)
    1212{
    1313        uint32_t lifetime = 10;
     
    1919END_TEST
    2020
    21 static struct Interface * iface = 0;
     21static struct Interface *iface = 0;
    2222
    2323static void iface_setup(void)
     
    3535}
    3636
    37 START_TEST (test_add_ra_header)
     37START_TEST(test_add_ra_header)
    3838{
    3939
     
    4747#else
    4848        unsigned char expected[] = {
    49                 0x86, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
    50                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    51         };
    52 
    53         ck_assert_int_eq(sizeof(expected), sb.used);
    54         ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
    55 #endif
    56 
    57         safe_buffer_free(&sb);
    58 }
    59 END_TEST
    60 
    61 START_TEST (test_add_ra_options_prefix)
     49            0x86, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     50        };
     51
     52        ck_assert_int_eq(sizeof(expected), sb.used);
     53        ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
     54#endif
     55
     56        safe_buffer_free(&sb);
     57}
     58END_TEST
     59
     60START_TEST(test_add_ra_options_prefix)
    6261{
    6362        ck_assert_ptr_ne(0, iface);
     
    7776#else
    7877        unsigned char expected[] = {
    79                 0x03, 0x04, 0x40, 0xe0, 0xff, 0xff, 0xff, 0xff,
    80                 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
    81                 0xfe, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
    82                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    83                 0x03, 0x04, 0x30, 0x80, 0x00, 0x00, 0x27, 0x10,
    84                 0x00, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00,
    85                 0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
    86                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    87                 0x03, 0x04, 0x40, 0xc0, 0x00, 0x01, 0x51, 0x80,
    88                 0x00, 0x00, 0x38, 0x40, 0x00, 0x00, 0x00, 0x00,
    89                 0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
    90                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    91         };
    92 
    93         ck_assert_int_eq(sizeof(expected), sb.used);
    94         ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
    95 #endif
    96 
    97         safe_buffer_free(&sb);
    98 }
    99 END_TEST
    100 
    101 START_TEST (test_add_ra_options_route)
     78            0x03, 0x04, 0x40, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
     79            0xfe, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     80            0x03, 0x04, 0x30, 0x80, 0x00, 0x00, 0x27, 0x10, 0x00, 0x00, 0x03, 0xe8, 0x00, 0x00, 0x00, 0x00,
     81            0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     82            0x03, 0x04, 0x40, 0xc0, 0x00, 0x01, 0x51, 0x80, 0x00, 0x00, 0x38, 0x40, 0x00, 0x00, 0x00, 0x00,
     83            0xfe, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     84        };
     85
     86        ck_assert_int_eq(sizeof(expected), sb.used);
     87        ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
     88#endif
     89
     90        safe_buffer_free(&sb);
     91}
     92END_TEST
     93
     94START_TEST(test_add_ra_options_route)
    10295{
    10396        ck_assert_ptr_ne(0, iface);
     
    117110#else
    118111        unsigned char expected[] = {
    119                 0x18, 0x03, 0x30, 0x18, 0x00, 0x00, 0x27, 0x10,
    120                 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00,
    121                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    122                 0x18, 0x03, 0x28, 0x08, 0xff, 0xff, 0xff, 0xff,
    123                 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00,
    124                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    125                 0x18, 0x03, 0x20, 0x00, 0x00, 0x00, 0x0b, 0xb8,
    126                 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00,
    127                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    128         };
    129 
    130         ck_assert_int_eq(sizeof(expected), sb.used);
    131         ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
    132 #endif
    133         safe_buffer_free(&sb);
    134 }
    135 END_TEST
    136 
    137 
    138 START_TEST (test_add_ra_options_rdnss)
     112            0x18, 0x03, 0x30, 0x18, 0x00, 0x00, 0x27, 0x10, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
     113            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x28, 0x08, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x80, 0x00, 0x0f,
     114            0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x20, 0x00, 0x00, 0x00,
     115            0x0b, 0xb8, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     116        };
     117
     118        ck_assert_int_eq(sizeof(expected), sb.used);
     119        ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
     120#endif
     121        safe_buffer_free(&sb);
     122}
     123END_TEST
     124
     125START_TEST(test_add_ra_options_rdnss)
    139126{
    140127        ck_assert_ptr_ne(0, iface);
     
    154141#else
    155142        unsigned char expected[] = {
    156                 0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2,
    157                 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    158                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
    159                 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    160                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
    161                 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    162                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
    163         };
    164 
    165         ck_assert_int_eq(sizeof(expected), sb.used);
    166         ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
    167 #endif
    168 
    169         safe_buffer_free(&sb);
    170 }
    171 END_TEST
    172 
    173 
    174 START_TEST (test_add_ra_options_rdnss2)
    175 {
    176         static struct Interface * iface = 0;
     143            0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     144            0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     145            0x00, 0x02, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
     146        };
     147
     148        ck_assert_int_eq(sizeof(expected), sb.used);
     149        ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
     150#endif
     151
     152        safe_buffer_free(&sb);
     153}
     154END_TEST
     155
     156START_TEST(test_add_ra_options_rdnss2)
     157{
     158        static struct Interface *iface = 0;
    177159        iface = readin_config("test/test_rdnss.conf");
    178160        ck_assert_ptr_ne(0, iface);
     
    193175#else
    194176        unsigned char expected[] = {
    195                 0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d,
    196                 0x12, 0x34, 0x04, 0x23, 0xfe, 0xfe, 0x04, 0x93,
    197                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
    198         };
    199 
    200         ck_assert_int_eq(sizeof(expected), sb.used);
    201         ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
    202 #endif
    203 
    204         safe_buffer_free(&sb);
    205 }
    206 END_TEST
    207 
    208 
    209 START_TEST (test_add_ra_options_dnssl)
     177            0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x12, 0x34, 0x04, 0x23,
     178            0xfe, 0xfe, 0x04, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
     179        };
     180
     181        ck_assert_int_eq(sizeof(expected), sb.used);
     182        ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
     183#endif
     184
     185        safe_buffer_free(&sb);
     186}
     187END_TEST
     188
     189START_TEST(test_add_ra_options_dnssl)
    210190{
    211191        ck_assert_ptr_ne(0, iface);
     
    225205#else
    226206        unsigned char expected[] = {
    227                 0x1f, 0x09, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe8,
    228                 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06,
    229                 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65,
    230                 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63,
    231                 0x6f, 0x6d, 0x00, 0x06, 0x62, 0x72, 0x61, 0x6e,
    232                 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70,
    233                 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x07,
    234                 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
    235                 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00,
    236                 0x1f, 0x09, 0x00, 0x00, 0x00, 0x00, 0x04, 0x4b,
    237                 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06,
    238                 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65,
    239                 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x6e,
    240                 0x65, 0x74, 0x00, 0x06, 0x62, 0x72, 0x61, 0x6e,
    241                 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70,
    242                 0x6c, 0x65, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x07,
    243                 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
    244                 0x6e, 0x65, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00,
    245                 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x4c,
    246                 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06,
    247                 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65,
    248                 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00, 0x06,
    249                 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65,
    250                 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00, 0x07,
    251                 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00,
    252         };
    253 
    254         ck_assert_int_eq(sizeof(expected), sb.used);
    255         ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
    256 #endif
    257 
    258         safe_buffer_free(&sb);
    259 }
    260 END_TEST
    261 
    262 
    263 START_TEST (test_add_ra_option_mtu)
     207            0x1f, 0x09, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe8, 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, 0x62, 0x72, 0x61,
     208            0x6e, 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x06, 0x62, 0x72,
     209            0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x07, 0x65,
     210            0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x09, 0x00, 0x00,
     211            0x00, 0x00, 0x04, 0x4b, 0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07,
     212            0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68,
     213            0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70,
     214            0x6c, 0x65, 0x03, 0x6e, 0x65, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x4c,
     215            0x06, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d,
     216            0x70, 0x6c, 0x65, 0x00, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65,
     217            0x00, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00,
     218        };
     219
     220        ck_assert_int_eq(sizeof(expected), sb.used);
     221        ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
     222#endif
     223
     224        safe_buffer_free(&sb);
     225}
     226END_TEST
     227
     228START_TEST(test_add_ra_option_mtu)
    264229{
    265230        ck_assert_ptr_ne(0, iface);
     
    274239#else
    275240        unsigned char expected[] = {
    276                 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2,
     241            0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2,
    277242        };
    278243
     
    285250END_TEST
    286251
    287 START_TEST (test_add_ra_option_sllao)
     252START_TEST(test_add_ra_option_sllao)
    288253{
    289254        struct sllao sllao48 = {
    290                 {1, 2, 3, 4, 5, 6, 7, 8},
    291                 48,
    292                 64,
    293                 1500,
    294         };
    295        
     255            {1, 2, 3, 4, 5, 6, 7, 8}, 48, 64, 1500,
     256        };
     257
    296258        struct safe_buffer sb = SAFE_BUFFER_INIT;
    297259        add_ra_option_sllao(&sb, &sllao48);
     
    303265#else
    304266        unsigned char expected48[] = {
    305                 0x01, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
     267            0x01, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
    306268        };
    307269
     
    313275
    314276        struct sllao sllao64 = {
    315                 {1, 2, 3, 4, 5, 6, 7, 8},
    316                 64,
    317                 64,
    318                 1500,
    319         };
    320        
     277            {1, 2, 3, 4, 5, 6, 7, 8}, 64, 64, 1500,
     278        };
     279
    321280        sb = SAFE_BUFFER_INIT;
    322281        add_ra_option_sllao(&sb, &sllao64);
     
    327286#else
    328287        unsigned char expected64[] = {
    329                 0x01, 0x02, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
    330                 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     288            0x01, 0x02, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    331289        };
    332290
     
    339297END_TEST
    340298
    341 START_TEST (test_add_ra_option_lowpanco)
     299START_TEST(test_add_ra_option_lowpanco)
    342300{
    343301        ck_assert_ptr_ne(0, iface);
     
    352310#else
    353311        unsigned char expected[] = {
    354                 0x22, 0x03, 0x32, 0x48, 0x00, 0x00, 0xe8, 0x03,
    355                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    356                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     312            0x22, 0x03, 0x32, 0x48, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00,
     313            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    357314        };
    358315
     
    365322END_TEST
    366323
    367 
    368 START_TEST (test_add_ra_option_abro)
     324START_TEST(test_add_ra_option_abro)
    369325{
    370326        ck_assert_ptr_ne(0, iface);
     
    379335#else
    380336        unsigned char expected[] = {
    381                 0x23, 0x03, 0x0a, 0x00, 0x02, 0x00, 0x02, 0x00,
    382                 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    383                 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
     337            0x23, 0x03, 0x0a, 0x00, 0x02, 0x00, 0x02, 0x00, 0xfe, 0x80, 0x00, 0x00,
     338            0x00, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
    384339        };
    385340
     
    392347END_TEST
    393348
    394 
    395 Suite * send_suite(void)
    396 {
    397         TCase * tc_update = tcase_create("update");
     349Suite *send_suite(void)
     350{
     351        TCase *tc_update = tcase_create("update");
    398352        tcase_add_test(tc_update, test_decrement_lifetime);
    399353
    400         TCase * tc_build = tcase_create("build");
     354        TCase *tc_build = tcase_create("build");
    401355        tcase_add_unchecked_fixture(tc_build, iface_setup, iface_teardown);
    402356        tcase_add_test(tc_build, test_add_ra_header);
     
    415369        suite_add_tcase(s, tc_build);
    416370
    417         return s;       
    418 }
    419 
     371        return s;
     372}
  • src/router/radvd/test/util.c

    r32089 r32663  
    88 */
    99
    10 START_TEST (test_safe_buffer)
     10START_TEST(test_safe_buffer)
    1111{
    1212        struct safe_buffer sb = SAFE_BUFFER_INIT;
     
    1717        safe_buffer_free(&sb);
    1818
    19         struct safe_buffer * sbptr = new_safe_buffer();
     19        struct safe_buffer *sbptr = new_safe_buffer();
    2020        ck_assert_ptr_eq(0, sbptr->buffer);
    2121        ck_assert_int_eq(0, sbptr->allocated);
     
    2626END_TEST
    2727
    28 START_TEST (test_safe_buffer_resize)
    29 {
    30         struct safe_buffer sb = SAFE_BUFFER_INIT;
    31         for(int i = 0; i < 5000; i += 17) {
     28START_TEST(test_safe_buffer_resize)
     29{
     30        struct safe_buffer sb = SAFE_BUFFER_INIT;
     31        for (int i = 0; i < 5000; i += 17) {
    3232                safe_buffer_resize(&sb, i);
    3333                ck_assert_int_ge(sb.allocated, i);
     
    3737END_TEST
    3838
    39 START_TEST (test_safe_buffer_append)
     39START_TEST(test_safe_buffer_append)
    4040{
    4141        struct safe_buffer sb = SAFE_BUFFER_INIT;
     
    4848END_TEST
    4949
    50 START_TEST (test_safe_buffer_append2)
     50START_TEST(test_safe_buffer_append2)
    5151{
    5252        struct safe_buffer sb = SAFE_BUFFER_INIT;
     
    5656        ck_assert_str_eq(sb.buffer, array);
    5757        ck_assert_str_eq(sb.buffer + sizeof(array), array);
    58         ck_assert_int_eq(sb.used, 2*sizeof(array));
    59        
    60         safe_buffer_free(&sb);
    61 }
    62 END_TEST
    63 
    64 START_TEST (test_safe_buffer_pad)
     58        ck_assert_int_eq(sb.used, 2 * sizeof(array));
     59
     60        safe_buffer_free(&sb);
     61}
     62END_TEST
     63
     64START_TEST(test_safe_buffer_pad)
    6565{
    6666        struct safe_buffer sb = SAFE_BUFFER_INIT;
     
    6969        safe_buffer_pad(&sb, 10);
    7070        ck_assert_str_eq(sb.buffer, array);
    71         ck_assert_int_eq(sb.used, 10+sizeof(array));
    72        
    73         safe_buffer_free(&sb);
    74 }
    75 END_TEST
    76 
    77 START_TEST (test_safe_buffer_list)
     71        ck_assert_int_eq(sb.used, 10 + sizeof(array));
     72
     73        safe_buffer_free(&sb);
     74}
     75END_TEST
     76
     77START_TEST(test_safe_buffer_list)
    7878{
    7979        struct safe_buffer_list *sbl = new_safe_buffer_list();
     
    8686END_TEST
    8787
    88 START_TEST (test_safe_buffer_list_to_safe_buffer)
     88START_TEST(test_safe_buffer_list_to_safe_buffer)
    8989{
    9090        struct safe_buffer_list *sbl = new_safe_buffer_list();
     
    100100        ck_assert_str_eq(sb.buffer, array);
    101101        ck_assert_str_eq(sb.buffer + sizeof(array), array);
    102         ck_assert_int_eq(sb.used, 2*sizeof(array));
    103        
     102        ck_assert_int_eq(sb.used, 2 * sizeof(array));
     103
    104104        safe_buffer_free(&sb);
    105105        safe_buffer_list_free(sbl);
     
    107107END_TEST
    108108
    109 START_TEST (test_addrtostr)
     109START_TEST(test_addrtostr)
    110110{
    111111        char buffer[INET6_ADDRSTRLEN] = {""};
    112112        struct in6_addr addr = {
    113                 {
    114                         0xfe, 0x80, 0xfe, 0x80,
    115                         0x00, 0x00, 0x00, 0x00,
    116                         0x00, 0x00, 0x00, 0x00,
    117                         0xff, 0x00, 0x12, 0x34,
    118                 },
     113            {
     114                0xfe, 0x80, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x12, 0x34,
     115            },
    119116        };
    120117        addrtostr(&addr, buffer, sizeof(buffer));
     
    123120END_TEST
    124121
    125 START_TEST (test_addrtostr_overflow)
     122START_TEST(test_addrtostr_overflow)
    126123{
    127124        char buffer[18] = {""};
    128125        struct in6_addr addr = {
    129                 {
    130                         0xfe, 0x80, 0xfe, 0x80,
    131                         0x00, 0x00, 0x00, 0x00,
    132                         0x00, 0x00, 0x00, 0x00,
    133                         0xff, 0x00, 0x12, 0x34,
    134                 },
     126            {
     127                0xfe, 0x80, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x12, 0x34,
     128            },
    135129        };
    136130        addrtostr(&addr, buffer, sizeof(buffer));
     
    139133END_TEST
    140134
    141 START_TEST (test_strdupf)
    142 {
    143         char * str = strdupf("%d %s %zu %c %% char", 1234, "str", (size_t)10, 'c');
     135START_TEST(test_strdupf)
     136{
     137        char *str = strdupf("%d %s %zu %c %% char", 1234, "str", (size_t)10, 'c');
    144138
    145139        ck_assert_str_eq(str, "1234 str 10 c % char");
     
    149143END_TEST
    150144
    151 START_TEST (test_readn)
     145START_TEST(test_readn)
    152146{
    153147        int fd = open("/dev/zero", O_RDONLY);
     
    162156
    163157        ck_assert_int_eq(count, 10000);
    164        
     158
    165159        for (int i = 0; i < sizeof(buffer); ++i) {
    166160                ck_assert_int_eq(buffer[i], 0);
     
    169163END_TEST
    170164
    171 START_TEST (test_writen)
     165START_TEST(test_writen)
    172166{
    173167        int fd = open("/dev/null", O_WRONLY);
     
    185179END_TEST
    186180
    187 static struct Interface * iface = 0;
     181static struct Interface *iface = 0;
    188182
    189183static void iface_setup(void)
     
    201195}
    202196
    203 START_TEST (test_check_dnssl_presence)
     197START_TEST(test_check_dnssl_presence)
    204198{
    205199        int rc = check_dnssl_presence(iface->AdvDNSSLList, "example.com");
     
    214208END_TEST
    215209
    216 START_TEST (test_check_rdnss_presence)
     210START_TEST(test_check_rdnss_presence)
    217211{
    218212        struct in6_addr addr;
     
    220214
    221215        /* The next three should be found */
    222         addr = (struct in6_addr){ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
     216        addr = (struct in6_addr){0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
    223217        rc = check_rdnss_presence(iface->AdvRDNSSList, &addr);
    224218        ck_assert_int_ne(0, rc);
    225219
    226         addr = (struct in6_addr){ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
     220        addr = (struct in6_addr){0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2};
    227221        rc = check_rdnss_presence(iface->AdvRDNSSList, &addr);
    228222        ck_assert_int_ne(0, rc);
    229223
    230         addr = (struct in6_addr){ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 };
     224        addr = (struct in6_addr){0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3};
    231225        rc = check_rdnss_presence(iface->AdvRDNSSList, &addr);
    232226        ck_assert_int_ne(0, rc);
    233227
    234228        /* The next one should *not* be found */
    235         addr = (struct in6_addr){ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 };
     229        addr = (struct in6_addr){0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6};
    236230        rc = check_rdnss_presence(iface->AdvRDNSSList, &addr);
    237231        ck_assert_int_eq(0, rc);
     
    239233END_TEST
    240234
    241 START_TEST (test_rand_between)
     235START_TEST(test_rand_between)
    242236{
    243237        int const RAND_TEST_MAX = 1000;
     
    266260END_TEST
    267261
    268 Suite * util_suite(void)
    269 {
    270         TCase * tc_safe_buffer = tcase_create("safe_buffer");
     262Suite *util_suite(void)
     263{
     264        TCase *tc_safe_buffer = tcase_create("safe_buffer");
    271265        tcase_add_test(tc_safe_buffer, test_safe_buffer);
    272266        tcase_add_test(tc_safe_buffer, test_safe_buffer_resize);