int eam_display(bool csv_format) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; union request_eamt *payload = (union request_eamt *) (request + HDR_LEN); struct display_params params; int error; init_request_hdr(hdr, sizeof(request), MODE_EAMT, OP_DISPLAY); payload->display.prefix4_set = false; memset(&payload->display.prefix4, 0, sizeof(payload->display.prefix4)); params.csv_format = csv_format; params.row_count = 0; params.req_payload = payload; if (csv_format) printf("IPv6 Prefix,IPv4 Prefix\n"); do { error = netlink_request(request, hdr->length, eam_display_response, ¶ms); } while (!error && payload->display.prefix4_set); if (!csv_format && !error) { if (params.row_count > 0) printf(" (Fetched %u entries.)\n", params.row_count); else printf(" (empty)\n"); } return error; }
int pool4_display(enum config_mode mode) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; union request_pool4 *payload = (union request_pool4 *) (request + HDR_LEN); struct display_args args; int error; init_request_hdr(hdr, sizeof(request), mode, OP_DISPLAY); payload->display.prefix_set = false; memset(&payload->display.prefix, 0, sizeof(payload->display.prefix)); args.row_count = 0; args.request = payload; do { error = netlink_request(&request, hdr->length, pool4_display_response, &args); } while (!error && args.request->display.prefix_set); if (!error) { if (args.row_count > 0) log_info(" (Fetched %u prefixes.)", args.row_count); else log_info(" (empty)"); } return error; }
static bool display_single_db(l3_protocol l3_proto, l4_protocol l4_proto) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; struct request_logtime *payload = (struct request_logtime *) (request + HDR_LEN); struct display_params params; bool error; init_request_hdr(hdr, sizeof(request), MODE_LOGTIME, OP_DISPLAY); payload->l3_proto = (__u8) l3_proto; payload->l4_proto = (__u8) l4_proto; payload->display.iterate = false; params.row_count = 0; params.req_payload = payload; do { error = netlink_request(request, hdr->length, logtime_display_response, ¶ms); if (error) break; } while (params.req_payload->display.iterate); if (!error) { if (params.row_count > 0) printf(" (Fetched %u entries.)\n", params.row_count); else printf(" (empty)\n"); } return error; }
int eam_test(bool addr6_set, struct in6_addr *addr6, bool addr4_set, struct in_addr *addr4) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; union request_eamt *payload = (union request_eamt *) (request + HDR_LEN); init_request_hdr(hdr, sizeof(request), MODE_EAMT, OP_TEST); if (addr4_set && addr6_set) { log_err("You gave me too many addresses."); return -EINVAL; } else if (addr6_set) { payload->test.addr_is_ipv6 = true; payload->test.addr.addr6 = *addr6; } else if (addr4_set) { payload->test.addr_is_ipv6 = false; payload->test.addr.addr4 = *addr4; } else { log_err("I need an IP address as argument."); return -EINVAL; } return netlink_request(request, hdr->length, eam_test_response, &payload->test.addr_is_ipv6); }
int joold_advertise(char *iname) { int error = 0; struct request_hdr request; init_request_hdr(&request, MODE_JOOLD, OP_ADVERTISE, false); error = netlink_request(iname, &request, sizeof(request), NULL, NULL); return error; }
int joold_advertise(void) { int error = 0; struct request_hdr request; init_request_hdr(&request, MODE_JOOLD, OP_ADVERTISE); error = netlink_request(&request, sizeof(request), NULL, NULL); return error; }
int pool4_add(enum config_mode mode, struct ipv4_prefix *addrs) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; union request_pool4 *payload = (union request_pool4 *) (request + HDR_LEN); init_request_hdr(hdr, sizeof(request), mode, OP_ADD); payload->add.addrs = *addrs; return netlink_request(request, hdr->length, pool4_add_response, NULL); }
int pool4_flush(enum config_mode mode, bool quick) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; union request_pool4 *payload = (union request_pool4 *) (request + HDR_LEN); init_request_hdr(hdr, sizeof(request), mode, OP_FLUSH); payload->flush.quick = quick; return netlink_request(&request, hdr->length, pool4_flush_response, NULL); }
int pool4_remove(enum config_mode mode, struct ipv4_prefix *addrs, bool quick) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; union request_pool4 *payload = (union request_pool4 *) (request + HDR_LEN); init_request_hdr(hdr, sizeof(request), mode, OP_REMOVE); payload->remove.addrs = *addrs; payload->remove.quick = quick; return netlink_request(request, hdr->length, pool4_remove_response, NULL); }
int eam_add(struct ipv6_prefix *prefix6, struct ipv4_prefix *prefix4, bool force) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; union request_eamt *payload = (union request_eamt *) (request + HDR_LEN); init_request_hdr(hdr, sizeof(request), MODE_EAMT, OP_ADD); payload->add.prefix4 = *prefix4; payload->add.prefix6 = *prefix6; payload->add.force = force; return netlink_request(request, hdr->length, NULL, NULL); }
static bool display_single_count(char *count_name, u_int8_t l4_proto) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; struct request_session *payload = (struct request_session *) (request + HDR_LEN); printf("%s: ", count_name); init_request_hdr(hdr, sizeof(request), MODE_SESSION, OP_COUNT); payload->l4_proto = l4_proto; return netlink_request(request, hdr->length, session_count_response, NULL); }
int eam_remove(bool pref6_set, struct ipv6_prefix *prefix6, bool pref4_set, struct ipv4_prefix *prefix4) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; union request_eamt *payload = (union request_eamt *) (request + HDR_LEN); init_request_hdr(hdr, sizeof(request), MODE_EAMT, OP_REMOVE); payload->rm.prefix4_set = pref4_set; payload->rm.prefix4 = *prefix4; payload->rm.prefix6_set = pref6_set; payload->rm.prefix6 = *prefix6; return netlink_request(request, hdr->length, NULL, NULL); }
int stats_foreach(char *iname, stats_foreach_cb cb, void *args) { struct query_args qargs; struct request_hdr request; int error; error = validate_stats(); if (error) return error; qargs.cb = cb; qargs.args = args; init_request_hdr(&request, MODE_STATS, OP_FOREACH, false); return netlink_request(iname, &request, sizeof(request), stats_query_response, &qargs); }
static int init_buffer(struct nl_buffer *buffer, enum parse_section section) { struct request_hdr hdr; __u16 tmp = section; int error; init_request_hdr(&hdr, MODE_PARSE_FILE, OP_ADD); error = nlbuffer_write(buffer, &hdr, sizeof(hdr)); if (error) { log_err("Writing on an empty buffer yielded error %d.", error); return error; } error = nlbuffer_write(buffer, &tmp, sizeof(tmp)); if (error) log_err("Writing on an empty buffer yielded error %d.", error); return error; }
static bool display_single_table(u_int8_t l4_proto, bool numeric_hostname, bool csv_format) { unsigned char request[HDR_LEN + PAYLOAD_LEN]; struct request_hdr *hdr = (struct request_hdr *) request; struct request_session *payload = (struct request_session *) (request + HDR_LEN); struct display_params params; bool error; if (!csv_format) { printf("%s:\n", l4proto_to_string(l4_proto)); printf("---------------------------------\n"); } init_request_hdr(hdr, sizeof(request), MODE_SESSION, OP_DISPLAY); payload->l4_proto = l4_proto; payload->display.connection_set = false; memset(&payload->display.remote4, 0, sizeof(payload->display.remote4)); memset(&payload->display.local4, 0, sizeof(payload->display.local4)); params.numeric_hostname = numeric_hostname; params.csv_format = csv_format; params.row_count = 0; params.req_payload = payload; do { error = netlink_request(request, hdr->length, session_display_response, ¶ms); } while (!error && params.req_payload->display.connection_set); if (!csv_format && !error) { if (params.row_count > 0) log_info(" (Fetched %u entries.)\n", params.row_count); else log_info(" (empty)\n"); } return error; }
int pool4_count(enum config_mode mode) { struct request_hdr request; init_request_hdr(&request, sizeof(request), mode, OP_COUNT); return netlink_request(&request, request.length, pool4_count_response, NULL); }
int eam_flush(void) { struct request_hdr request; init_request_hdr(&request, sizeof(request), MODE_EAMT, OP_FLUSH); return netlink_request(&request, request.length, NULL, NULL); }
int joold_test(char *iname) { struct request_hdr hdr; init_request_hdr(&hdr, MODE_JOOLD, OP_TEST, false); return netlink_request(iname, &hdr, sizeof(hdr), NULL, NULL); }
int eam_count(void) { struct request_hdr request; init_request_hdr(&request, sizeof(request), MODE_EAMT, OP_COUNT); return netlink_request(&request, request.length, eam_count_response, NULL); }
int joold_test(void) { struct request_hdr hdr; init_request_hdr(&hdr, MODE_JOOLD, OP_TEST); return netlink_request(&hdr, sizeof(hdr), NULL, NULL); }