• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sd_bus_message_read函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: count_addresses

static int count_addresses(sd_bus_message *m, int af, const char **canonical) {
        int c = 0, r, ifindex;

        assert(m);
        assert(canonical);

        r = sd_bus_message_read(m, "i", &ifindex);
        if (r < 0)
                return r;

        r = sd_bus_message_enter_container(m, 'a', "(iay)");
        if (r < 0)
                return r;

        while ((r = sd_bus_message_enter_container(m, 'r', "iay")) > 0) {
                int family;

                r = sd_bus_message_read(m, "i", &family);
                if (r < 0)
                        return r;

                r = sd_bus_message_skip(m, "ay");
                if (r < 0)
                        return r;

                r = sd_bus_message_exit_container(m);
                if (r < 0)
                        return r;

                if (af != AF_UNSPEC && family != af)
                        continue;

                c ++;
        }
        if (r < 0)
                return r;

        r = sd_bus_message_exit_container(m);
        if (r < 0)
                return r;

        r = sd_bus_message_read(m, "s", canonical);
        if (r < 0)
                return r;

        r = sd_bus_message_rewind(m, true);
        if (r < 0)
                return r;

        return c;
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:51,代码来源:nss-resolve.c


示例2: bus_machine_method_kill

int bus_machine_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
        Machine *m = userdata;
        const char *swho;
        int32_t signo;
        KillWho who;
        int r;

        assert(bus);
        assert(message);
        assert(m);

        r = sd_bus_message_read(message, "si", &swho, &signo);
        if (r < 0)
                return r;

        if (isempty(swho))
                who = KILL_ALL;
        else {
                who = kill_who_from_string(swho);
                if (who < 0)
                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho);
        }

        if (signo <= 0 || signo >= _NSIG)
                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo);

        r = machine_kill(m, who, signo);
        if (r < 0)
                return r;

        return sd_bus_reply_method_return(message, NULL);
}
开发者ID:chenyf,项目名称:systemd,代码行数:32,代码来源:machine-dbus.c


示例3: generate_signals

static int generate_signals(sd_bus_message *m, void *userdata, sd_bus_error
        *ret_error) {
    uint64_t num_signals, payload_size;
    uint64_t i = 0;
    double c_time;
    int r;
    struct timeval ts;
    char *pl = NULL;

    /* Read the parameters */
    r = sd_bus_message_read(m, "tt", &num_signals, &payload_size);
    if (r < 0) {
        fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r));
        return r;
    }

    printf("SpamSignal: %"PRIu64", %"PRIu64 "\n", num_signals,
            payload_size);

    pl = (char*) malloc(payload_size + 1);
    _rs(pl, payload_size);

    for (i = 0; i < num_signals; i++) {
        c_time = time_time();
        r = sd_bus_emit_signal(bus, OBJ, INT,
                "Spam", "dts", c_time, payload_size, pl);
        if (r < 0) {
            fprintf(stderr, "Failed to emit signal: %s\n", strerror(-r));
            free(pl);
            return sd_bus_reply_method_return(m, "t", i);
        }
    }
    free(pl);
    return sd_bus_reply_method_return(m, "t", num_signals);
}
开发者ID:bossjones,项目名称:dbus-signals,代码行数:35,代码来源:spamsignals.c


示例4: PmonInit

static int PmonInit(sd_bus_message *m, void *userdata, sd_bus_error *retError)
{
	usec_t time = 0;
	sd_bus_message_read(m, "t", &time);
	int id = 0;
	if (openSlots == 0) {
		return sd_bus_reply_method_return(m, "u", -1);
	}

	uint64_t usec = 0;
	sd_event_now(event, CLOCK_MONOTONIC, &usec);
	usec += time;
	if (clients[lastAllocatedId] == NULL) {
		id = lastAllocatedId;

		sd_event_add_time(event, &clients[lastAllocatedId], CLOCK_MONOTONIC, usec, 1000,
					Timeout, (void *)sd_bus_message_get_sender(m));
		lastAllocatedId += 1;
		openSlots -= 1;
		clientTimeout[id] = time;
		return sd_bus_reply_method_return(m, "u", id);
	}

	id = freeIds[lastFreedSlot];

	sd_event_add_time(event, &clients[freeIds[lastFreedSlot]], CLOCK_MONOTONIC, usec, 1000,
				Timeout, (void *)sd_bus_message_get_sender(m));

	lastFreedSlot -= 1;
	openSlots -= 1;
	clientTimeout[id] = time;
	return sd_bus_reply_method_return(m, "u", id);
}
开发者ID:clockley,项目名称:watchdogd,代码行数:33,代码来源:dbusapi.c


示例5: print_inhibitors

static void print_inhibitors(sd_bus *bus) {
        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
        const char *what, *who, *why, *mode;
        uint32_t uid, pid;
        unsigned n = 0;
        int r;

        r = sd_bus_call_method(bus,
                        "org.freedesktop.login1",
                        "/org/freedesktop/login1",
                        "org.freedesktop.login1.Manager",
                        "ListInhibitors",
                        &error,
                        &reply,
                        "");
        assert_se(r >= 0);

        r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssuu)");
        assert_se(r >= 0);

        while ((r = sd_bus_message_read(reply, "(ssssuu)", &what, &who, &why, &mode, &uid, &pid)) > 0) {
                printf("what=<%s> who=<%s> why=<%s> mode=<%s> uid=<%"PRIu32"> pid=<%"PRIu32">\n",
                       what, who, why, mode, uid, pid);

                n++;
        }
        assert_se(r >= 0);

        printf("%u inhibitors\n", n);
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:31,代码来源:test-inhibit.c


示例6: kbdctx_set_locale

static int kbdctx_set_locale(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
        kbdctx *kc = userdata;
        const char *s, *ctype = NULL, *lang = NULL;
        int r;

        r = sd_bus_message_enter_container(m, 'a', "s");
        if (r < 0)
                goto error;

        while ((r = sd_bus_message_read(m, "s", &s)) > 0) {
                if (!ctype)
                        ctype = startswith(s, "LC_CTYPE=");
                if (!lang)
                        lang = startswith(s, "LANG=");
        }

        if (r < 0)
                goto error;

        r = sd_bus_message_exit_container(m);
        if (r < 0)
                goto error;

        kbdctx_refresh_compose_table(kc, ctype ? : lang);
        r = 0;

error:
        if (r < 0)
                log_debug_errno(r, "idev-keyboard: cannot parse locale property from locale1: %m");

        return r;
}
开发者ID:RaghavanSanthanam,项目名称:systemd,代码行数:32,代码来源:idev-keyboard.c


示例7: sd_bus_release_name

int sd_bus_release_name(sd_bus *bus, const char *name) {
        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
        uint32_t ret;
        int r;

        if (!bus)
                return -EINVAL;
        if (!name)
                return -EINVAL;

        r = sd_bus_call_method(
                        bus,
                        "org.freedesktop.DBus",
                        "/",
                        "org.freedesktop.DBus",
                        "ReleaseName",
                        NULL,
                        &reply,
                        "s",
                        name);
        if (r < 0)
                return r;

        r = sd_bus_message_read(reply, "u", &ret);
        if (r < 0)
                return r;

        return ret;
}
开发者ID:olegchir,项目名称:systemd,代码行数:29,代码来源:bus-control.c


示例8: sd_bus_get_owner_pid

int sd_bus_get_owner_pid(sd_bus *bus, const char *name, pid_t *pid) {
        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
        uint32_t u;
        int r;

        if (!bus)
                return -EINVAL;
        if (!name)
                return -EINVAL;
        if (!pid)
                return -EINVAL;

        r = sd_bus_call_method(
                        bus,
                        "org.freedesktop.DBus",
                        "/",
                        "org.freedesktop.DBus",
                        "GetConnectionUnixProcessID",
                        NULL,
                        &reply,
                        "s",
                        name);
        if (r < 0)
                return r;

        r = sd_bus_message_read(reply, "u", &u);
        if (r < 0)
                return r;

        if (u == 0)
                return -EIO;

        *pid = (uid_t) u;
        return 0;
}
开发者ID:olegchir,项目名称:systemd,代码行数:35,代码来源:bus-control.c


示例9: server

static void server(sd_bus *b, size_t *result) {
        int r;

        for (;;) {
                _cleanup_bus_message_unref_ sd_bus_message *m = NULL;

                r = sd_bus_process(b, &m);
                assert_se(r >= 0);

                if (r == 0)
                        assert_se(sd_bus_wait(b, (usec_t) -1) >= 0);
                if (!m)
                        continue;

                if (sd_bus_message_is_method_call(m, "benchmark.server", "Ping"))
                        assert_se(sd_bus_reply_method_return(b, m, NULL) >= 0);
                else if (sd_bus_message_is_method_call(m, "benchmark.server", "Work")) {
                        const void *p;
                        size_t sz;

                        /* Make sure the mmap is mapped */
                        assert_se(sd_bus_message_read_array(m, 'y', &p, &sz) > 0);

                        assert_se(sd_bus_reply_method_return(b, m, NULL) >= 0);
                } else if (sd_bus_message_is_method_call(m, "benchmark.server", "Exit")) {
                        uint64_t res;
                        assert_se(sd_bus_message_read(m, "t", &res) > 0);

                        *result = res;
                        return;

                } else
                        assert_not_reached("Unknown method");
        }
}
开发者ID:prodigeni,项目名称:systemd,代码行数:35,代码来源:test-bus-kernel-benchmark.c


示例10: method_echo

static int method_echo(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
	char *str;
	const char *intf = sd_bus_message_get_interface(m),
	      *path = sd_bus_message_get_path(m);
	sd_bus *bus = sd_bus_message_get_bus(m);

	char response[512] = {0};
	int r;

	/* Read the parameters */
	r = sd_bus_message_read(m, "s", &str);
	if (r < 0) {
		fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r));
		return r;
	}

	r = sd_bus_emit_signal(bus, path, intf, "MethodInvoked", "ss",
			"Echo method was invoked", path);
	if (r < 0) {
		fprintf(stderr, "Failed to emit signal: %s\n", strerror(-r));
		return r;
	}

	strncat(response, path, 128);
	strcat(response, " says ");
	strncat(response, str, 128);

	/* Reply with the response */
	return sd_bus_reply_method_return(m, "s", &response);
}
开发者ID:bradbishop,项目名称:openbmc,代码行数:30,代码来源:obmc-phosphor-example-sdbus.c


示例11: get_creds

static int get_creds(sd_bus *bus, sd_bus_message *m, uint64_t mask, sd_bus_creds **_creds, sd_bus_error *error) {
        _cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
        const char *name;
        int r;

        assert(bus);
        assert(m);
        assert(_creds);

        r = sd_bus_message_read(m, "s", &name);
        if (r < 0)
                return r;

        assert_return(service_name_is_valid(name), -EINVAL);

        r = sd_bus_get_owner(bus, name, mask, &c);
        if (r == -ENOENT || r == -ENXIO)
                return sd_bus_error_setf(error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Name %s is currently not owned by anyone.", name);
        if (r < 0)
                return r;

        if ((c->mask & mask) != mask)
                return -ENOTSUP;

        *_creds = c;
        c = NULL;

        return 0;
}
开发者ID:jaanek,项目名称:systemd,代码行数:29,代码来源:bus-driverd.c


示例12: show_one_name

static int show_one_name(sd_bus *bus, const char* attr) {
        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
        const char *s;
        int r;

        r = sd_bus_get_property(
                        bus,
                        "org.freedesktop.hostname1",
                        "/org/freedesktop/hostname1",
                        "org.freedesktop.hostname1",
                        attr,
                        &error, &reply, "s");
        if (r < 0) {
                log_error("Could not get property: %s", bus_error_message(&error, -r));
                return r;
        }

        r = sd_bus_message_read(reply, "s", &s);
        if (r < 0)
                return bus_log_parse_error(r);

        printf("%s\n", s);

        return 0;
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:26,代码来源:hostnamectl.c


示例13: bus_image_method_set_limit

int bus_image_method_set_limit(
                sd_bus_message *message,
                void *userdata,
                sd_bus_error *error) {

        Image *image = userdata;
        Manager *m = image->userdata;
        uint64_t limit;
        int r;

        assert(message);

        r = sd_bus_message_read(message, "t", &limit);
        if (r < 0)
                return r;

        r = bus_verify_polkit_async(
                        message,
                        CAP_SYS_ADMIN,
                        "org.freedesktop.machine1.manage-images",
                        false,
                        UID_INVALID,
                        &m->polkit_registry,
                        error);
        if (r < 0)
                return r;
        if (r == 0)
                return 1; /* Will call us back */

        r = image_set_limit(image, limit);
        if (r < 0)
                return r;

        return sd_bus_reply_method_return(message, NULL);
}
开发者ID:AlexBaranosky,项目名称:systemd,代码行数:35,代码来源:image-dbus.c


示例14: something_handler

static int something_handler(sd_bus_message *m, void *userdata, sd_bus_error *error) {
        struct context *c = userdata;
        const char *s;
        char *n = NULL;
        int r;

        r = sd_bus_message_read(m, "s", &s);
        assert_se(r > 0);

        n = strjoin("<<<", s, ">>>", NULL);
        assert_se(n);

        free(c->something);
        c->something = n;

        log_info("AlterSomething() called, got %s, returning %s", s, n);

        /* This should fail, since the return type doesn't match */
        assert_se(sd_bus_reply_method_return(m, "u", 4711) == -ENOMSG);

        r = sd_bus_reply_method_return(m, "s", n);
        assert_se(r >= 0);

        return 1;
}
开发者ID:rhvgoyal,项目名称:systemd,代码行数:25,代码来源:test-bus-objects.c


示例15: sprintf

// Sets up the sd_bus structures for the given fru type
int ipmi_fru::setup_sd_bus_paths(void)
{
    // Need this to get respective DBUS objects
    sd_bus_error bus_error = SD_BUS_ERROR_NULL;
    sd_bus_message *response = NULL;
    int rc = 0;

    // What we need is BOARD_1, PRODUCT_1, CHASSIS_1 etc..
    char *inv_bus_name, *inv_obj_path, *inv_intf_name;
    char fru_area_name[16] = {0};
    sprintf(fru_area_name,"%s%d",iv_name.c_str(), iv_fruid);

#ifdef __IPMI_DEBUG__
    printf("Getting sd_bus for :[%s]\n",fru_area_name);
#endif

    // We want to call a method "getObjectFromId" on System Bus that is
    // made available over  OpenBmc system services.

    rc = sd_bus_call_method(iv_bus_type,                // On the System Bus
                            sys_bus_name,               // Service to contact
                            sys_object_name,            // Object path
                            sys_intf_name,              // Interface name
                            "getObjectFromId",          // Method to be called
                            &bus_error,                 // object to return error
                            &response,                  // Response message on success
                            "ss",                       // input message (string,string)
                            "FRU_STR",                  // First argument to getObjectFromId
                            fru_area_name);             // Second Argument
    if(rc < 0)
    {
        fprintf(stderr, "Failed to resolve fruid:[%d] to dbus: [%s]\n", iv_fruid, bus_error.message);
    }
    else
    {
        // Method getObjectFromId returns 3 parameters and all are strings, namely
        // bus_name , object_path and interface name for accessing that particular
        // FRU over Inventory SDBUS manager. 'sss' here mentions that format.
        rc = sd_bus_message_read(response, "(sss)", &inv_bus_name, &inv_obj_path, &inv_intf_name);
        if(rc < 0)
        {
            fprintf(stderr, "Failed to parse response message:[%s]\n", strerror(-rc));
        }
        else
        {
            // Update the paths in the area object
            update_dbus_paths(inv_bus_name, inv_obj_path, inv_intf_name);
        }
    }

#ifdef __IPMI_DEBUG__
            printf("fru_area=[%s], inv_bus_name=[%s], inv_obj_path=[%s], inv_intf_name=[%s]\n",
                    fru_area_name, inv_bus_name, inv_obj_path, inv_intf_name);
#endif

    sd_bus_error_free(&bus_error);
    sd_bus_message_unref(response);

    return rc;
}
开发者ID:vishwabmc,项目名称:ipmi-fru-parser,代码行数:61,代码来源:writefrudata.C


示例16: method_set_hostname

static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *error) {
    Context *c = userdata;
    const char *name;
    int interactive;
    char *h;
    int r;

    assert(m);
    assert(c);

    r = sd_bus_message_read(m, "sb", &name, &interactive);
    if (r < 0)
        return r;

    if (isempty(name))
        name = c->data[PROP_STATIC_HOSTNAME];

    if (isempty(name))
        name = "localhost";

    if (!hostname_is_valid(name, false))
        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", name);

    if (streq_ptr(name, c->data[PROP_HOSTNAME]))
        return sd_bus_reply_method_return(m, NULL);

    r = bus_verify_polkit_async(
            m,
            CAP_SYS_ADMIN,
            "org.freedesktop.hostname1.set-hostname",
            NULL,
            interactive,
            UID_INVALID,
            &c->polkit_registry,
            error);
    if (r < 0)
        return r;
    if (r == 0)
        return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */

    h = strdup(name);
    if (!h)
        return -ENOMEM;

    free(c->data[PROP_HOSTNAME]);
    c->data[PROP_HOSTNAME] = h;

    r = context_update_kernel_hostname(c);
    if (r < 0) {
        log_error_errno(r, "Failed to set host name: %m");
        return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %s", strerror(-r));
    }

    log_info("Changed host name to '%s'", strna(c->data[PROP_HOSTNAME]));

    (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), "/org/freedesktop/hostname1", "org.freedesktop.hostname1", "Hostname", NULL);

    return sd_bus_reply_method_return(m, NULL);
}
开发者ID:NetworkManager,项目名称:systemd,代码行数:59,代码来源:hostnamed.c


示例17: driver_remove_match

static int driver_remove_match(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {

        struct bus_match_component *components = NULL;
        _cleanup_free_ char *normalized = NULL;
        Context *context = userdata;
        unsigned n_components = 0;
        Client *c = NULL;
        Match *m = NULL;
        char *arg0;
        uint64_t id;
        int r;

        assert(bus);
        assert(message);
        assert(context);

        r = sd_bus_message_read(message, "s", &arg0);
        if (r < 0)
                return r;

        r = bus_kernel_parse_unique_name(message->sender, &id);
        if (r < 0)
                return r;

        c = hashmap_get(context->clients, &id);
        if (!c)
                return sd_bus_error_setf(error, SD_BUS_ERROR_MATCH_RULE_NOT_FOUND, "You have not registered any matches.");

        r = bus_match_parse(arg0, &components, &n_components);
        if (r < 0) {
                r = sd_bus_error_setf(error, SD_BUS_ERROR_MATCH_RULE_INVALID, "Match rule \"%s\" is not valid", arg0);
                goto finish;
        }

        normalized = bus_match_to_string(components, n_components);
        if (!normalized) {
                r = -ENOMEM;
                goto finish;
        }

        m = hashmap_get(c->matches, normalized);
        if (!m) {
                r = sd_bus_error_setf(error, SD_BUS_ERROR_MATCH_RULE_NOT_FOUND, "Match rule \"%s\" not found.", normalized);
                goto finish;
        }

        bus_remove_match_internal_kernel(bus, id, m->cookie);
        match_free(m);

        r = sd_bus_reply_method_return(message, NULL);

finish:
        bus_match_parse_free(components, n_components);

        if (c->n_matches <= 0)
                client_free(c);

        return r;
}
开发者ID:jaanek,项目名称:systemd,代码行数:59,代码来源:bus-driverd.c


示例18: lvmnotify_send

void lvmnotify_send(struct cmd_context *cmd)
{
	static const char _dbus_notification_failed_msg[] = "D-Bus notification failed";
	sd_bus *bus = NULL;
	sd_bus_message *m = NULL;
	sd_bus_error error = SD_BUS_ERROR_NULL;
	const char *cmd_name;
	int ret;
	int result = 0;

	if (!cmd->vg_notify && !cmd->lv_notify && !cmd->pv_notify)
		return;

	cmd->vg_notify = 0;
	cmd->lv_notify = 0;
	cmd->pv_notify = 0;

	cmd_name = get_cmd_name();

	ret = sd_bus_open_system(&bus);
	if (ret < 0) {
		log_debug_dbus("Failed to connect to dbus: %d", ret);
		return;
	}

	log_debug_dbus("Nofify dbus at %s.", LVM_DBUS_DESTINATION);

	ret = sd_bus_call_method(bus,
				 LVM_DBUS_DESTINATION,
				 LVM_DBUS_PATH,
				 LVM_DBUS_INTERFACE,
				 "ExternalEvent",
				 &error,
				 &m,
				 "s",
				 cmd_name);

	if (ret < 0) {
		if (sd_bus_error_has_name(&error, SD_BUS_SYSTEMD_NO_SUCH_UNIT_ERROR) ||
		    sd_bus_error_has_name(&error, SD_BUS_DBUS_SERVICE_UNKNOWN_ERROR))
			log_debug_dbus("%s: %s", _dbus_notification_failed_msg, error.message);
		else
			log_warn("WARNING: %s: %s", _dbus_notification_failed_msg, error.message);
		goto out;
	}

	ret = sd_bus_message_read(m, "i", &result);
	if (ret < 0)
		log_debug_dbus("Failed to parse dbus response message: %d", ret);
	if (result)
		log_debug_dbus("Bad return value from dbus service: %d", result);
out:
	sd_bus_error_free(&error);
	sd_bus_message_unref(m);
	sd_bus_flush_close_unref(bus);
}
开发者ID:jthornber,项目名称:lvm2-ejt,代码行数:56,代码来源:lvmnotify.c


示例19: handle_ipmi_command

static int handle_ipmi_command(sd_bus_message *m, void *user_data, sd_bus_error
                         *ret_error) {
    int r = 0;
    const char *msg = NULL;
    char sequence, netfn, cmd;
    const void *request;
    size_t sz;
    size_t resplen =MAX_IPMI_BUFFER;
    unsigned char response[MAX_IPMI_BUFFER];

    printf(" *** Received Signal: ");

    memset(response, 0, MAX_IPMI_BUFFER);

    r = sd_bus_message_read(m, "yyy",  &sequence, &netfn, &cmd);
    if (r < 0) {
        fprintf(stderr, "Failed to parse signal message: %s\n", strerror(-r));
        return -1;
    }

    r = sd_bus_message_read_array(m, 'y',  &request, &sz );
    if (r < 0) {
        fprintf(stderr, "Failed to parse signal message: %s\n", strerror(-r));
        return -1;
    }


    printf("Seq 0x%02x, NetFn 0x%02x, CMD: 0x%02x \n", sequence, netfn, cmd);
    hexdump((void*)request, sz);

    // Allow the length field to be used for both input and output of the 
    // ipmi call
    resplen = sz;

    // Now that we have parsed the entire byte array from the caller 
    // we can call the ipmi router to do the work...
    r = ipmi_netfn_router(netfn, cmd, (void *)request, (void *)response, &resplen);
    if(r != 0)
    {
        fprintf(stderr,"ERROR:[0x%X] handling NetFn:[0x%X], Cmd:[0x%X]\n",r, netfn, cmd);
    }

    printf("Response...\n");
    hexdump((void*)response, resplen);

    // Send the response buffer from the ipmi command
    r = send_ipmi_message(sequence, netfn, cmd, response, resplen);
    if (r < 0) {
        fprintf(stderr, "Failed to send the response message\n");
        return -1;
    }


    return 0;
}
开发者ID:williamspatrick,项目名称:phosphor-host-ipmid,代码行数:55,代码来源:ipmid.C


示例20: map_ntp_message

static int map_ntp_message(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
        NTPStatusInfo *p = userdata;
        const void *d;
        size_t sz;
        int32_t b;
        int r;

        assert(p);

        r = sd_bus_message_enter_container(m, 'r', "uuuuittayttttbtt");
        if (r < 0)
                return r;

        r = sd_bus_message_read(m, "uuuuitt",
                                &p->leap, &p->version, &p->mode, &p->stratum, &p->precision,
                                &p->root_delay, &p->root_dispersion);
        if (r < 0)
                return r;

        r = sd_bus_message_read_array(m, 'y', &d, &sz);
        if (r < 0)
                return r;

        r = sd_bus_message_read(m, "ttttbtt",
                                &p->origin, &p->recv, &p->trans, &p->dest,
                                &b, &p->packet_count, &p->jitter);
        if (r < 0)
                return r;

        r = sd_bus_message_exit_container(m);
        if (r < 0)
                return r;

        if (sz != 4)
                return -EINVAL;

        memcpy(p->reference.str, d, sz);

        p->spike = b;

        return 0;
}
开发者ID:clemensg,项目名称:systemd,代码行数:42,代码来源:timedatectl.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sd_bus_reply_method_return函数代码示例发布时间:2022-05-30
下一篇:
C++ sd_bus_message_new_method_call函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap