signal(SIGPIPE, SIG_IGN);
if (argc - optind < 1) {
- fatal(0, "at least one vconn argument required; use --help for usage");
+ ofp_fatal(0, "at least one vconn argument required; "
+ "use --help for usage");
}
retval = vlog_server_listen(NULL, NULL);
if (retval) {
- fatal(retval, "Could not listen for vlog connections");
+ ofp_fatal(retval, "Could not listen for vlog connections");
}
n_switches = n_listeners = 0;
if (vconn_is_passive(vconn)) {
if (n_listeners >= MAX_LISTENERS) {
- fatal(0, "max %d passive connections", n_listeners);
+ ofp_fatal(0, "max %d passive connections", n_listeners);
}
listeners[n_listeners++] = vconn;
} else {
if (n_switches >= MAX_SWITCHES) {
- fatal(0, "max %d switch connections", n_switches);
+ ofp_fatal(0, "max %d switch connections", n_switches);
}
new_switch(&switches[n_switches++], vconn, name);
}
}
if (n_switches == 0 && n_listeners == 0) {
- fatal(0, "no active or passive switch connections");
+ ofp_fatal(0, "no active or passive switch connections");
}
die_if_already_running();
} else {
max_idle = atoi(optarg);
if (max_idle < 1 || max_idle > 65535) {
- fatal(0, "--max-idle argument must be between 1 and "
- "65535 or the word 'permanent'");
+ ofp_fatal(0, "--max-idle argument must be between 1 and "
+ "65535 or the word 'permanent'");
}
}
break;
--- /dev/null
+Subproject commit 5e70c38c78be569f075ec4d8f6e224f0d2e3df53
char *xstrdup(const char *);
char *xasprintf(const char *format, ...) PRINTF_FORMAT(1, 2);
-void fatal(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3) NO_RETURN;
-void error(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3);
-void debug(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3);
-void debug_msg(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3);
-void hex_dump(FILE *, const void *, size_t, uintptr_t offset, bool ascii);
+void ofp_fatal(int err_no, const char *format, ...)
+ PRINTF_FORMAT(2, 3) NO_RETURN;
+void ofp_error(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3);
+void ofp_hex_dump(FILE *, const void *, size_t, uintptr_t offset, bool ascii);
#ifdef __cplusplus
}
pid_t pid = already_running();
if (pid) {
if (!force) {
- fatal(0, "%s: already running as pid %ld",
- get_pidfile(), (long int) pid);
+ ofp_fatal(0, "%s: already running as pid %ld",
+ get_pidfile(), (long int) pid);
} else {
VLOG_WARN("%s: %s already running as pid %ld",
get_pidfile(), program_name, (long int) pid);
char c = 0;
int fds[2];
if (pipe(fds) < 0) {
- fatal(errno, "pipe failed");
+ ofp_fatal(errno, "pipe failed");
}
switch (fork()) {
case -1:
/* Error. */
- fatal(errno, "could not fork");
+ ofp_fatal(errno, "could not fork");
break;
}
} else {
sigaddset(&fatal_signal_set, sig_nr);
if (sigaction(sig_nr, NULL, &old_sa)) {
- fatal(errno, "sigaction");
+ ofp_fatal(errno, "sigaction");
}
if (old_sa.sa_handler == SIG_DFL
&& signal(sig_nr, fatal_signal_handler) == SIG_ERR) {
- fatal(errno, "signal");
+ ofp_fatal(errno, "signal");
}
}
atexit(atexit_handler);
fatal_signal_add_hook(restore_all_flags, NULL, true);
af_inet_sock = socket(AF_INET, SOCK_DGRAM, 0);
if (af_inet_sock < 0) {
- fatal(errno, "socket(AF_INET)");
+ ofp_fatal(errno, "socket(AF_INET)");
}
}
}
pcap = tmpfile();
if (!pcap) {
- error(errno, "tmpfile");
+ ofp_error(errno, "tmpfile");
return xstrdup("<error>");
}
fflush(pcap);
if (ferror(pcap)) {
- error(errno, "error writing temporary file");
+ ofp_error(errno, "error writing temporary file");
}
rewind(pcap);
tcpdump = popen(command, "r");
fclose(pcap);
if (!tcpdump) {
- error(errno, "exec(\"%s\")", command);
+ ofp_error(errno, "exec(\"%s\")", command);
return xstrdup("<error>");
}
status = pclose(tcpdump);
if (WIFEXITED(status)) {
if (WEXITSTATUS(status))
- error(0, "tcpdump exited with status %d", WEXITSTATUS(status));
+ ofp_error(0, "tcpdump exited with status %d", WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
- error(0, "tcpdump exited with signal %d", WTERMSIG(status));
+ ofp_error(0, "tcpdump exited with signal %d", WTERMSIG(status));
}
return ds_cstr(&ds);
}
struct timeval tv;
inited = true;
if (gettimeofday(&tv, NULL) < 0) {
- fatal(errno, "gettimeofday");
+ ofp_fatal(errno, "gettimeofday");
}
srand(tv.tv_sec ^ tv.tv_usec);
}
VLOG_WARN("%s: connected", rc->name);
rc->n_successful_connections++;
if (vconn_is_passive(rc->vconn)) {
- error(0, "%s: passive vconn not supported", rc->name);
+ ofp_error(0, "%s: passive vconn not supported", rc->name);
state_transition(rc, S_VOID);
} else {
state_transition(rc, S_ACTIVE);
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
if (sigaction(SIGALRM, &sa, NULL)) {
- fatal(errno, "sigaction(SIGALRM) failed");
+ ofp_fatal(errno, "sigaction(SIGALRM) failed");
}
/* Set up periodic timer. */
itimer.it_interval.tv_usec = TIME_UPDATE_INTERVAL * 1000;
itimer.it_value = itimer.it_interval;
if (setitimer(ITIMER_REAL, &itimer, NULL)) {
- fatal(errno, "setitimer failed");
+ ofp_fatal(errno, "setitimer failed");
}
}
sigemptyset(&sigalrm);
sigaddset(&sigalrm, SIGALRM);
if (sigprocmask(SIG_BLOCK, &sigalrm, oldsigs)) {
- fatal(errno, "sigprocmask");
+ ofp_fatal(errno, "sigprocmask");
}
}
unblock_sigalrm(const sigset_t *oldsigs)
{
if (sigprocmask(SIG_SETMASK, oldsigs, NULL)) {
- fatal(errno, "sigprocmask");
+ ofp_fatal(errno, "sigprocmask");
}
}
static void
out_of_memory(void)
{
- fatal(0, "virtual memory exhausted");
+ ofp_fatal(0, "virtual memory exhausted");
}
void *
return s;
}
-void fatal(int err_no, const char *format, ...)
+void
+ofp_fatal(int err_no, const char *format, ...)
{
va_list args;
exit(EXIT_FAILURE);
}
-void error(int err_no, const char *format, ...)
-{
- va_list args;
-
- fprintf(stderr, "%s: ", program_name);
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- if (err_no != 0)
- fprintf(stderr, " (%s)", strerror(err_no));
- putc('\n', stderr);
-}
-
-void debug(int err_no, const char *format, ...)
+void
+ofp_error(int err_no, const char *format, ...)
{
va_list args;
* byte in 'buf'. If 'ascii' is true then the corresponding ASCII characters
* are also rendered alongside. */
void
-hex_dump(FILE *stream, const void *buf_, size_t size,
- uintptr_t ofs, bool ascii)
+ofp_hex_dump(FILE *stream, const void *buf_, size_t size,
+ uintptr_t ofs, bool ascii)
{
const uint8_t *buf = buf_;
const size_t per_line = 16; /* Maximum bytes per line. */
subscribe = 1;
if (sscanf(suffix, "%d:%d", &dp_idx, &subscribe) < 1) {
- error(0, "%s: syntax error", name);
+ ofp_error(0, "%s: syntax error", name);
return EAFNOSUPPORT;
}
host_name = strtok_r(suffix, "::", &save_ptr);
port_string = strtok_r(NULL, "::", &save_ptr);
if (!host_name) {
- error(0, "%s: bad peer name format", name);
+ ofp_error(0, "%s: bad peer name format", name);
return EAFNOSUPPORT;
}
if (!dh->dh) {
dh->dh = dh->constructor();
if (!dh->dh) {
- fatal(ENOMEM, "out of memory constructing "
- "Diffie-Hellman parameters");
+ ofp_fatal(ENOMEM, "out of memory constructing "
+ "Diffie-Hellman parameters");
}
}
return dh->dh;
host_name = strtok_r(suffix, "::", &save_ptr);
port_string = strtok_r(NULL, "::", &save_ptr);
if (!host_name) {
- error(0, "%s: bad peer name format", name);
+ ofp_error(0, "%s: bad peer name format", name);
return EAFNOSUPPORT;
}
*vconnp = NULL;
prefix_len = strcspn(name, ":");
if (prefix_len == strlen(name)) {
- error(0, "`%s' not correct format for peer name", name);
+ ofp_error(0, "`%s' not correct format for peer name", name);
return EAFNOSUPPORT;
}
for (i = 0; i < ARRAY_SIZE(vconn_classes); i++) {
return retval;
}
}
- error(0, "unknown peer type `%.*s'", (int) prefix_len, name);
+ ofp_error(0, "unknown peer type `%.*s'", (int) prefix_len, name);
return EAFNOSUPPORT;
}
if (arg) {
char *msg = vlog_set_levels_from_string(arg);
if (msg) {
- fatal(0, "processing \"%s\": %s", arg, msg);
+ ofp_fatal(0, "processing \"%s\": %s", arg, msg);
}
} else {
vlog_set_levels(VLM_ANY_MODULE, VLF_ANY_FACILITY, VLL_DBG);
struct vconn *listener;
retval = vconn_open(name, &listener);
if (retval && retval != EAGAIN) {
- fatal(retval, "opening %s", name);
+ ofp_fatal(retval, "opening %s", name);
}
if (!vconn_is_passive(listener)) {
- fatal(0, "%s is not a passive vconn", name);
+ ofp_fatal(0, "%s is not a passive vconn", name);
}
listeners[n_listeners++] = listener;
}
/* Start listening for vlogconf requests. */
retval = vlog_server_listen(NULL, NULL);
if (retval) {
- fatal(retval, "Could not listen for vlog connections");
+ ofp_fatal(retval, "Could not listen for vlog connections");
}
die_if_already_running();
if (s.controller_name) {
retval = rconn_connect(remote_rconn, s.controller_name);
if (retval == EAFNOSUPPORT) {
- fatal(0, "No support for %s vconn", s.controller_name);
+ ofp_fatal(0, "No support for %s vconn", s.controller_name);
}
}
switch_status_register_category(switch_status, "remote",
retval = netdev_open(s->of_name, NETDEV_ETH_TYPE_NONE,
&in_band->of_device);
if (retval) {
- fatal(retval, "Could not open %s device", s->of_name);
+ ofp_fatal(retval, "Could not open %s device", s->of_name);
}
memcpy(in_band->mac, netdev_get_etheraddr(in_band->of_device),
ETH_ADDR_LEN);
/* Bring ofX network device up. */
retval = netdev_open(s->of_name, NETDEV_ETH_TYPE_NONE, &netdev);
if (retval) {
- fatal(retval, "Could not open %s device", s->of_name);
+ ofp_fatal(retval, "Could not open %s device", s->of_name);
}
retval = netdev_turn_flags_on(netdev, NETDEV_UP, true);
if (retval) {
- fatal(retval, "Could not bring %s device up", s->of_name);
+ ofp_fatal(retval, "Could not bring %s device up", s->of_name);
}
netdev_close(netdev);
retval = dhclient_create(s->of_name, modify_dhcp_request,
validate_dhcp_offer, (void *) s, &dhcp);
if (retval) {
- fatal(retval, "Failed to initialize DHCP client");
+ ofp_fatal(retval, "Failed to initialize DHCP client");
}
dhclient_init(dhcp, 0);
} else if (!strcmp(optarg, "closed")) {
s->fail_mode = FAIL_CLOSED;
} else {
- fatal(0,
- "-f or --fail argument must be \"open\" or \"closed\"");
+ ofp_fatal(0, "-f or --fail argument must be \"open\" "
+ "or \"closed\"");
}
break;
case OPT_INACTIVITY_PROBE:
s->probe_interval = atoi(optarg);
if (s->probe_interval < 5) {
- fatal(0, "--inactivity-probe argument must be at least 5");
+ ofp_fatal(0, "--inactivity-probe argument must be at least 5");
}
break;
} else {
s->max_idle = atoi(optarg);
if (s->max_idle < 1 || s->max_idle > 65535) {
- fatal(0, "--max-idle argument must be between 1 and "
- "65535 or the word 'permanent'");
+ ofp_fatal(0, "--max-idle argument must be between 1 and "
+ "65535 or the word 'permanent'");
}
}
break;
case OPT_MAX_BACKOFF:
s->max_backoff = atoi(optarg);
if (s->max_backoff < 1) {
- fatal(0, "--max-backoff argument must be at least 1");
+ ofp_fatal(0, "--max-backoff argument must be at least 1");
} else if (s->max_backoff > 3600) {
s->max_backoff = 3600;
}
if (optarg) {
s->rate_limit = atoi(optarg);
if (s->rate_limit < 1) {
- fatal(0, "--rate-limit argument must be at least 1");
+ ofp_fatal(0, "--rate-limit argument must be at least 1");
}
} else {
s->rate_limit = 1000;
case OPT_BURST_LIMIT:
s->burst_limit = atoi(optarg);
if (s->burst_limit < 1) {
- fatal(0, "--burst-limit argument must be at least 1");
+ ofp_fatal(0, "--burst-limit argument must be at least 1");
}
break;
case 'l':
if (s->n_listeners >= MAX_MGMT) {
- fatal(0, "-l or --listen may be specified at most %d times",
- MAX_MGMT);
+ ofp_fatal(0,
+ "-l or --listen may be specified at most %d times",
+ MAX_MGMT);
}
s->listener_names[s->n_listeners++] = optarg;
break;
argc -= optind;
argv += optind;
if (argc < 1 || argc > 2) {
- fatal(0, "need one or two non-option arguments; use --help for usage");
+ ofp_fatal(0, "need one or two non-option arguments; "
+ "use --help for usage");
}
/* Local and remote vconns. */
if (strncmp(s->nl_name, "nl:", 3)
|| strlen(s->nl_name) < 4
|| s->nl_name[strspn(s->nl_name + 3, "0123456789") + 3]) {
- fatal(0, "%s: argument is not of the form \"nl:DP_IDX\"", s->nl_name);
+ ofp_fatal(0, "%s: argument is not of the form \"nl:DP_IDX\"",
+ s->nl_name);
}
s->of_name = xasprintf("of%s", s->nl_name + 3);
s->controller_name = argc > 1 ? xstrdup(argv[1]) : NULL;
size_t length = regerror(retval, &s->accept_controller_regex, NULL, 0);
char *buffer = xmalloc(length);
regerror(retval, &s->accept_controller_regex, buffer, length);
- fatal(0, "%s: %s", accept_re, buffer);
+ ofp_fatal(0, "%s: %s", accept_re, buffer);
}
s->accept_controller_re = accept_re;
retval = netdev_open(s->of_name, NETDEV_ETH_TYPE_NONE, &netdev);
if (retval) {
- fatal(retval, "Could not open %s device", s->of_name);
+ ofp_fatal(retval, "Could not open %s device", s->of_name);
}
retval = netdev_get_flags(netdev, &flags);
if (retval) {
- fatal(retval, "Could not get flags for %s device", s->of_name);
+ ofp_fatal(retval, "Could not get flags for %s device", s->of_name);
}
s->in_band = (flags & NETDEV_UP) != 0;
signal(SIGPIPE, SIG_IGN);
if (argc - optind != 1) {
- fatal(0, "missing controller argument; use --help for usage");
+ ofp_fatal(0, "missing controller argument; use --help for usage");
}
rconn = rconn_create(60, max_backoff);
error = rconn_connect(rconn, argv[optind]);
if (error == EAFNOSUPPORT) {
- fatal(0, "no support for %s vconn", argv[optind]);
+ ofp_fatal(0, "no support for %s vconn", argv[optind]);
}
error = dp_new(&dp, dpid, rconn);
if (listen_vconn_name) {
retval = vconn_open(listen_vconn_name, &listen_vconn);
if (retval && retval != EAGAIN) {
- fatal(retval, "opening %s", listen_vconn_name);
+ ofp_fatal(retval, "opening %s", listen_vconn_name);
}
if (!vconn_is_passive(listen_vconn)) {
- fatal(0, "%s is not a passive vconn", listen_vconn_name);
+ ofp_fatal(0, "%s is not a passive vconn", listen_vconn_name);
}
dp_add_listen_vconn(dp, listen_vconn);
}
if (error) {
- fatal(error, "could not create datapath");
+ ofp_fatal(error, "could not create datapath");
}
if (port_list) {
add_ports(dp, port_list);
error = vlog_server_listen(NULL, NULL);
if (error) {
- fatal(error, "could not listen for vlog connections");
+ ofp_fatal(error, "could not listen for vlog connections");
}
die_if_already_running();
port = strtok_r(NULL, ",,", &save_ptr)) {
int error = dp_add_port(dp, port);
if (error) {
- fatal(error, "failed to add port %s", port);
+ ofp_fatal(error, "failed to add port %s", port);
}
}
}
case 'd':
if (strlen(optarg) != 12
|| strspn(optarg, "0123456789abcdefABCDEF") != 12) {
- fatal(0, "argument to -d or --datapath-id must be "
- "exactly 12 hex digits");
+ ofp_fatal(0, "argument to -d or --datapath-id must be "
+ "exactly 12 hex digits");
}
dpid = strtoll(optarg, NULL, 16);
if (!dpid) {
- fatal(0, "argument to -d or --datapath-id must be nonzero");
+ ofp_fatal(0, "argument to -d or --datapath-id must "
+ "be nonzero");
}
break;
case OPT_MAX_BACKOFF:
max_backoff = atoi(optarg);
if (max_backoff < 1) {
- fatal(0, "--max-backoff argument must be at least 1");
+ ofp_fatal(0, "--max-backoff argument must be at least 1");
} else if (max_backoff > 3600) {
max_backoff = 3600;
}
case 'l':
if (listen_vconn_name) {
- fatal(0, "-l or --listen may be only specified once");
+ ofp_fatal(0, "-l or --listen may be only specified once");
}
listen_vconn_name = optarg;
break;
argc -= optind;
argv += optind;
if (argc != 1) {
- fatal(0, "exactly one non-option argument required; "
- "use --help for help");
+ ofp_fatal(0, "exactly one non-option argument required; "
+ "use --help for help");
}
error = dhclient_create(argv[0], modify_dhcp_request, NULL, NULL, &cli);
if (error) {
- fatal(error, "dhclient_create failed");
+ ofp_fatal(error, "dhclient_create failed");
}
dhclient_init(cli, request_ip.s_addr);
fatal_signal_add_hook(release, cli, true);
switch (c) {
case OPT_REQUEST_IP:
if (!inet_aton(optarg, &request_ip)) {
- fatal(0, "--request-ip argument is not a valid IP address");
+ ofp_fatal(0,
+ "--request-ip argument is not a valid IP address");
}
break;
argc -= optind;
argv += optind;
if (argc < 1)
- fatal(0, "missing command name; use --help for help");
+ ofp_fatal(0, "missing command name; use --help for help");
for (p = all_commands; p->name != NULL; p++) {
if (!strcmp(p->name, argv[0])) {
int n_arg = argc - 1;
if (n_arg < p->min_args)
- fatal(0, "'%s' command requires at least %d arguments",
- p->name, p->min_args);
+ ofp_fatal(0, "'%s' command requires at least %d arguments",
+ p->name, p->min_args);
else if (n_arg > p->max_args)
- fatal(0, "'%s' command takes at most %d arguments",
- p->name, p->max_args);
+ ofp_fatal(0, "'%s' command takes at most %d arguments",
+ p->name, p->max_args);
else {
p->handler(argc, argv);
exit(0);
}
}
}
- fatal(0, "unknown command '%s'; use --help for help", argv[0]);
+ ofp_fatal(0, "unknown command '%s'; use --help for help", argv[0]);
return 0;
}
case 't':
timeout = strtoul(optarg, NULL, 10);
if (timeout <= 0) {
- fatal(0, "value %s on -t or --timeout is not at least 1",
- optarg);
+ ofp_fatal(0, "value %s on -t or --timeout is not at least 1",
+ optarg);
} else {
time_alarm(timeout);
}
if (strncmp(name, "nl:", 3)
|| strlen(name) < 4
|| name[strspn(name + 3, "0123456789") + 3]) {
- fatal(0, "%s: argument is not of the form \"nl:DP_ID\"", name);
+ ofp_fatal(0, "%s: argument is not of the form \"nl:DP_ID\"", name);
}
run(dpif_open(atoi(name + 3), subscribe, dpif), "opening datapath");
}
for (i = 2; i < argc; i++) {
int retval = function(&dp, argv[i]);
if (retval) {
- error(retval, "failed to %s %s %s %s",
- operation, argv[i], preposition, argv[1]);
+ ofp_error(retval, "failed to %s %s %s %s",
+ operation, argv[i], preposition, argv[1]);
failure = true;
}
}
errno = 0;
value = strtoul(str, &tail, 0);
if (errno == EINVAL || errno == ERANGE || *tail) {
- fatal(0, "invalid numeric format %s", str);
+ ofp_fatal(0, "invalid numeric format %s", str);
}
return value;
}
{
if (sscanf(str, "%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8,
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) != 6) {
- fatal(0, "invalid mac address %s", str);
+ ofp_fatal(0, "invalid mac address %s", str);
}
}
name = strtok_r(str, "//", &save_ptr);
retval = name ? lookup_ip(name, &in_addr) : EINVAL;
if (retval) {
- fatal(0, "%s: could not convert to IP address", str);
+ ofp_fatal(0, "%s: could not convert to IP address", str);
}
*ip = in_addr.s_addr;
/* Verify that the rest of the bits are 1-bits. */
for (; i < 32; i++) {
if (!(nm & (1u << i))) {
- fatal(0, "%s: %s is not a valid netmask", str, netmask);
+ ofp_fatal(0, "%s: %s is not a valid netmask",
+ str, netmask);
}
}
} else {
int prefix = atoi(netmask);
if (prefix <= 0 || prefix > 32) {
- fatal(0, "%s: network prefix bits not between 1 and 32", str);
+ ofp_fatal(0, "%s: network prefix bits not between 1 and 32",
+ str);
}
n_wild = 32 - prefix;
}
} else if (strspn(act, "0123456789") == strlen(act)) {
port = str_to_int(act);
} else {
- fatal(0, "Unknown action: %s", act);
+ ofp_fatal(0, "Unknown action: %s", act);
}
if (port != OFPP_MAX) {
if (action) {
char *act_str = strstr(string, "action");
if (!act_str) {
- fatal(0, "must specify an action");
+ ofp_fatal(0, "must specify an action");
}
*(act_str-1) = '\0';
act_str = strchr(act_str, '=');
if (!act_str) {
- fatal(0, "must specify an action");
+ ofp_fatal(0, "must specify an action");
}
act_str++;
value = strtok(NULL, ", \t\r\n");
if (!value) {
- fatal(0, "field %s missing value", name);
+ ofp_fatal(0, "field %s missing value", name);
}
if (table_idx && !strcmp(name, "table")) {
}
}
} else {
- fatal(0, "unknown keyword %s", name);
+ ofp_fatal(0, "unknown keyword %s", name);
}
}
}
file = fopen(argv[2], "r");
if (file == NULL) {
- fatal(errno, "%s: open", argv[2]);
+ ofp_fatal(errno, "%s: open", argv[2]);
}
run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
run(vconn_transact(vconn, request, &reply), "talking to %s", argv[1]);
if (reply->size != request->size) {
- fatal(0, "reply does not match request");
+ ofp_fatal(0, "reply does not match request");
}
ofpbuf_delete(reply);
vconn_close(vconn);
}
}
if (port_idx == n_ports) {
- fatal(0, "couldn't find monitored port: %s", argv[2]);
+ ofp_fatal(0, "couldn't find monitored port: %s", argv[2]);
}
opm = make_openflow(sizeof(struct ofp_port_mod), OFPT_PORT_MOD, &request);
opm->mask |= htonl(OFPPFL_NO_FLOOD);
opm->desc.flags |= htonl(OFPPFL_NO_FLOOD);
} else {
- fatal(0, "unknown mod-port command '%s'", argv[3]);
+ ofp_fatal(0, "unknown mod-port command '%s'", argv[3]);
}
send_openflow_buffer(vconn, request);
payload = argc > 2 ? atoi(argv[2]) : 64;
if (payload > max_payload) {
- fatal(0, "payload must be between 0 and %zu bytes", max_payload);
+ ofp_fatal(0, "payload must be between 0 and %zu bytes", max_payload);
}
run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
payload_size = atoi(argv[2]);
if (payload_size > max_payload) {
- fatal(0, "payload must be between 0 and %zu bytes", max_payload);
+ ofp_fatal(0, "payload must be between 0 and %zu bytes", max_payload);
}
message_size = sizeof(struct ofp_header) + payload_size;
argc -= optind;
argv += optind;
if (argc < 1) {
- fatal(0, "need at least one non-option argument; "
- "use --help for usage");
+ ofp_fatal(0, "need at least one non-option argument; "
+ "use --help for usage");
}
ifaces = xmalloc(argc * sizeof *ifaces);
}
}
if (!n_ifaces) {
- fatal(0, "failed to initialize any DHCP clients");
+ ofp_fatal(0, "failed to initialize any DHCP clients");
}
for (i = 0; i < n_ifaces; i++) {
size_t length = regerror(retval, &accept_controller_regex, NULL, 0);
char *buffer = xmalloc(length);
regerror(retval, &accept_controller_regex, buffer, length);
- fatal(0, "%s: %s", accept_controller_re, buffer);
+ ofp_fatal(0, "%s: %s", accept_controller_re, buffer);
}
retval = vlog_server_listen(NULL, NULL);
if (retval) {
- fatal(retval, "Could not listen for vlog connections");
+ ofp_fatal(retval, "Could not listen for vlog connections");
}
die_if_already_running();
retval = netdev_open(iface->name, NETDEV_ETH_TYPE_NONE, &netdev);
if (retval) {
- error(retval, "Could not open %s device", iface->name);
+ ofp_error(retval, "Could not open %s device", iface->name);
return false;
}
retval = netdev_turn_flags_on(netdev, NETDEV_UP, true);
if (retval) {
- error(retval, "Could not bring %s device up", iface->name);
+ ofp_error(retval, "Could not bring %s device up", iface->name);
return false;
}
netdev_close(netdev);
retval = dhclient_create(iface->name, modify_dhcp_request,
validate_dhcp_offer, NULL, &iface->dhcp);
if (retval) {
- error(retval, "%s: failed to initialize DHCP client", iface->name);
+ ofp_error(retval, "%s: failed to initialize DHCP client", iface->name);
return false;
}
case 't':
timeout = strtoul(optarg, NULL, 10);
if (timeout <= 0) {
- fatal(0, "value %s on -t or --timeout is not at least 1",
- optarg);
+ ofp_fatal(0, "value %s on -t or --timeout is not at least 1",
+ optarg);
} else {
time_alarm(timeout);
}
free(short_options);
if ((exit_without_bind + exit_after_bind + !detach_after_bind) > 1) {
- fatal(0, "--exit-without-bind, --exit-after-bind, and --no-detach "
- "are mutually exclusive");
+ ofp_fatal(0, "--exit-without-bind, --exit-after-bind, and --no-detach "
+ "are mutually exclusive");
}
if (detach_after_bind) {
set_detach();
argv += optind;
if (argc < 1) {
if (!force) {
- fatal(0, "need at least one non-option argument; "
- "use --help for usage");
+ ofp_fatal(0, "need at least one non-option argument; "
+ "use --help for usage");
}
}
goto got_name;
}
}
- fatal(0, "unknown signal \"%s\"", optarg);
+ ofp_fatal(0, "unknown signal \"%s\"", optarg);
got_name: ;
}
break;
break;
}
if (!strchr("ath", option) && n_clients == 0) {
- fatal(0, "no targets specified (use --help for help)");
+ ofp_fatal(0, "no targets specified (use --help for help)");
} else {
++n_actions;
}