pfctl_radix.c (3c7fbb06a0d440aaeca539be76054a9265f89e40) pfctl_radix.c (4823489ab61dbaef4405cf03d2a48e77e593ce9c)
1/* $OpenBSD: pfctl_radix.c,v 1.27 2005/05/21 21:03:58 henning Exp $ */
2
3/*-
4 * SPDX-License-Identifier: BSD-2-Clause
5 *
6 * Copyright (c) 2002 Cedric Berger
7 * All rights reserved.
8 *

--- 197 unchanged lines hidden (view full) ---

206 *ndel = io.pfrio_ndel;
207 return (0);
208}
209
210int
211pfr_add_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
212 int *nadd, int flags)
213{
1/* $OpenBSD: pfctl_radix.c,v 1.27 2005/05/21 21:03:58 henning Exp $ */
2
3/*-
4 * SPDX-License-Identifier: BSD-2-Clause
5 *
6 * Copyright (c) 2002 Cedric Berger
7 * All rights reserved.
8 *

--- 197 unchanged lines hidden (view full) ---

206 *ndel = io.pfrio_ndel;
207 return (0);
208}
209
210int
211pfr_add_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
212 int *nadd, int flags)
213{
214 struct pfioc_table io;
214 int ret;
215
215
216 if (tbl == NULL || size < 0 || (size && addr == NULL)) {
217 errno = EINVAL;
216 ret = pfctl_table_add_addrs(dev, tbl, addr, size, nadd, flags);
217 if (ret) {
218 errno = ret;
218 return (-1);
219 }
219 return (-1);
220 }
220 bzero(&io, sizeof io);
221 io.pfrio_flags = flags;
222 io.pfrio_table = *tbl;
223 io.pfrio_buffer = addr;
224 io.pfrio_esize = sizeof(*addr);
225 io.pfrio_size = size;
226 if (ioctl(dev, DIOCRADDADDRS, &io)) {
227 pfr_report_error(tbl, &io, "add addresses in");
228 return (-1);
229 }
230 if (nadd != NULL)
231 *nadd = io.pfrio_nadd;
232 return (0);
233}
234
235int
236pfr_del_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
237 int *ndel, int flags)
238{
221 return (0);
222}
223
224int
225pfr_del_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
226 int *ndel, int flags)
227{
239 struct pfioc_table io;
228 int ret;
240
229
241 if (tbl == NULL || size < 0 || (size && addr == NULL)) {
242 errno = EINVAL;
230 ret = pfctl_table_del_addrs(dev, tbl, addr, size, ndel, flags);
231 if (ret) {
232 errno = ret;
243 return (-1);
244 }
233 return (-1);
234 }
245 bzero(&io, sizeof io);
246 io.pfrio_flags = flags;
247 io.pfrio_table = *tbl;
248 io.pfrio_buffer = addr;
249 io.pfrio_esize = sizeof(*addr);
250 io.pfrio_size = size;
251 if (ioctl(dev, DIOCRDELADDRS, &io)) {
252 pfr_report_error(tbl, &io, "delete addresses in");
253 return (-1);
254 }
255 if (ndel != NULL)
256 *ndel = io.pfrio_ndel;
257 return (0);
258}
259
260int
261pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
262 int *size2, int *nadd, int *ndel, int *nchange, int flags)
263{
235 return (0);
236}
237
238int
239pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
240 int *size2, int *nadd, int *ndel, int *nchange, int flags)
241{
264 struct pfioc_table io;
242 int ret;
265
243
266 if (tbl == NULL || size < 0 || (size && addr == NULL)) {
267 errno = EINVAL;
244 ret = pfctl_table_set_addrs(dev, tbl, addr, size, size2, nadd, ndel,
245 nchange, flags);
246 if (ret) {
247 errno = ret;
268 return (-1);
269 }
248 return (-1);
249 }
270 bzero(&io, sizeof io);
271 io.pfrio_flags = flags;
272 io.pfrio_table = *tbl;
273 io.pfrio_buffer = addr;
274 io.pfrio_esize = sizeof(*addr);
275 io.pfrio_size = size;
276 io.pfrio_size2 = (size2 != NULL) ? *size2 : 0;
277 if (ioctl(dev, DIOCRSETADDRS, &io)) {
278 pfr_report_error(tbl, &io, "set addresses in");
279 return (-1);
280 }
281 if (nadd != NULL)
282 *nadd = io.pfrio_nadd;
283 if (ndel != NULL)
284 *ndel = io.pfrio_ndel;
285 if (nchange != NULL)
286 *nchange = io.pfrio_nchange;
287 if (size2 != NULL)
288 *size2 = io.pfrio_size2;
289 return (0);
290}
291
292int
293pfr_get_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int *size,
294 int flags)
295{
250 return (0);
251}
252
253int
254pfr_get_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int *size,
255 int flags)
256{
296 struct pfioc_table io;
257 int ret;
297
258
298 if (tbl == NULL || size == NULL || *size < 0 ||
299 (*size && addr == NULL)) {
300 errno = EINVAL;
259 ret = pfctl_table_get_addrs(dev, tbl, addr, size, flags);
260 if (ret) {
261 errno = ret;
301 return (-1);
302 }
262 return (-1);
263 }
303 bzero(&io, sizeof io);
304 io.pfrio_flags = flags;
305 io.pfrio_table = *tbl;
306 io.pfrio_buffer = addr;
307 io.pfrio_esize = sizeof(*addr);
308 io.pfrio_size = *size;
309 if (ioctl(dev, DIOCRGETADDRS, &io)) {
310 pfr_report_error(tbl, &io, "get addresses from");
311 return (-1);
312 }
313 *size = io.pfrio_size;
314 return (0);
315}
316
317int
318pfr_get_astats(struct pfr_table *tbl, struct pfr_astats *addr, int *size,
319 int flags)
320{
321 struct pfioc_table io;

--- 307 unchanged lines hidden ---
264 return (0);
265}
266
267int
268pfr_get_astats(struct pfr_table *tbl, struct pfr_astats *addr, int *size,
269 int flags)
270{
271 struct pfioc_table io;

--- 307 unchanged lines hidden ---