当前位置: 首页>>代码示例>>C++>>正文


C++ VLOG_ERR函数代码示例

本文整理汇总了C++中VLOG_ERR函数的典型用法代码示例。如果您正苦于以下问题:C++ VLOG_ERR函数的具体用法?C++ VLOG_ERR怎么用?C++ VLOG_ERR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VLOG_ERR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parse_sockaddr_components

static bool
parse_sockaddr_components(struct sockaddr_storage *ss,
                          const char *host_s,
                          const char *port_s, uint16_t default_port,
                          const char *s)
{
    struct sockaddr_in *sin = ALIGNED_CAST(struct sockaddr_in *, ss);
    int port;

    if (port_s && port_s[0]) {
        if (!str_to_int(port_s, 10, &port) || port < 0 || port > 65535) {
            VLOG_ERR("%s: bad port number \"%s\"", s, port_s);
        }
    } else {
        port = default_port;
    }

    memset(ss, 0, sizeof *ss);
    if (strchr(host_s, ':')) {
        struct sockaddr_in6 *sin6
            = ALIGNED_CAST(struct sockaddr_in6 *, ss);

        sin6->sin6_family = AF_INET6;
        sin6->sin6_port = htons(port);
        if (!ipv6_parse(host_s, &sin6->sin6_addr)) {
            VLOG_ERR("%s: bad IPv6 address \"%s\"", s, host_s);
            goto exit;
        }
    } else {
开发者ID:AlexanderFroemmgen,项目名称:ovs,代码行数:29,代码来源:socket-util.c

示例2: get_entropy

/* Initializes 'buffer' with 'n' bytes of high-quality random numbers.  Returns
 * 0 if successful, otherwise a positive errno value or EOF on error. */
int
get_entropy(void *buffer, size_t n)
{
#ifndef _WIN32
    size_t bytes_read;
    int error;
    int fd;

    fd = open(urandom, O_RDONLY);
    if (fd < 0) {
        VLOG_ERR("%s: open failed (%s)", urandom, ovs_strerror(errno));
        return errno ? errno : EINVAL;
    }

    error = read_fully(fd, buffer, n, &bytes_read);
    close(fd);

    if (error) {
        VLOG_ERR("%s: read error (%s)", urandom, ovs_retval_to_string(error));
    }
#else
    int error = 0;
    HCRYPTPROV   crypt_prov = 0;

    CryptAcquireContext(&crypt_prov, NULL, NULL,
                        PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
    if (!CryptGenRandom(crypt_prov, n, buffer)) {
        VLOG_ERR("CryptGenRandom: read error (%s)", ovs_lasterror_to_string());
        error = EINVAL;
    }

    CryptReleaseContext(crypt_prov, 0);
#endif
    return error;
}
开发者ID:David-B55,项目名称:ovs,代码行数:37,代码来源:entropy.c

示例3: get_manuf_and_prodname

static void
get_manuf_and_prodname(char *cmd_path, char **manufacturer, char **product_name)
{
    char    dmid_cmd[256];

    snprintf(dmid_cmd, sizeof(dmid_cmd), "%s -s %s",
             cmd_path, "system-manufacturer");

    get_sys_cmd_out(dmid_cmd, manufacturer);
    if (*manufacturer == NULL) {
        VLOG_ERR("Unable to get system manufacturer.");
        return;
    }

    snprintf(dmid_cmd, sizeof(dmid_cmd), "%s -s %s",
             cmd_path, "system-product-name");

    get_sys_cmd_out(dmid_cmd, product_name);
    if (*product_name == NULL) {
        VLOG_ERR("Unable to get system product name.");
        return;
    }
    return;

} /* get_manuf_and_prodname() */
开发者ID:mabnhdev,项目名称:ops-sysd,代码行数:25,代码来源:sysd_util.c

示例4: ptcp_open

static int
ptcp_open(const char *name, char *suffix, struct pvconn **pvconnp)
{
    struct sockaddr_in sin;
    int retval;
    int fd;
    unsigned int yes  = 1;

    fd = socket(AF_INET, SOCK_STREAM, 0);
    if (fd < 0) {
        VLOG_ERR("%s: socket: %s", name, strerror(errno));
        return errno;
    }

    if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes) < 0) {
        VLOG_ERR("%s: setsockopt(SO_REUSEADDR): %s", name, strerror(errno));
        return errno;
    }

    memset(&sin, 0, sizeof sin);
    sin.sin_family = AF_INET;
    sin.sin_addr.s_addr = htonl(INADDR_ANY);
    sin.sin_port = htons(atoi(suffix) ? atoi(suffix) : OFP_TCP_PORT);
    retval = bind(fd, (struct sockaddr *) &sin, sizeof sin);
    if (retval < 0) {
        int error = errno;
        VLOG_ERR("%s: bind: %s", name, strerror(error));
        close(fd);
        return error;
    }

    return new_pstream_pvconn("ptcp", fd, ptcp_accept, pvconnp);
}
开发者ID:TakashiSasaki,项目名称:openflow,代码行数:33,代码来源:vconn-tcp.c

示例5: set_nonblocking

/* Sets 'fd' to non-blocking mode.  Returns 0 if successful, otherwise a
 * positive errno value. */
int
set_nonblocking(int fd)
{
#ifndef _WIN32
    int flags = fcntl(fd, F_GETFL, 0);
    if (flags != -1) {
        if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) != -1) {
            return 0;
        } else {
            VLOG_ERR("fcntl(F_SETFL) failed: %s", ovs_strerror(errno));
            return errno;
        }
    } else {
        VLOG_ERR("fcntl(F_GETFL) failed: %s", ovs_strerror(errno));
        return errno;
    }
#else
    unsigned long arg = 1;
    if (ioctlsocket(fd, FIONBIO, &arg)) {
        int error = sock_errno();
        VLOG_ERR("set_nonblocking failed: %s", sock_strerror(error));
        return error;
    }
    return 0;
#endif
}
开发者ID:AlexanderFroemmgen,项目名称:ovs,代码行数:28,代码来源:socket-util.c

示例6: tcp_open

static int
tcp_open(const char *name, char *suffix, struct vconn **vconnp)
{
    char *save_ptr;
    const char *host_name;
    const char *port_string;
    struct sockaddr_in sin;
    int retval;
    int fd;

    /* Glibc 2.7 has a bug in strtok_r when compiling with optimization that
     * can cause segfaults here:
     * http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614.
     * Using "::" instead of the obvious ":" works around it. */
    host_name = strtok_r(suffix, "::", &save_ptr);
    port_string = strtok_r(NULL, "::", &save_ptr);
    if (!host_name) {
        ofp_error(0, "%s: bad peer name format", name);
        return EAFNOSUPPORT;
    }

    memset(&sin, 0, sizeof sin);
    sin.sin_family = AF_INET;
    if (lookup_ip(host_name, &sin.sin_addr)) {
        return ENOENT;
    }
    sin.sin_port = htons(port_string ? atoi(port_string) : OFP_TCP_PORT);

    fd = socket(AF_INET, SOCK_STREAM, 0);
    if (fd < 0) {
        VLOG_ERR("%s: socket: %s", name, strerror(errno));
        return errno;
    }

    retval = set_nonblocking(fd);
    if (retval) {
        close(fd);
        return retval;
    }

    retval = connect(fd, (struct sockaddr *) &sin, sizeof sin);
    if (retval < 0) {
        if (errno == EINPROGRESS) {
            return new_tcp_vconn(name, fd, EAGAIN, &sin, vconnp);
        } else {
            int error = errno;
            VLOG_ERR("%s: connect: %s", name, strerror(error));
            close(fd);
            return error;
        }
    } else {
        return new_tcp_vconn(name, fd, 0, &sin, vconnp);
    }
}
开发者ID:TakashiSasaki,项目名称:openflow,代码行数:54,代码来源:vconn-tcp.c

示例7: plugins_open_plugin

static int
plugins_open_plugin(const char *filename, void *data)
{
    struct plugin_class *plcl;
    lt_dlhandle handle;

    if (!(handle = lt_dlopenadvise(filename, *(lt_dladvise *)data))) {
        VLOG_ERR("Failed loading %s: %s", filename, lt_dlerror());
        return 0;
    }

    if (!(plcl = (struct plugin_class *)malloc(sizeof(struct plugin_class)))) {
        VLOG_ERR("Couldn't allocate plugin class");
        goto err_plugin_class;
    }

    if (!(plcl->init = lt_dlsym(handle, "init")) ||
        !(plcl->run = lt_dlsym(handle, "run")) ||
        !(plcl->wait = lt_dlsym(handle, "wait")) ||
        !(plcl->destroy = lt_dlsym(handle, "destroy"))) {
            VLOG_ERR("Couldn't initialize the interface for %s", filename);
            goto err_dlsym;
    }

    // The following APIs are optional, so don't fail if they are missing.
    plcl->netdev_register = lt_dlsym(handle, "netdev_register");
    plcl->ofproto_register = lt_dlsym(handle, "ofproto_register");
    plcl->bufmon_register = lt_dlsym(handle, "bufmon_register");


    if (lt_dlcaller_set_data(interface_id, handle, plcl)) {
        VLOG_ERR("plugin %s initialized twice? must be a bug", filename);
        goto err_set_data;
    }

    plcl->init();

    VLOG_INFO("Loaded plugin library %s", filename);
    return 0;

err_set_data:
err_dlsym:
    free(plcl);

err_plugin_class:
    if (lt_dlclose(handle)) {
        VLOG_ERR("Couldn't dlclose %s", filename);
    }

    return 0;
}
开发者ID:ops-snappy,项目名称:ops-openvswitch,代码行数:51,代码来源:plugins.c

示例8: mgmt_intf_set_dhcp

/* Configure management interface as dhcp mode.
 * On success, returns CMD_SUCCESS. On failure, returns CMD_OVSDB_FAILURE.
 */
static int
mgmt_intf_set_dhcp()
{
    const struct ovsrec_system *row = NULL;
    struct ovsdb_idl_txn* status_txn = NULL;
    enum ovsdb_idl_txn_status status;
    struct smap smap = SMAP_INITIALIZER(&smap);

    status_txn = cli_do_config_start();
    if (NULL == status_txn)
    {
        VLOG_ERR(OVSDB_TXN_CREATE_ERROR);
        cli_do_config_abort(status_txn);
        return CMD_OVSDB_FAILURE;
    }

    row = ovsrec_system_first(idl);

    if (!row)
    {
        VLOG_ERR(OVSDB_ROW_FETCH_ERROR);
        cli_do_config_abort(status_txn);
        return CMD_OVSDB_FAILURE;
    }


 /* If current mode is static remove static configs from DB. */
    smap_clone(&smap, &row->mgmt_intf);
    if (is_mode_static(row))
    {
        mgmt_intf_clear_ipv4_config_db(row, &smap);
        mgmt_intf_clear_ipv6_config_db(row, &smap);
    }

    smap_replace(&smap,
                 SYSTEM_MGMT_INTF_MAP_MODE,
                 SYSTEM_MGMT_INTF_MAP_MODE_DHCP);

    ovsrec_system_set_mgmt_intf(row, &smap);
    smap_destroy(&smap);
    status = cli_do_config_finish(status_txn);
    if (TXN_SUCCESS == status || TXN_UNCHANGED == status)
    {
        return CMD_SUCCESS;
    }
    else
    {
        VLOG_ERR(OVSDB_TXN_COMMIT_ERROR);
        return CMD_OVSDB_FAILURE;
    }
}
开发者ID:bluecmd,项目名称:ops-cli,代码行数:54,代码来源:mgmt_intf_vty.c

示例9: discovery_local_port_cb

static void
discovery_local_port_cb(const struct ofp_port *port, void *d_)
{
    struct discovery *d = d_;
    if (port) {
        char name[OFP_MAX_PORT_NAME_LEN + 1];
        struct netdev *netdev;
        int retval;

        /* Check that this was really a change. */
        get_port_name(port, name, sizeof name);
        if (d->dhcp && !strcmp(netdev_get_name(dhclient_get_netdev(d->dhcp)),
                               name)) {
            return;
        }

        /* Destroy current DHCP client. */
        dhclient_destroy(d->dhcp);
        d->dhcp = NULL;

        /* Bring local network device up. */
        retval = netdev_open(name, NETDEV_ETH_TYPE_NONE, &netdev);
        if (retval) {
            VLOG_ERR(LOG_MODULE, "Could not open %s device, discovery disabled: %s",
                     name, strerror(retval));
            return;
        }
        retval = netdev_turn_flags_on(netdev, NETDEV_UP, true);
        if (retval) {
            VLOG_ERR(LOG_MODULE, "Could not bring %s device up, discovery disabled: %s",
                     name, strerror(retval));
            return;
        }
        netdev_close(netdev);

        /* Initialize DHCP client. */
        retval = dhclient_create(name, modify_dhcp_request,
                                 validate_dhcp_offer, (void *) d->s, &d->dhcp);
        if (retval) {
            VLOG_ERR(LOG_MODULE, "Failed to initialize DHCP client, "
                     "discovery disabled: %s", strerror(retval));
            return;
        }
        dhclient_set_max_timeout(d->dhcp, 3);
        dhclient_init(d->dhcp, 0);
    } else {
        dhclient_destroy(d->dhcp);
        d->dhcp = NULL;
    }
}
开发者ID:BiangHoo,项目名称:ofsoftswitch13,代码行数:50,代码来源:discovery.c

示例10: ecmp_config_set_status

static int
ecmp_config_set_status (bool status, const char * field)
{
  const struct ovsrec_system *ovs_row = NULL;
  enum ovsdb_idl_txn_status txn_status;
  struct ovsdb_idl_txn *status_txn = cli_do_config_start ();
  bool rc = false;
  struct smap smap_ecmp_config;

  if (status_txn == NULL)
    {
      VLOG_ERR (OVSDB_TXN_CREATE_ERROR);
      cli_do_config_abort (status_txn);
      return CMD_OVSDB_FAILURE;
    }

  /* Need to set ecmp_config status */
  ovs_row = ovsrec_system_first (idl);

  if (!ovs_row)
    {
      VLOG_ERR (OVSDB_ROW_FETCH_ERROR);
      cli_do_config_abort (status_txn);
      return CMD_OVSDB_FAILURE;
    }

  rc = smap_get_bool (&ovs_row->ecmp_config, field,
                      SYSTEM_ECMP_CONFIG_ENABLE_DEFAULT);

  if (rc != status)
    {
      smap_clone (&smap_ecmp_config, &ovs_row->ecmp_config);
      smap_replace (&smap_ecmp_config, field, status ? "true" : "false");
      VLOG_DBG ("%s Set the ecmp config to status = %s old state = %s",
                __func__, status ? "enabled" : "disabled",
                rc ? "enabled" : "disabled");
      ovsrec_system_set_ecmp_config (ovs_row, &smap_ecmp_config);
      smap_destroy (&smap_ecmp_config);
    }

  txn_status = cli_do_config_finish (status_txn);

  if (txn_status == TXN_SUCCESS || txn_status == TXN_UNCHANGED)
    return CMD_SUCCESS;
  else
    {
      VLOG_ERR (OVSDB_TXN_COMMIT_ERROR);
      return CMD_OVSDB_FAILURE;
    }
}
开发者ID:bluecmd,项目名称:ops-cli,代码行数:50,代码来源:ecmp_vty.c

示例11: make_pidfile

/* If a pidfile has been configured, creates it and stores the running
 * process's pid in it.  Ensures that the pidfile will be deleted when the
 * process exits. */
static void
make_pidfile(void)
{
    if (pidfile) {
        /* Create pidfile via temporary file, so that observers never see an
         * empty pidfile or an unlocked pidfile. */
        long int pid = getpid();
        char *tmpfile;
        int fd;

        tmpfile = xasprintf("%s.tmp%ld", pidfile, pid);
        fatal_signal_add_file_to_unlink(tmpfile);
        fd = open(tmpfile, O_CREAT | O_WRONLY | O_TRUNC, 0666);
        if (fd >= 0) {
            struct flock lck;
            lck.l_type = F_WRLCK;
            lck.l_whence = SEEK_SET;
            lck.l_start = 0;
            lck.l_len = 0;
            if (fcntl(fd, F_SETLK, &lck) != -1) {
                char *text = xasprintf("%ld\n", pid);
                if (write(fd, text, strlen(text)) == strlen(text)) {
                    fatal_signal_add_file_to_unlink(pidfile);
                    if (rename(tmpfile, pidfile) < 0) {
                        VLOG_ERR("failed to rename \"%s\" to \"%s\": %s",
                                 tmpfile, pidfile, strerror(errno));
                        fatal_signal_remove_file_to_unlink(pidfile);
                        close(fd);
                    } else {
                        /* Keep 'fd' open to retain the lock. */
                    }
                    free(text);
                } else {
                    VLOG_ERR("%s: write failed: %s", tmpfile, strerror(errno));
                    close(fd);
                }
            } else {
                VLOG_ERR("%s: fcntl failed: %s", tmpfile, strerror(errno));
                close(fd);
            }
        } else {
            VLOG_ERR("%s: create failed: %s", tmpfile, strerror(errno));
        }
        fatal_signal_remove_file_to_unlink(tmpfile);
        free(tmpfile);
    }
    free(pidfile);
    pidfile = NULL;
}
开发者ID:InCNTRE,项目名称:OFTT,代码行数:52,代码来源:daemon.c

示例12: plugins_init

void
plugins_init(const char *path)
{
    char *plugins_path;
    lt_dladvise advise;

    if (path && !strcmp(path, "none")) {
        return;
    }

    if (!(plugins_path = path ? xstrdup(path) : xstrdup(ovs_pluginsdir()))) {
        VLOG_ERR("Failed to allocate plugins path");
        return;
    }

    if (lt_dlinit() ||
        lt_dlsetsearchpath(plugins_path) ||
        lt_dladvise_init(&advise)) {
        VLOG_ERR("ltdl initializations: %s", lt_dlerror());
        goto err_init;
    }

    if (!(interface_id = lt_dlinterface_register("ovs-plugin", NULL))) {
        VLOG_ERR("lt_dlinterface_register: %s", lt_dlerror());
        goto err_interface_register;
    }

    if (lt_dladvise_global(&advise) || lt_dladvise_ext (&advise) ||
        lt_dlforeachfile(lt_dlgetsearchpath(), &plugins_open_plugin, &advise)) {
        VLOG_ERR("ltdl setting advise: %s", lt_dlerror());
        goto err_set_advise;
    }

    VLOG_INFO("Successfully initialized all plugins");
    return;

err_set_advise:
    lt_dlinterface_free(interface_id);

err_interface_register:
    if (lt_dladvise_destroy(&advise)) {
        VLOG_ERR("destroying ltdl advise%s", lt_dlerror());
        return;
    }

err_init:
    free(plugins_path);
}
开发者ID:ops-snappy,项目名称:ops-openvswitch,代码行数:48,代码来源:plugins.c

示例13: parse_sockaddr_components

static bool
parse_sockaddr_components(struct sockaddr_storage *ss,
                          char *host_s,
                          const char *port_s, uint16_t default_port,
                          const char *s)
{
    struct sockaddr_in *sin = ALIGNED_CAST(struct sockaddr_in *, ss);
    int port;

    if (port_s && port_s[0]) {
        if (!str_to_int(port_s, 10, &port) || port < 0 || port > 65535) {
            VLOG_ERR("%s: bad port number \"%s\"", s, port_s);
            goto exit;
        }
    } else {
        port = default_port;
    }

    memset(ss, 0, sizeof *ss);
    if (host_s && strchr(host_s, ':')) {
        struct sockaddr_in6 *sin6
            = ALIGNED_CAST(struct sockaddr_in6 *, ss);

        char *addr = strsep(&host_s, "%");

        sin6->sin6_family = AF_INET6;
        sin6->sin6_port = htons(port);
        if (!addr || !*addr || !ipv6_parse(addr, &sin6->sin6_addr)) {
            VLOG_ERR("%s: bad IPv6 address \"%s\"", s, addr ? addr : "");
            goto exit;
        }

#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
        char *scope = strsep(&host_s, "%");
        if (scope && *scope) {
            if (!scope[strspn(scope, "0123456789")]) {
                sin6->sin6_scope_id = atoi(scope);
            } else {
                sin6->sin6_scope_id = if_nametoindex(scope);
                if (!sin6->sin6_scope_id) {
                    VLOG_ERR("%s: bad IPv6 scope \"%s\" (%s)",
                             s, scope, ovs_strerror(errno));
                    goto exit;
                }
            }
        }
#endif
    } else {
开发者ID:aserdean,项目名称:ovs,代码行数:48,代码来源:socket-util.c

示例14: _sysd_process_daemons

static int
_sysd_process_daemons(struct shash *object) {
    const struct shash_node *dnode;

    SHASH_FOR_EACH (dnode, object) {
        daemons = realloc(daemons, sizeof(daemon_info_t*)*(num_daemons+1));
        daemons[num_daemons] = calloc(sizeof(daemon_info_t), 1);
        if (daemons[num_daemons] == (daemon_info_t *) NULL) {
            VLOG_ERR("Error processing daemon information");
            return (-1);
        }

        strncpy(daemons[num_daemons]->name, dnode->name, strlen(dnode->name));

        /* If this row is sysd, then go ahead and set cur_hw = 1 since
           ...everything is being done in one transaction. */

        if (strncmp(daemons[num_daemons]->name, NAME_IN_DAEMON_TABLE,
                    strlen(NAME_IN_DAEMON_TABLE)) == 0 ) {
            daemons[num_daemons]->cur_hw = 1;
        }
        else
        {
            daemons[num_daemons]->cur_hw = 0;
        }

        _sysd_get_hw_handler(json_object(dnode->data));

        num_daemons++;
    }
开发者ID:mabnhdev,项目名称:ops-sysd,代码行数:30,代码来源:sysd_util.c

示例15: vtysh_ovsdb_config_logmsg

/*-----------------------------------------------------------------------------
| Function: vtysh_ovsdb_config_logmsg
| Responsibility : logs info/dbg/err/warn level message
| Parameters: loglevel - logging level INFO/DBG/ERR/WARN
|             fmt - log message foramt
|             elipses - variable args
| Return: void
-----------------------------------------------------------------------------*/
void
vtysh_ovsdb_config_logmsg(int loglevel, char *fmt, ...)
{

  va_list args;
  va_start(args, fmt);

  switch (loglevel) {

    case VTYSH_OVSDB_CONFIG_ERR:
          VLOG_ERR(fmt, args);
          break;
    case VTYSH_OVSDB_CONFIG_WARN:
          VLOG_WARN(fmt, args);
          break;
    case VTYSH_OVSDB_CONFIG_INFO:
          VLOG_INFO(fmt, args);
          break;
    case VTYSH_OVSDB_CONFIG_DBG:
          VLOG_DBG(fmt, args);
          break;
    default :
          break;
  }
  va_end(args);
}
开发者ID:bluecmd,项目名称:ops-cli,代码行数:34,代码来源:vtysh_ovsdb_config.c


注:本文中的VLOG_ERR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。