libpfctl.c (c4a08ef2af6fe0b0d1b03f7ec4f20bed96de20e8) | libpfctl.c (4823489ab61dbaef4405cf03d2a48e77e593ce9c) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2021 Rubicon Communications, LLC (Netgate) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 1446 unchanged lines hidden (view full) --- 1455 1456 s->highwater = nvlist_get_number(nvl, "highwater") * 100 / state_limit; 1457 s->lowwater = nvlist_get_number(nvl, "lowwater") * 100 / state_limit; 1458 1459 nvlist_destroy(nvl); 1460 1461 return (0); 1462} | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2021 Rubicon Communications, LLC (Netgate) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 1446 unchanged lines hidden (view full) --- 1455 1456 s->highwater = nvlist_get_number(nvl, "highwater") * 100 / state_limit; 1457 s->lowwater = nvlist_get_number(nvl, "lowwater") * 100 / state_limit; 1458 1459 nvlist_destroy(nvl); 1460 1461 return (0); 1462} |
1463 1464int 1465pfctl_table_add_addrs(int dev, struct pfr_table *tbl, struct pfr_addr 1466 *addr, int size, int *nadd, int flags) 1467{ 1468 struct pfioc_table io; 1469 1470 if (tbl == NULL || size < 0 || (size && addr == NULL)) { 1471 return (EINVAL); 1472 } 1473 bzero(&io, sizeof io); 1474 io.pfrio_flags = flags; 1475 io.pfrio_table = *tbl; 1476 io.pfrio_buffer = addr; 1477 io.pfrio_esize = sizeof(*addr); 1478 io.pfrio_size = size; 1479 1480 if (ioctl(dev, DIOCRADDADDRS, &io)) 1481 return (errno); 1482 if (nadd != NULL) 1483 *nadd = io.pfrio_nadd; 1484 return (0); 1485} 1486 1487int 1488pfctl_table_del_addrs(int dev, struct pfr_table *tbl, struct pfr_addr 1489 *addr, int size, int *ndel, int flags) 1490{ 1491 struct pfioc_table io; 1492 1493 if (tbl == NULL || size < 0 || (size && addr == NULL)) { 1494 return (EINVAL); 1495 } 1496 bzero(&io, sizeof io); 1497 io.pfrio_flags = flags; 1498 io.pfrio_table = *tbl; 1499 io.pfrio_buffer = addr; 1500 io.pfrio_esize = sizeof(*addr); 1501 io.pfrio_size = size; 1502 1503 if (ioctl(dev, DIOCRDELADDRS, &io)) 1504 return (errno); 1505 if (ndel != NULL) 1506 *ndel = io.pfrio_ndel; 1507 return (0); 1508} 1509 1510int 1511pfctl_table_set_addrs(int dev, struct pfr_table *tbl, struct pfr_addr 1512 *addr, int size, int *size2, int *nadd, int *ndel, int *nchange, int flags) 1513{ 1514 struct pfioc_table io; 1515 1516 if (tbl == NULL || size < 0 || (size && addr == NULL)) { 1517 return (EINVAL); 1518 } 1519 bzero(&io, sizeof io); 1520 io.pfrio_flags = flags; 1521 io.pfrio_table = *tbl; 1522 io.pfrio_buffer = addr; 1523 io.pfrio_esize = sizeof(*addr); 1524 io.pfrio_size = size; 1525 io.pfrio_size2 = (size2 != NULL) ? *size2 : 0; 1526 if (ioctl(dev, DIOCRSETADDRS, &io)) 1527 return (-1); 1528 if (nadd != NULL) 1529 *nadd = io.pfrio_nadd; 1530 if (ndel != NULL) 1531 *ndel = io.pfrio_ndel; 1532 if (nchange != NULL) 1533 *nchange = io.pfrio_nchange; 1534 if (size2 != NULL) 1535 *size2 = io.pfrio_size2; 1536 return (0); 1537} 1538 1539int pfctl_table_get_addrs(int dev, struct pfr_table *tbl, struct pfr_addr *addr, 1540 int *size, int flags) 1541{ 1542 struct pfioc_table io; 1543 1544 if (tbl == NULL || size == NULL || *size < 0 || 1545 (*size && addr == NULL)) { 1546 return (EINVAL); 1547 } 1548 bzero(&io, sizeof io); 1549 io.pfrio_flags = flags; 1550 io.pfrio_table = *tbl; 1551 io.pfrio_buffer = addr; 1552 io.pfrio_esize = sizeof(*addr); 1553 io.pfrio_size = *size; 1554 if (ioctl(dev, DIOCRGETADDRS, &io)) 1555 return (-1); 1556 *size = io.pfrio_size; 1557 return (0); 1558} |
|