#include #define WITH_CASPER 1 #include #include #include #include #include int val; cap_channel_t *cap_config; void *mem; int main(void) { val = 1024; mem = malloc(1024); cap_channel_t *cap_casper = cap_init(); if (cap_casper == NULL) err(1, "failed to contact casper"); cap_config = cap_service_open(cap_casper, "casper.test"); if (cap_config == NULL) err(1, "failed to open test service"); cap_close(cap_casper); nvlist_t *nvl = nvlist_create(0); nvlist_add_string(nvl, "cmd", "print"); printf("parent cap_config: %p\n", cap_config); printf("parent val: %d\n", val); printf("parent mem: %p\n", mem); if (cap_send_nvlist(cap_config, nvl) == -1) err(1, "send failed"); free(mem); nvlist_destroy(nvl); return (0); } static int cmd(const char *cmd, const nvlist_t *nvlim, nvlist_t *nvnew, nvlist_t *nvold) { if (strcmp(cmd, "print") == 0) { printf("casper cap_config: %p\n", cap_config); printf("casper val: %d\n", val); printf("casper mem: %p\n", mem); } return (0); } CREATE_SERVICE("casper.test", NULL, cmd, CASPER_SERVICE_STDIO);