xref: /freebsd/usr.sbin/ppp/iplist.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1c39934eaSBrian Somers /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
31de7b4b8SPedro F. Giffuni  *
4c39934eaSBrian Somers  * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
5c39934eaSBrian Somers  * All rights reserved.
6c39934eaSBrian Somers  *
7c39934eaSBrian Somers  * Redistribution and use in source and binary forms, with or without
8c39934eaSBrian Somers  * modification, are permitted provided that the following conditions
9c39934eaSBrian Somers  * are met:
10c39934eaSBrian Somers  * 1. Redistributions of source code must retain the above copyright
11c39934eaSBrian Somers  *    notice, this list of conditions and the following disclaimer.
12c39934eaSBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
13c39934eaSBrian Somers  *    notice, this list of conditions and the following disclaimer in the
14c39934eaSBrian Somers  *    documentation and/or other materials provided with the distribution.
15c39934eaSBrian Somers  *
16c39934eaSBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17c39934eaSBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18c39934eaSBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19c39934eaSBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20c39934eaSBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21c39934eaSBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22c39934eaSBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23c39934eaSBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24c39934eaSBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25c39934eaSBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26c39934eaSBrian Somers  * SUCH DAMAGE.
27bcc332bdSBrian Somers  */
28bcc332bdSBrian Somers 
29bcc332bdSBrian Somers struct iplist_cur {
30bcc332bdSBrian Somers   struct in_addr ip;
31bcc332bdSBrian Somers   int pos;
32bcc332bdSBrian Somers   char *srcptr;
333a2e4f62SBrian Somers   u_long srcitem;
343a2e4f62SBrian Somers   u_int32_t lstart;
353a2e4f62SBrian Somers   u_long nItems;
363a2e4f62SBrian Somers };
373a2e4f62SBrian Somers 
383a2e4f62SBrian Somers struct iplist {
393a2e4f62SBrian Somers   struct iplist_cur cur;
403a2e4f62SBrian Somers   u_long nItems;
41bcc332bdSBrian Somers   char src[LINE_LEN];
42bcc332bdSBrian Somers };
43bcc332bdSBrian Somers 
44bcc332bdSBrian Somers extern int iplist_setsrc(struct iplist *, const char *);
45bcc332bdSBrian Somers extern void iplist_reset(struct iplist *);
463a2e4f62SBrian Somers extern struct in_addr iplist_setcurpos(struct iplist *, long);
47bcc332bdSBrian Somers extern struct in_addr iplist_setrandpos(struct iplist *);
48bcc332bdSBrian Somers extern int iplist_ip2pos(struct iplist *, struct in_addr);
49bcc332bdSBrian Somers extern struct in_addr iplist_next(struct iplist *);
50bcc332bdSBrian Somers 
51bcc332bdSBrian Somers #define iplist_isvalid(x) ((x)->src[0] != '\0')
52