add .clang-format

This commit is contained in:
Reuben Hawkins
2017-02-04 07:10:59 -08:00
parent b021f6f687
commit 3cda9c0c6c
6 changed files with 14 additions and 124 deletions

7
.clang-format Normal file
View File

@@ -0,0 +1,7 @@
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Linux
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 130

View File

@@ -140,7 +140,7 @@ man_MANS = \
### build support ### ### build support ###
indent: indent:
indent -linux -l125 *.c *.h clang-format -i *.c *.h test/*.c test/*.h
EXTRA_DIST = \ EXTRA_DIST = \
CHANGES \ CHANGES \

View File

@@ -75,7 +75,6 @@ int update_device_info(int sock, struct Interface *iface)
case ARPHRD_ETHER: case ARPHRD_ETHER:
iface->sllao.if_hwaddr_len = 48; iface->sllao.if_hwaddr_len = 48;
iface->sllao.if_prefix_len = 64; iface->sllao.if_prefix_len = 64;
/* *INDENT-OFF* */
char hwaddr[3 * 6]; char hwaddr[3 * 6];
sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x", sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned char)ifr.ifr_hwaddr.sa_data[0], (unsigned char)ifr.ifr_hwaddr.sa_data[0],
@@ -84,7 +83,6 @@ int update_device_info(int sock, struct Interface *iface)
(unsigned char)ifr.ifr_hwaddr.sa_data[3], (unsigned char)ifr.ifr_hwaddr.sa_data[3],
(unsigned char)ifr.ifr_hwaddr.sa_data[4], (unsigned char)ifr.ifr_hwaddr.sa_data[4],
(unsigned char)ifr.ifr_hwaddr.sa_data[5]); (unsigned char)ifr.ifr_hwaddr.sa_data[5]);
/* *INDENT-ON* */
dlog(LOG_DEBUG, 3, "%s hardware address: %s", iface->props.name, hwaddr); dlog(LOG_DEBUG, 3, "%s hardware address: %s", iface->props.name, hwaddr);
iface->props.max_ra_option_size -= 14; /* RFC 2464 */ iface->props.max_ra_option_size -= 14; /* RFC 2464 */
break; break;

View File

@@ -28,7 +28,7 @@
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
/* *INDENT-OFF* */ /* clang-format off */
static char usage_str[] = { static char usage_str[] = {
"\n" "\n"
" -C, --config=PATH Set the config file. Default is /etc/radvd.d.\n" " -C, --config=PATH Set the config file. Default is /etc/radvd.d.\n"
@@ -69,7 +69,7 @@ static char usage_str[] = {
"\t[-f facility] [-p pid_file] [-u username] [-t chrootdir]" "\t[-f facility] [-p pid_file] [-u username] [-t chrootdir]"
}; };
/* *INDENT-ON* */ /* clang-format on */
#endif #endif

119
send.c
View File

@@ -355,7 +355,7 @@ static struct safe_buffer_list* add_ra_options_prefix(struct safe_buffer_list *
/* *INDENT-OFF* */ /* clang-format off */
/* /*
* Domain Names of DNS Search List * Domain Names of DNS Search List
* One or more domain names of DNS Search List that MUST * One or more domain names of DNS Search List that MUST
@@ -374,7 +374,7 @@ static struct safe_buffer_list* add_ra_options_prefix(struct safe_buffer_list *
* encoding parts of the domain name representations * encoding parts of the domain name representations
* MUST be padded with zeros. * MUST be padded with zeros.
*/ */
/* *INDENT-ON* */ /* clang-format on */
static size_t serialize_domain_names(struct safe_buffer * safe_buffer, struct AdvDNSSL const *dnssl) static size_t serialize_domain_names(struct safe_buffer * safe_buffer, struct AdvDNSSL const *dnssl)
{ {
size_t len = 0; size_t len = 0;
@@ -484,62 +484,6 @@ static struct safe_buffer_list * add_ra_options_dnssl(struct safe_buffer_list *
struct safe_buffer *serialized_domains = new_safe_buffer(); struct safe_buffer *serialized_domains = new_safe_buffer();
while (dnssl) { while (dnssl) {
/* *INDENT-OFF* */
/*
* Snippet from RFC 6106...
*
* 5.2. DNS Search List Option
*
*
* The DNSSL option contains one or more domain names of DNS suffixes.
* All of the domain names share the same Lifetime value. If it is
* desirable to have different Lifetime values, multiple DNSSL options
* can be used. Figure 2 shows the format of the DNSSL option.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Type | Length | Reserved |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Lifetime |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* : Domain Names of DNS Search List :
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Figure 2: DNS Search List (DNSSL) Option Format
*
* Fields:
* Type 8-bit identifier of the DNSSL option type as assigned
* by the IANA: 31
*
* Length 8-bit unsigned integer. The length of the option
* (including the Type and Length fields) is in units of
* 8 octets. The minimum value is 2 if at least one
* domain name is contained in the option. The Length
* field is set to a multiple of 8 octets to accommodate
* all the domain names in the field of Domain Names of
* DNS Search List.
*
* Lifetime 32-bit unsigned integer. The maximum time, in
* seconds (relative to the time the packet is sent),
* over which this DNSSL domain name MAY be used for
* name resolution. The Lifetime value has the same
* semantics as with the RDNSS option. That is, Lifetime
* SHOULD be bounded as follows:
* MaxRtrAdvInterval <= Lifetime <= 2*MaxRtrAdvInterval.
* A value of all one bits (0xffffffff) represents
* infinity. A value of zero means that the DNSSL
* domain name MUST no longer be used.
*
* Domain Names of DNS Search List
* One or more domain names of DNS Search List that MUST
* be encoded using the technique described in Section
* 3.1 of [RFC1035].
*
*/
/* *INDENT-ON* */
struct nd_opt_dnssl_info_local dnsslinfo; struct nd_opt_dnssl_info_local dnsslinfo;
if(!cease_adv && !schedule_option_dnssl(dest, iface, dnssl)) { if(!cease_adv && !schedule_option_dnssl(dest, iface, dnssl)) {
@@ -588,39 +532,6 @@ static struct safe_buffer_list * add_ra_options_dnssl(struct safe_buffer_list *
*/ */
static void add_ra_option_sllao(struct safe_buffer * sb, struct sllao const *sllao) static void add_ra_option_sllao(struct safe_buffer * sb, struct sllao const *sllao)
{ {
/* *INDENT-OFF* */
/*
4.6.1. Source/Target Link-layer Address
0 1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length | Link-Layer Address ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Fields:
Type
1 for Source Link-layer Address
2 for Target Link-layer Address
Length The length of the option (including the type and
length fields) in units of 8 octets. For example,
the length for IEEE 802 addresses is 1 [IPv6-
ETHER].
Link-Layer Address
The variable length link-layer address.
The content and format of this field (including
byte and bit ordering) is expected to be specified
in specific documents that describe how IPv6
operates over different link layers. For instance,
[IPv6-ETHER].
*/
/* *INDENT-ON* */
/* +2 for the ND_OPT_SOURCE_LINKADDR and the length (each occupy one byte) */ /* +2 for the ND_OPT_SOURCE_LINKADDR and the length (each occupy one byte) */
size_t const sllao_bytes = (sllao->if_hwaddr_len / 8) + 2; size_t const sllao_bytes = (sllao->if_hwaddr_len / 8) + 2;
size_t const sllao_len = (sllao_bytes + 7) / 8; size_t const sllao_len = (sllao_bytes + 7) / 8;
@@ -818,32 +729,6 @@ static int send_ra(int sock, struct Interface *iface, struct in6_addr const *des
// Build RA option list // Build RA option list
struct safe_buffer_list *ra_opts = build_ra_options(iface, dest); struct safe_buffer_list *ra_opts = build_ra_options(iface, dest);
/* *INDENT-OFF* */
/*
* RFC4861: 6.2.3. Router Advertisement Message Content
* If including all options causes the size of an advertisement to
* exceed the link MTU, multiple advertisements can be sent, each
* containing a subset of the options.
*
* RFC6980: 5. Specification
* Nodes MUST NOT employ IPv6 fragmentation for sending any of the
* following Neighbor Discovery and SEcure Neighbor Discovery messages:
*
* o Neighbor Solicitation
* o Neighbor Advertisement
* o Router Solicitation
* o Router Advertisement
* o Redirect
* o Certification Path Solicitation
*
* Nodes SHOULD NOT employ IPv6 fragmentation for sending the following
* messages (see Section 6.4.2 of [RFC3971]):
*
* o Certification Path Advertisement
*
*/
/* *INDENT-ON* */
// Send out one or more RAs, all in the form of (hdr+options), // Send out one or more RAs, all in the form of (hdr+options),
// such that none of the RAs exceed the link MTU // such that none of the RAs exceed the link MTU
// (max size is pre-computed in iface->props.max_ra_option_size) // (max size is pre-computed in iface->props.max_ra_option_size)

View File

@@ -19,7 +19,7 @@ Suite * send_suite();
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
/* *INDENT-OFF* */ /* clang-format off */
static char usage_str[] = { static char usage_str[] = {
"\n" "\n"
" -h, --help Print the help and quit.\n" " -h, --help Print the help and quit.\n"
@@ -43,7 +43,7 @@ static struct option prog_opt[] = {
static char usage_str[] = { static char usage_str[] = {
"[-hv] [-m mode] [-s suite] [-t test]" "[-hv] [-m mode] [-s suite] [-t test]"
}; };
/* *INDENT-ON* */ /* clang-format on */
#endif #endif