MCPcopy Index your code
hub / github.com/F-Stack/f-stack / do_cmd

Function do_cmd

tools/ipfw/ipfw2.c:583–609  ·  view source on GitHub ↗

* conditionally runs the command. * Selected options or negative -> getsockopt */

Source from the content-addressed store, hash-verified

581 * Selected options or negative -> getsockopt
582 */
583int
584do_cmd(int optname, void *optval, uintptr_t optlen)
585{
586 int i;
587
588 if (g_co.test_only)
589 return 0;
590
591 if (ipfw_socket == -1)
592 ipfw_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
593 if (ipfw_socket < 0)
594 err(EX_UNAVAILABLE, "socket");
595
596 if (optname == IP_FW_GET || optname == IP_DUMMYNET_GET ||
597 optname == IP_FW_ADD || optname == IP_FW3 ||
598 optname == IP_FW_NAT_GET_CONFIG ||
599 optname < 0 ||
600 optname == IP_FW_NAT_GET_LOG) {
601 if (optname < 0)
602 optname = -optname;
603 i = getsockopt(ipfw_socket, IPPROTO_IP, optname, optval,
604 (socklen_t *)optlen);
605 } else {
606 i = setsockopt(ipfw_socket, IPPROTO_IP, optname, optval, optlen);
607 }
608 return i;
609}
610
611/*
612 * do_set3 - pass ipfw control cmd to kernel

Callers 5

get_extra_parmsFunction · 0.70
ipfw_delete_pipeFunction · 0.70
ipfw_config_pipeFunction · 0.70
dummynet_flushFunction · 0.70
dummynet_listFunction · 0.70

Calls 3

getsockoptFunction · 0.85
socketClass · 0.50
setsockoptFunction · 0.50

Tested by

no test coverage detected