* do_get3 - pass ipfw control cmd to kernel * @optname: option name * @optval: pointer to option data * @optlen: pointer to option length * * Assumes op3 header is already embedded. * Calls getsockopt() with IP_FW3 as kernel-visible opcode. * Returns 0 on success or errno otherwise. */
| 646 | * Returns 0 on success or errno otherwise. |
| 647 | */ |
| 648 | int |
| 649 | do_get3(int optname, ip_fw3_opheader *op3, size_t *optlen) |
| 650 | { |
| 651 | int error; |
| 652 | socklen_t len; |
| 653 | |
| 654 | if (g_co.test_only) |
| 655 | return (0); |
| 656 | |
| 657 | if (ipfw_socket == -1) |
| 658 | ipfw_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); |
| 659 | if (ipfw_socket < 0) |
| 660 | err(EX_UNAVAILABLE, "socket"); |
| 661 | |
| 662 | op3->opcode = optname; |
| 663 | |
| 664 | len = *optlen; |
| 665 | error = getsockopt(ipfw_socket, IPPROTO_IP, IP_FW3, op3, &len); |
| 666 | *optlen = len; |
| 667 | |
| 668 | return (error); |
| 669 | } |
| 670 | |
| 671 | /** |
| 672 | * match_token takes a table and a string, returns the value associated |
no test coverage detected