libnl
3.2.3
|
00001 /* 00002 * lib/netfilter/netfilter.c Netfilter Generic Functions 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation version 2.1 00007 * of the License. 00008 * 00009 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net> 00010 */ 00011 00012 #include <netlink-local.h> 00013 #include <netlink/netfilter/netfilter.h> 00014 #include <linux/netfilter.h> 00015 00016 static const struct trans_tbl nfnl_verdicts[] = { 00017 __ADD(NF_DROP, NF_DROP) 00018 __ADD(NF_ACCEPT, NF_ACCEPT) 00019 __ADD(NF_STOLEN, NF_STOLEN) 00020 __ADD(NF_QUEUE, NF_QUEUE) 00021 __ADD(NF_REPEAT, NF_REPEAT) 00022 __ADD(NF_STOP, NF_STOP) 00023 }; 00024 00025 char *nfnl_verdict2str(unsigned int verdict, char *buf, size_t len) 00026 { 00027 return __type2str(verdict, buf, len, nfnl_verdicts, 00028 ARRAY_SIZE(nfnl_verdicts)); 00029 } 00030 00031 unsigned int nfnl_str2verdict(const char *name) 00032 { 00033 return __str2type(name, nfnl_verdicts, ARRAY_SIZE(nfnl_verdicts)); 00034 } 00035 00036 static const struct trans_tbl nfnl_inet_hooks[] = { 00037 __ADD(NF_INET_PRE_ROUTING, NF_INET_PREROUTING) 00038 __ADD(NF_INET_LOCAL_IN, NF_INET_LOCAL_IN) 00039 __ADD(NF_INET_FORWARD, NF_INET_FORWARD) 00040 __ADD(NF_INET_LOCAL_OUT, NF_INET_LOCAL_OUT) 00041 __ADD(NF_INET_POST_ROUTING, NF_INET_POST_ROUTING) 00042 }; 00043 00044 char *nfnl_inet_hook2str(unsigned int hook, char *buf, size_t len) 00045 { 00046 return __type2str(hook, buf, len, nfnl_inet_hooks, 00047 ARRAY_SIZE(nfnl_inet_hooks)); 00048 } 00049 00050 unsigned int nfnl_str2inet_hook(const char *name) 00051 { 00052 return __str2type(name, nfnl_inet_hooks, ARRAY_SIZE(nfnl_inet_hooks)); 00053 }