err = send(s, nlh, size, 0); if (err == -1)
ulog("Failed to send: %s [%d].\n",
strerror(errno), errno);
return err;
}
staticvoid usage(void)
{
printf( "Usage: ucon [options] [output file]\n" "\n" "\t-h\tthis help screen\n" "\t-s\tsend buffers to the test module\n" "\n" "The default behavior of ucon is to subscribe to the test module\n" "and wait for state messages. Any ones received are dumped to the\n" "specified output file (or stdout). The test module is assumed to\n" "have an id of {%u.%u}\n" "\n" "If you get no output, then verify the cn_test module id matches\n" "the expected id above.\n"
, CN_TEST_IDX, CN_TEST_VAL
);
}
while ((s = getopt(argc, argv, "hs")) != -1) { switch (s) { case's':
send_msgs = true; break;
case'h':
usage(); return 0;
default: /* getopt() outputs an error for us */
usage(); return 1;
}
}
if (argc != optind) {
out = fopen(argv[optind], "a+"); if (!out) {
ulog("Unable to open %s for writing: %s\n",
argv[1], strerror(errno));
out = stdout;
}
} else
out = stdout;
memset(buf, 0, sizeof(buf));
s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); if (s == -1) {
perror("socket"); return -1;
}
l_local.nl_family = AF_NETLINK;
l_local.nl_groups = -1; /* bitmask of requested groups */
l_local.nl_pid = 0;
ulog("subscribing to %u.%u\n", CN_TEST_IDX, CN_TEST_VAL);
#if 0
{ int on = 0x57; /* Additional group number */
setsockopt(s, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &on, sizeof(on));
} #endif if (send_msgs) { int i, j;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.