Skip to content

Commit

Permalink
Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
DO1JLR committed May 27, 2017
1 parent fae04bf commit 9ae82ff
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
30 changes: 19 additions & 11 deletions package/simple-radvd/src/simple-radvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#define _GNU_SOURCE

#include <errno.h>
#include <error.h>
#include <ifaddrs.h>
#include <fcntl.h>
#include <poll.h>
Expand Down Expand Up @@ -107,11 +106,12 @@ static struct global {


static inline void exit_errno(const char *message) {
error(1, errno, "error: %s", message);
fprintf(stderr, "error: %s: %s\n", message, strerror(errno));
exit(1);
}

static inline void warn_errno(const char *message) {
error(0, errno, "warning: %s", message);
fprintf(stderr, "warning: %s: %s\n", message, strerror(errno));
}


Expand Down Expand Up @@ -370,7 +370,8 @@ static void handle_rtnl(void) {
return;

case NLMSG_ERROR:
error(1, 0, "error: netlink error");
fprintf(stderr, "error: netlink error");
exit(1);

default:
if (handle_rtnl_msg(nh->nlmsg_type, NLMSG_DATA(nh))) {
Expand Down Expand Up @@ -545,8 +546,10 @@ static void usage(void) {
}

static void add_prefix(const char *prefix) {
if (G.n_prefixes == MAX_PREFIXES)
error(1, 0, "maximum number of prefixes is %i.", MAX_PREFIXES);
if (G.n_prefixes == MAX_PREFIXES) {
fprintf(stderr, "maximum number of prefixes is %i.", MAX_PREFIXES);
exit(1);
}

const size_t len = strlen(prefix)+1;
char prefix2[len];
Expand All @@ -570,16 +573,19 @@ static void add_prefix(const char *prefix) {
return;

error:
error(1, 0, "invalid prefix %s (only prefixes of length 64 are supported).", prefix);
fprintf(stderr, "invalid prefix %s (only prefixes of length 64 are supported).", prefix);
exit(1);
}

static void parse_cmdline(int argc, char *argv[]) {
int c;
while ((c = getopt(argc, argv, "i:p:h")) != -1) {
switch(c) {
case 'i':
if (G.ifname)
error(1, 0, "multiple interfaces are not supported.");
if (G.ifname) {
fprintf(stderr, "multiple interfaces are not supported.");
exit(1);
}

G.ifname = optarg;

Expand All @@ -603,8 +609,10 @@ static void parse_cmdline(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
parse_cmdline(argc, argv);

if (!G.ifname || !G.n_prefixes)
error(1, 0, "interface and prefix arguments are required.");
if (!G.ifname || !G.n_prefixes) {
fprintf(stderr, "interface and prefix arguments are required.");
exit(1);
}

init_random();
init_icmp();
Expand Down
17 changes: 10 additions & 7 deletions package/simple-tc/src/simple-tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#define _GNU_SOURCE

#include <errno.h>
#include <error.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -62,11 +61,12 @@ static int nlerror;


static inline void exit_errno(const char *message) {
error(1, errno, "error: %s", message);
fprintf(stderr, "error: %s: %s\n", message, strerror(errno));
exit(1);
}

static inline void warn_errno(const char *message) {
error(0, errno, "warning: %s", message);
fprintf(stderr, "warning: %s: %s\n", message, strerror(errno));
}


Expand Down Expand Up @@ -124,8 +124,8 @@ static bool do_send(struct nl_msg *msg, bool expect) {
nl_wait_for_ack(sock);

if (nlerror) {
error(0, nlerror, "netlink");
errno = nlerror;
warn_errno("netlink");
return false;
}

Expand Down Expand Up @@ -233,7 +233,8 @@ static inline void usage(void) {
}

static inline void maxrate(void) {
error(1, 0, "error: maximum allowed rate it about 2^25 Kbit/s");
fprintf(stderr, "error: maximum allowed rate it about 2^25 Kbit/s");
exit(1);
}


Expand All @@ -245,8 +246,10 @@ int main(int argc, char *argv[]) {
char *end;

ifindex = if_nametoindex(argv[1]);
if (!ifindex)
error(1, 0, "invalid interface: %s", argv[1]);
if (!ifindex) {
fprintf(stderr, "invalid interface: %s", argv[1]);
exit(1);
}

if (strcmp(argv[2], "-") != 0) {
ingress = strtod(argv[2], &end);
Expand Down

0 comments on commit 9ae82ff

Please sign in to comment.