xref: /freebsd/sbin/ipf/libipf/optvalue.c (revision 2a63c3be158216222d89a073dcbd6a72ee4aab5a)
141edb306SCy Schubert 
241edb306SCy Schubert /*
341edb306SCy Schubert  * Copyright (C) 2012 by Darren Reed.
441edb306SCy Schubert  *
541edb306SCy Schubert  * See the IPFILTER.LICENCE file for details on licencing.
641edb306SCy Schubert  *
741edb306SCy Schubert  * $Id$
841edb306SCy Schubert  */
941edb306SCy Schubert #include "ipf.h"
1041edb306SCy Schubert 
1141edb306SCy Schubert 
12efeb8bffSCy Schubert u_32_t
getoptbyname(char * optname)13efeb8bffSCy Schubert getoptbyname(char *optname)
1441edb306SCy Schubert {
1541edb306SCy Schubert 	struct ipopt_names *io;
1641edb306SCy Schubert 
1741edb306SCy Schubert 	for (io = ionames; io->on_name; io++)
1841edb306SCy Schubert 		if (!strcasecmp(optname, io->on_name))
19*2582ae57SCy Schubert 			return (io->on_bit);
20*2582ae57SCy Schubert 	return (-1);
2141edb306SCy Schubert }
2241edb306SCy Schubert 
2341edb306SCy Schubert 
24efeb8bffSCy Schubert u_32_t
getoptbyvalue(int optval)25efeb8bffSCy Schubert getoptbyvalue(int optval)
2641edb306SCy Schubert {
2741edb306SCy Schubert 	struct ipopt_names *io;
2841edb306SCy Schubert 
2941edb306SCy Schubert 	for (io = ionames; io->on_name; io++)
3041edb306SCy Schubert 		if (io->on_value == optval)
31*2582ae57SCy Schubert 			return (io->on_bit);
32*2582ae57SCy Schubert 	return (-1);
3341edb306SCy Schubert }
34