Home | History | Annotate | Download | only in netfilter
      1 /*
      2  * lib/netfilter/netfilter.c    Netfilter Generic Functions
      3  *
      4  *	This library is free software; you can redistribute it and/or
      5  *	modify it under the terms of the GNU Lesser General Public
      6  *	License as published by the Free Software Foundation version 2.1
      7  *	of the License.
      8  *
      9  * Copyright (c) 2008 Patrick McHardy <kaber (at) trash.net>
     10  */
     11 
     12 #include <netlink-local.h>
     13 #include <netlink/netfilter/netfilter.h>
     14 #include <linux/netfilter.h>
     15 
     16 static struct trans_tbl nfnl_verdicts[] = {
     17 	__ADD(NF_DROP,		NF_DROP)
     18 	__ADD(NF_ACCEPT,	NF_ACCEPT)
     19 	__ADD(NF_STOLEN,	NF_STOLEN)
     20 	__ADD(NF_QUEUE,		NF_QUEUE)
     21 	__ADD(NF_REPEAT,	NF_REPEAT)
     22 	__ADD(NF_STOP,		NF_STOP)
     23 };
     24 
     25 char *nfnl_verdict2str(unsigned int verdict, char *buf, size_t len)
     26 {
     27 	return __type2str(verdict, buf, len, nfnl_verdicts,
     28 			  ARRAY_SIZE(nfnl_verdicts));
     29 }
     30 
     31 unsigned int nfnl_str2verdict(const char *name)
     32 {
     33 	return __str2type(name, nfnl_verdicts, ARRAY_SIZE(nfnl_verdicts));
     34 }
     35 
     36 static struct trans_tbl nfnl_inet_hooks[] = {
     37 	__ADD(NF_INET_PRE_ROUTING,	NF_INET_PREROUTING)
     38 	__ADD(NF_INET_LOCAL_IN,		NF_INET_LOCAL_IN)
     39 	__ADD(NF_INET_FORWARD,		NF_INET_FORWARD)
     40 	__ADD(NF_INET_LOCAL_OUT,	NF_INET_LOCAL_OUT)
     41 	__ADD(NF_INET_POST_ROUTING,	NF_INET_POST_ROUTING)
     42 };
     43 
     44 char *nfnl_inet_hook2str(unsigned int hook, char *buf, size_t len)
     45 {
     46 	return __type2str(hook, buf, len, nfnl_inet_hooks,
     47 			  ARRAY_SIZE(nfnl_inet_hooks));
     48 }
     49 
     50 unsigned int nfnl_str2inet_hook(const char *name)
     51 {
     52 	return __str2type(name, nfnl_inet_hooks, ARRAY_SIZE(nfnl_inet_hooks));
     53 }
     54