Home | History | Annotate | Line # | Download | only in npfctl
npf_var.h revision 1.11
      1   1.1     rmind /*-
      2   1.1     rmind  * Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
      3   1.1     rmind  * All rights reserved.
      4   1.1     rmind  *
      5   1.1     rmind  * This code is derived from software contributed to The NetBSD Foundation
      6   1.1     rmind  * by Christos Zoulas.
      7   1.1     rmind  *
      8   1.1     rmind  * Redistribution and use in source and binary forms, with or without
      9   1.1     rmind  * modification, are permitted provided that the following conditions
     10   1.1     rmind  * are met:
     11   1.1     rmind  * 1. Redistributions of source code must retain the above copyright
     12   1.1     rmind  *    notice, this list of conditions and the following disclaimer.
     13   1.1     rmind  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1     rmind  *    notice, this list of conditions and the following disclaimer in the
     15   1.1     rmind  *    documentation and/or other materials provided with the distribution.
     16   1.1     rmind  *
     17   1.1     rmind  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     18   1.1     rmind  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19   1.1     rmind  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20   1.1     rmind  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     21   1.1     rmind  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22   1.1     rmind  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23   1.1     rmind  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24   1.1     rmind  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25   1.1     rmind  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26   1.1     rmind  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27   1.1     rmind  * POSSIBILITY OF SUCH DAMAGE.
     28   1.1     rmind  */
     29   1.1     rmind 
     30   1.1     rmind #ifndef _NPF_VAR_H_
     31   1.1     rmind #define _NPF_VAR_H_
     32   1.1     rmind 
     33   1.1     rmind #define	NPFVAR_STRING		0
     34   1.1     rmind #define	NPFVAR_IDENTIFIER	1
     35   1.1     rmind #define	NPFVAR_VAR_ID		2
     36   1.4     rmind #define	NPFVAR_NUM		3
     37   1.4     rmind #define	NPFVAR_PORT_RANGE	4
     38   1.1     rmind 
     39   1.1     rmind /* Note: primitive types are equivalent. */
     40   1.4     rmind #define	NPFVAR_PRIM		NPFVAR_PORT_RANGE
     41   1.4     rmind #define	NPFVAR_TYPE(x)		(((x) > NPFVAR_PRIM) ? (x) : 0)
     42   1.1     rmind 
     43   1.2  christos #define	NPFVAR_TABLE		5
     44   1.2  christos #define	NPFVAR_FAM		6
     45   1.4     rmind #define	NPFVAR_PROC		7
     46   1.4     rmind #define	NPFVAR_PROC_PARAM	8
     47   1.4     rmind #define	NPFVAR_TCPFLAG		9
     48   1.4     rmind #define	NPFVAR_ICMP		10
     49   1.7     rmind #define	NPFVAR_INTERFACE	11
     50  1.10     rmind #define	NPFVAR_PROTO		12
     51   1.1     rmind 
     52   1.1     rmind #ifdef _NPFVAR_PRIVATE
     53   1.1     rmind static const char *npfvar_types[ ] = {
     54   1.4     rmind 	[NPFVAR_STRING]		= "string",
     55   1.4     rmind 	[NPFVAR_IDENTIFIER]	= "identifier",
     56   1.5     rmind 	[NPFVAR_VAR_ID]		= "variable-id",
     57   1.5     rmind 	[NPFVAR_NUM]		= "number",
     58   1.4     rmind 	[NPFVAR_PORT_RANGE]	= "port-range",
     59   1.4     rmind 	[NPFVAR_TABLE]		= "table",
     60   1.5     rmind 	[NPFVAR_FAM]		= "family-address-mask",
     61   1.5     rmind 	[NPFVAR_PROC]		= "procedure",
     62   1.5     rmind 	[NPFVAR_PROC_PARAM]	= "procedure-parameter",
     63   1.5     rmind 	[NPFVAR_TCPFLAG]	= "tcp-flag",
     64   1.4     rmind 	[NPFVAR_ICMP]		= "icmp",
     65  1.10     rmind 	[NPFVAR_INTERFACE]	= "interface-address",
     66  1.10     rmind 	[NPFVAR_PROTO]		= "proto",
     67   1.1     rmind };
     68   1.1     rmind #endif
     69   1.1     rmind 
     70   1.1     rmind struct npfvar;
     71   1.1     rmind typedef struct npfvar npfvar_t;
     72  1.11       joe typedef int (*rid_parser)(const char *, uint32_t *);
     73   1.1     rmind 
     74   1.8     rmind npfvar_t *	npfvar_create(void);
     75  1.10     rmind npfvar_t *	npfvar_create_element(unsigned, const void *, size_t);
     76  1.10     rmind npfvar_t *	npfvar_create_from_string(unsigned, const char *);
     77   1.1     rmind npfvar_t *	npfvar_lookup(const char *);
     78   1.1     rmind const char *	npfvar_type(size_t);
     79   1.8     rmind void		npfvar_add(npfvar_t *, const char *);
     80  1.10     rmind npfvar_t *	npfvar_add_element(npfvar_t *, unsigned, const void *, size_t);
     81   1.1     rmind npfvar_t *	npfvar_add_elements(npfvar_t *, npfvar_t *);
     82   1.1     rmind void		npfvar_destroy(npfvar_t *);
     83   1.1     rmind 
     84   1.1     rmind char *		npfvar_expand_string(const npfvar_t *);
     85   1.1     rmind size_t		npfvar_get_count(const npfvar_t *);
     86  1.11       joe uint32_t	npfvar_expand_number(const npfvar_t *);
     87   1.2  christos int		npfvar_get_type(const npfvar_t *, size_t);
     88  1.10     rmind void *		npfvar_get_data(const npfvar_t *, unsigned, size_t);
     89  1.11       joe void		npf_var_rid(char *, rid_parser, uint32_t *, const char *);
     90   1.1     rmind 
     91   1.1     rmind #endif
     92