Check-in [9a13922db2]
Overview
Comment:it compiles and links properly. I don't guarantee ANYTHING else. This is a very major change - I have removed dotconf and am replacing with libconfig. Also did some cleanup along with it. Some parts are messy. I hope it's functional.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9a13922db2c0751727556b9aa6f59598ef963c78
User & Date: rmiller on 2011-03-06 01:57:33
Other Links: manifest | tags
Context
2011-03-06
02:10
This fixes a few segfaults with an empty config file. It's, of course, *useless* with an empty config file, but that's for testing at a later time. check-in: 5396b2b79c user: rmiller tags: trunk
01:57
it compiles and links properly. I don't guarantee ANYTHING else. This is a very major change - I have removed dotconf and am replacing with libconfig. Also did some cleanup along with it. Some parts are messy. I hope it's functional. check-in: 9a13922db2 user: rmiller tags: trunk
2011-03-01
22:34
Move a bunch of includes to packetbl.h, and also fix what appears to be a small signing problem (THIS one doesn't break anything) check-in: 50168f46c0 user: rmiller tags: trunk
Changes

Modified autom4te.cache/output.0 from [cd3458412f] to [c36152d6d3].

3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
_ACEOF
 
fi

done


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pool_free in -lpool" >&5
$as_echo_n "checking for pool_free in -lpool... " >&6; }
if test "${ac_cv_lib_pool_pool_free+set}" = set; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lpool  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char pool_free ();
int
main ()
{
return pool_free ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_pool_pool_free=yes
else
  ac_cv_lib_pool_pool_free=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pool_pool_free" >&5
$as_echo "$ac_cv_lib_pool_pool_free" >&6; }
if test "x$ac_cv_lib_pool_pool_free" = x""yes; then :
  
	
$as_echo "@%:@define HAVE_POOL /**/" >>confdefs.h

	LIBS="$LIBS -lpool"

else
  
	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "You must have dotconf (libpool), find it here: http://www.azzit.de/dotconf/
See \`config.log' for more details" "$LINENO" 5; }

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dotconf_create in -ldotconf" >&5
$as_echo_n "checking for dotconf_create in -ldotconf... " >&6; }
if test "${ac_cv_lib_dotconf_dotconf_create+set}" = set; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldotconf  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char dotconf_create ();
int
main ()
{
return dotconf_create ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_dotconf_dotconf_create=yes
else
  ac_cv_lib_dotconf_dotconf_create=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dotconf_dotconf_create" >&5
$as_echo "$ac_cv_lib_dotconf_dotconf_create" >&6; }
if test "x$ac_cv_lib_dotconf_dotconf_create" = x""yes; then :
  
	
$as_echo "@%:@define HAVE_DOTCONF /**/" >>confdefs.h

	LIBS="$LIBS -ldotconf"

else
  
	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "You must have dotconf, find it here: http://www.azzit.de/dotconf/
See \`config.log' for more details" "$LINENO" 5; }

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nfq_set_verdict in -lnetfilter_queue" >&5
$as_echo_n "checking for nfq_set_verdict in -lnetfilter_queue... " >&6; }







|
|
|



|









|



|





|

|





|
|
|


|

|





<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|







3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927





















































3928
3929
3930
3931
3932
3933
3934
3935
_ACEOF
 
fi

done


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for config_init in -lconfig" >&5
$as_echo_n "checking for config_init in -lconfig... " >&6; }
if test "${ac_cv_lib_config_config_init+set}" = set; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lconfig  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char config_init ();
int
main ()
{
return config_init ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_config_config_init=yes
else
  ac_cv_lib_config_config_init=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_config_config_init" >&5
$as_echo "$ac_cv_lib_config_config_init" >&6; }
if test "x$ac_cv_lib_config_config_init" = x""yes; then :
  
	
$as_echo "@%:@define HAVE_LIBCONFIG /**/" >>confdefs.h

	LIBS="$LIBS -lconfig"

else
  
	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}





















































as_fn_error $? "You must have libconfig
See \`config.log' for more details" "$LINENO" 5; }

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nfq_set_verdict in -lnetfilter_queue" >&5
$as_echo_n "checking for nfq_set_verdict in -lnetfilter_queue... " >&6; }

Modified autom4te.cache/traces.0 from [af22284bcc] to [bad0bba9bc].

384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
@%:@undef HAVE_STRINGS_H])
m4trace:configure.in:47: -1- AH_OUTPUT([HAVE_INTTYPES_H], [/* Define to 1 if you have the <inttypes.h> header file. */
@%:@undef HAVE_INTTYPES_H])
m4trace:configure.in:47: -1- AH_OUTPUT([HAVE_STDINT_H], [/* Define to 1 if you have the <stdint.h> header file. */
@%:@undef HAVE_STDINT_H])
m4trace:configure.in:47: -1- AH_OUTPUT([HAVE_UNISTD_H], [/* Define to 1 if you have the <unistd.h> header file. */
@%:@undef HAVE_UNISTD_H])
m4trace:configure.in:49: -1- AC_DEFINE_TRACE_LITERAL([HAVE_POOL])
m4trace:configure.in:49: -1- m4_pattern_allow([^HAVE_POOL$])
m4trace:configure.in:49: -1- AH_OUTPUT([HAVE_POOL], [/* Enable if you have the required pool library */
@%:@undef HAVE_POOL])
m4trace:configure.in:56: -1- AC_DEFINE_TRACE_LITERAL([HAVE_DOTCONF])
m4trace:configure.in:56: -1- m4_pattern_allow([^HAVE_DOTCONF$])
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_DOTCONF], [/* Enable if you have the required dotconf library. */
@%:@undef HAVE_DOTCONF])
m4trace:configure.in:63: -1- AC_DEFINE_TRACE_LITERAL([HAVE_NFQUEUE])
m4trace:configure.in:63: -1- m4_pattern_allow([^HAVE_NFQUEUE$])
m4trace:configure.in:63: -1- AH_OUTPUT([HAVE_NFQUEUE], [/* Enable if you have nfqueue */
@%:@undef HAVE_NFQUEUE])
m4trace:configure.in:73: -1- AC_DEFINE_TRACE_LITERAL([HAVE_NFNETLINK])
m4trace:configure.in:73: -1- m4_pattern_allow([^HAVE_NFNETLINK$])
m4trace:configure.in:73: -1- AH_OUTPUT([HAVE_NFNETLINK], [/* Enable if netlink exists */
@%:@undef HAVE_NFNETLINK])
m4trace:configure.in:86: -1- AC_DEFINE_TRACE_LITERAL([HAVE_FIREDNS])
m4trace:configure.in:86: -1- m4_pattern_allow([^HAVE_FIREDNS$])
m4trace:configure.in:86: -1- AH_OUTPUT([HAVE_FIREDNS], [/* Enable if you have the optional firedns library */
@%:@undef HAVE_FIREDNS])
m4trace:configure.in:99: -1- AC_DEFINE_TRACE_LITERAL([USE_CACHE])
m4trace:configure.in:99: -1- m4_pattern_allow([^USE_CACHE$])
m4trace:configure.in:99: -1- AH_OUTPUT([USE_CACHE], [/* Enable if you want to use a caching mechanism. */
@%:@undef USE_CACHE])
m4trace:configure.in:104: -1- AC_CONFIG_FILES([Makefile])
m4trace:configure.in:105: -1- AC_CONFIG_HEADERS([config.h])
m4trace:configure.in:106: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([LIB@&t@OBJS])
m4trace:configure.in:106: -1- m4_pattern_allow([^LIB@&t@OBJS$])
m4trace:configure.in:106: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([LTLIBOBJS])
m4trace:configure.in:106: -1- m4_pattern_allow([^LTLIBOBJS$])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([top_builddir])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([top_build_prefix])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([srcdir])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([abs_srcdir])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([top_srcdir])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([abs_top_srcdir])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([builddir])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([abs_builddir])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([abs_top_builddir])
m4trace:configure.in:106: -1- AC_SUBST_TRACE([INSTALL])







|
|
|
|
|
|
<
<
<
<
|

|
|
|

|
|
|

|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384
385
386
387
388
389
390
391
392
393
394
395
396




397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
@%:@undef HAVE_STRINGS_H])
m4trace:configure.in:47: -1- AH_OUTPUT([HAVE_INTTYPES_H], [/* Define to 1 if you have the <inttypes.h> header file. */
@%:@undef HAVE_INTTYPES_H])
m4trace:configure.in:47: -1- AH_OUTPUT([HAVE_STDINT_H], [/* Define to 1 if you have the <stdint.h> header file. */
@%:@undef HAVE_STDINT_H])
m4trace:configure.in:47: -1- AH_OUTPUT([HAVE_UNISTD_H], [/* Define to 1 if you have the <unistd.h> header file. */
@%:@undef HAVE_UNISTD_H])
m4trace:configure.in:49: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LIBCONFIG])
m4trace:configure.in:49: -1- m4_pattern_allow([^HAVE_LIBCONFIG$])
m4trace:configure.in:49: -1- AH_OUTPUT([HAVE_LIBCONFIG], [/* Enable if you have the required libconfig library. */
@%:@undef HAVE_LIBCONFIG])
m4trace:configure.in:56: -1- AC_DEFINE_TRACE_LITERAL([HAVE_NFQUEUE])
m4trace:configure.in:56: -1- m4_pattern_allow([^HAVE_NFQUEUE$])




m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_NFQUEUE], [/* Enable if you have nfqueue */
@%:@undef HAVE_NFQUEUE])
m4trace:configure.in:66: -1- AC_DEFINE_TRACE_LITERAL([HAVE_NFNETLINK])
m4trace:configure.in:66: -1- m4_pattern_allow([^HAVE_NFNETLINK$])
m4trace:configure.in:66: -1- AH_OUTPUT([HAVE_NFNETLINK], [/* Enable if netlink exists */
@%:@undef HAVE_NFNETLINK])
m4trace:configure.in:79: -1- AC_DEFINE_TRACE_LITERAL([HAVE_FIREDNS])
m4trace:configure.in:79: -1- m4_pattern_allow([^HAVE_FIREDNS$])
m4trace:configure.in:79: -1- AH_OUTPUT([HAVE_FIREDNS], [/* Enable if you have the optional firedns library */
@%:@undef HAVE_FIREDNS])
m4trace:configure.in:92: -1- AC_DEFINE_TRACE_LITERAL([USE_CACHE])
m4trace:configure.in:92: -1- m4_pattern_allow([^USE_CACHE$])
m4trace:configure.in:92: -1- AH_OUTPUT([USE_CACHE], [/* Enable if you want to use a caching mechanism. */
@%:@undef USE_CACHE])
m4trace:configure.in:97: -1- AC_CONFIG_FILES([Makefile])
m4trace:configure.in:98: -1- AC_CONFIG_HEADERS([config.h])
m4trace:configure.in:99: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([LIB@&t@OBJS])
m4trace:configure.in:99: -1- m4_pattern_allow([^LIB@&t@OBJS$])
m4trace:configure.in:99: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([LTLIBOBJS])
m4trace:configure.in:99: -1- m4_pattern_allow([^LTLIBOBJS$])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([top_builddir])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([top_build_prefix])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([srcdir])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([abs_srcdir])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([top_srcdir])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([abs_top_srcdir])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([builddir])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([abs_builddir])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([abs_top_builddir])
m4trace:configure.in:99: -1- AC_SUBST_TRACE([INSTALL])

Modified configure from [5a5437a7aa] to [568f3e906e].

3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
_ACEOF

fi

done


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pool_free in -lpool" >&5
$as_echo_n "checking for pool_free in -lpool... " >&6; }
if test "${ac_cv_lib_pool_pool_free+set}" = set; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lpool  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char pool_free ();
int
main ()
{
return pool_free ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_pool_pool_free=yes
else
  ac_cv_lib_pool_pool_free=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pool_pool_free" >&5
$as_echo "$ac_cv_lib_pool_pool_free" >&6; }
if test "x$ac_cv_lib_pool_pool_free" = x""yes; then :


$as_echo "#define HAVE_POOL /**/" >>confdefs.h

	LIBS="$LIBS -lpool"

else

	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "You must have dotconf (libpool), find it here: http://www.azzit.de/dotconf/
See \`config.log' for more details" "$LINENO" 5; }

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dotconf_create in -ldotconf" >&5
$as_echo_n "checking for dotconf_create in -ldotconf... " >&6; }
if test "${ac_cv_lib_dotconf_dotconf_create+set}" = set; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldotconf  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char dotconf_create ();
int
main ()
{
return dotconf_create ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_dotconf_dotconf_create=yes
else
  ac_cv_lib_dotconf_dotconf_create=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dotconf_dotconf_create" >&5
$as_echo "$ac_cv_lib_dotconf_dotconf_create" >&6; }
if test "x$ac_cv_lib_dotconf_dotconf_create" = x""yes; then :


$as_echo "#define HAVE_DOTCONF /**/" >>confdefs.h

	LIBS="$LIBS -ldotconf"

else

	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "You must have dotconf, find it here: http://www.azzit.de/dotconf/
See \`config.log' for more details" "$LINENO" 5; }

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nfq_set_verdict in -lnetfilter_queue" >&5
$as_echo_n "checking for nfq_set_verdict in -lnetfilter_queue... " >&6; }







|
|
|



|









|



|





|

|





|
|
|


|

|





<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|







3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927





















































3928
3929
3930
3931
3932
3933
3934
3935
_ACEOF

fi

done


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for config_init in -lconfig" >&5
$as_echo_n "checking for config_init in -lconfig... " >&6; }
if test "${ac_cv_lib_config_config_init+set}" = set; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lconfig  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char config_init ();
int
main ()
{
return config_init ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_config_config_init=yes
else
  ac_cv_lib_config_config_init=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_config_config_init" >&5
$as_echo "$ac_cv_lib_config_config_init" >&6; }
if test "x$ac_cv_lib_config_config_init" = x""yes; then :


$as_echo "#define HAVE_LIBCONFIG /**/" >>confdefs.h

	LIBS="$LIBS -lconfig"

else

	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}





















































as_fn_error $? "You must have libconfig
See \`config.log' for more details" "$LINENO" 5; }

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nfq_set_verdict in -lnetfilter_queue" >&5
$as_echo_n "checking for nfq_set_verdict in -lnetfilter_queue... " >&6; }

Modified configure.in from [063c9874e8] to [39f7f4ab4f].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
		AC_DEFINE_UNQUOTED(SOCKSTAT_PATH, ["$withval"], [Define the path of the stats socket])
	fi
	])
	

AC_CHECK_HEADERS(libipq.h stdlib.h stdio.h string.h netinet/in.h netinet/tcp.h resolv.h netdb.h ctype.h syslog.h sys/stat.h sys/types.h unistd.h getopt.h dotconf.h libpool.h time.h)

AC_CHECK_LIB(pool, pool_free, [
	AC_DEFINE(HAVE_POOL, [], [Enable if you have the required pool library])
	LIBS="$LIBS -lpool"
], [
	AC_MSG_FAILURE([You must have dotconf (libpool), find it here: http://www.azzit.de/dotconf/])
])

AC_CHECK_LIB(dotconf, dotconf_create, [
	AC_DEFINE(HAVE_DOTCONF, [], [Enable if you have the required dotconf library.])
	LIBS="$LIBS -ldotconf"
], [
	AC_MSG_FAILURE([You must have dotconf, find it here: http://www.azzit.de/dotconf/])
])

AC_CHECK_LIB(netfilter_queue, nfq_set_verdict, [
	AC_DEFINE(HAVE_NFQUEUE, [], [Enable if you have nfqueue])
	LIBS="$LIBS -lnetfilter_queue"
	have_nfqueue='yes'
])







|
|
|

<
<
<
<
<
<
<
|







42
43
44
45
46
47
48
49
50
51
52







53
54
55
56
57
58
59
60
		AC_DEFINE_UNQUOTED(SOCKSTAT_PATH, ["$withval"], [Define the path of the stats socket])
	fi
	])
	

AC_CHECK_HEADERS(libipq.h stdlib.h stdio.h string.h netinet/in.h netinet/tcp.h resolv.h netdb.h ctype.h syslog.h sys/stat.h sys/types.h unistd.h getopt.h dotconf.h libpool.h time.h)

AC_CHECK_LIB(config, config_init, [
	AC_DEFINE(HAVE_LIBCONFIG, [], [Enable if you have the required libconfig library.])
	LIBS="$LIBS -lconfig"
], [







	AC_MSG_FAILURE([You must have libconfig])
])

AC_CHECK_LIB(netfilter_queue, nfq_set_verdict, [
	AC_DEFINE(HAVE_NFQUEUE, [], [Enable if you have nfqueue])
	LIBS="$LIBS -lnetfilter_queue"
	have_nfqueue='yes'
])

Modified packetbl.c from [6783fc984d] to [de1fe284bf].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <time.h>
#include <errno.h>
#include <linux/netfilter.h>

#include <dotconf.h>
#include <libpool.h>

#ifdef USE_SOCKSTAT
#include <sys/socket.h>
#include <sys/un.h>
#include <pthread.h>
#endif








<
<
|







30
31
32
33
34
35
36


37
38
39
40
41
42
43
44
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <time.h>
#include <errno.h>
#include <linux/netfilter.h>


#include <libconfig.h>

#ifdef USE_SOCKSTAT
#include <sys/socket.h>
#include <sys/un.h>
#include <pthread.h>
#endif

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147




148

149
150
151
152
153
154
155
156
	char *string;
	struct config_entry *next;
	struct packet_info ip;
	struct cidr	cidr;

};

struct config_entry *blacklistbl = NULL;
struct config_entry *whitelistbl = NULL;
struct config_entry *blacklist = NULL;
struct config_entry *whitelist = NULL;

struct bl_context {

	int	permissions;
	const char *current_end_token;

	pool_t *pool;
};

enum permissions {
	O_ROOT = 1,
	O_HOSTSECTION = 2,
	O_LAST = 4
};

static DOTCONF_CB(host_section_open);
static DOTCONF_CB(common_section_close);
static DOTCONF_CB(common_option);
static DOTCONF_CB(toggle_option);
static DOTCONF_CB(facility_option);

static const char *end_host = "</host>";
char msgbuf[BUFFERSIZE];

struct config {
	int	allow_non25;
	int	allow_nonsyn;
	int	default_accept;
	int	dryrun;
	int 	log_facility;
	int	queueno;
	int	quiet;
	int	debug;




};

static struct config conf = { 0, 0, 1, 0, LOG_DAEMON, 0 };

struct pbl_stat_info {
	uint32_t	cacheaccept;
	uint32_t	cachereject;
	uint32_t	whitelistblhits;
	uint32_t	blacklistblhits;
	uint32_t	whitelisthits;







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<











>
>
>
>

>
|







102
103
104
105
106
107
108


























109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
	char *string;
	struct config_entry *next;
	struct packet_info ip;
	struct cidr	cidr;

};



























char msgbuf[BUFFERSIZE];

struct config {
	int	allow_non25;
	int	allow_nonsyn;
	int	default_accept;
	int	dryrun;
	int 	log_facility;
	int	queueno;
	int	quiet;
	int	debug;
	struct config_entry *blacklistbl;
	struct config_entry *whitelistbl;
	struct config_entry *blacklist;
	struct config_entry *whitelist;
};

static struct config conf = { 0, 0, 1, 0, LOG_DAEMON, 0, 0, 0, NULL, NULL, NULL, NULL };

struct pbl_stat_info {
	uint32_t	cacheaccept;
	uint32_t	cachereject;
	uint32_t	whitelistblhits;
	uint32_t	blacklistblhits;
	uint32_t	whitelisthits;
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211

212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
static void get_ip_string(const struct packet_info *ip);
static void pbl_set_verdict(struct PBL_HANDLE *h, PBL_ID_T id,
        unsigned int verdict);

static int pbl_callback(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg,
	struct nfq_data *nfa, void *data);
	
static const configoption_t options[] = {
	{"<host>", ARG_NONE, host_section_open, NULL, O_ROOT},
	{"</host>", ARG_NONE, common_section_close, NULL, O_ROOT},
	{"blacklistbl", ARG_STR, common_option, NULL, O_HOSTSECTION},
	{"whitelistbl", ARG_STR, common_option, NULL, O_HOSTSECTION},
	{"whitelist", ARG_STR, common_option, NULL, O_HOSTSECTION},
	{"blacklist", ARG_STR, common_option, NULL, O_HOSTSECTION},
	{"fallthroughaccept", ARG_TOGGLE, toggle_option, NULL, O_ROOT},
	{"allownonport25", ARG_TOGGLE, toggle_option, NULL, O_ROOT},
	{"allownonsyn", ARG_TOGGLE, toggle_option, NULL, O_ROOT},
	{"dryrun", ARG_TOGGLE, toggle_option, NULL, O_ROOT},
	{"quiet", ARG_TOGGLE, toggle_option, NULL, O_ROOT},
#ifdef USE_CACHE
	{"cachettl", ARG_INT, toggle_option, NULL, O_ROOT},
	{"cachesize", ARG_INT, toggle_option, NULL, O_ROOT},
#endif
	{"logfacility", ARG_STR, facility_option, NULL, O_ROOT},
#ifdef HAVE_NFQUEUE
	{"queueno", ARG_INT, common_option, NULL, O_ROOT},
#endif

	LAST_OPTION
};

FUNC_ERRORHANDLER(error_handler) {

	fprintf(stderr, "[error] %s\n", msg);
	return 1;

}

/*
 * SYNOPSIS:
 *   void daemonize(void);
 *
 * NOTES:
 *   This function accomplishes everything needed to become a daemon.
 *   Including closing standard in/out/err and forking.







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
>
|
|
|
|
|
<
<
|
|








162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

188
189
190
191
192
193


194
195
196
197
198
199
200
201
202
203
static void get_ip_string(const struct packet_info *ip);
static void pbl_set_verdict(struct PBL_HANDLE *h, PBL_ID_T id,
        unsigned int verdict);

static int pbl_callback(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg,
	struct nfq_data *nfa, void *data);
	
typedef struct facility {
	char *string;
	int num;
} facility;

static struct facility facenum[] = {
	{"auth", LOG_AUTH},
	{"authpriv", LOG_AUTHPRIV},
	{"cron", LOG_CRON},
	{"daemon", LOG_DAEMON},
	{"kern", LOG_KERN},
	{"lpr", LOG_LPR},
	{"mail", LOG_MAIL},
	{"news", LOG_NEWS},
	{"syslog", LOG_SYSLOG},
	{"user", LOG_USER},
	{"uucp", LOG_UUCP},
	{"local0", LOG_LOCAL0},
	{"local1", LOG_LOCAL1},

	{"local2", LOG_LOCAL2},
	{"local3", LOG_LOCAL3},
	{"local4", LOG_LOCAL4},
	{"local5", LOG_LOCAL5},
	{"local6", LOG_LOCAL6},
	{"local7", LOG_LOCAL7},


	NULL
};

/*
 * SYNOPSIS:
 *   void daemonize(void);
 *
 * NOTES:
 *   This function accomplishes everything needed to become a daemon.
 *   Including closing standard in/out/err and forking.
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
	}
#endif

	/* the get_ip_string is set AFTER the check_packet_*
	 * calls because of the possibility they could screw with
	 * msgbuf.  They shouldn't, really, but better safe than
	 * sorry, at least for now. */
	if (check_packet_list(&ip, whitelist) == 1) {
		get_ip_string(&ip);
		if (!conf.quiet) {
			if (conf.debug == 0) {
				syslog(LOG_INFO,
					"[accept whitelist] [%s]",
						msgbuf);
			} else {
				fprintf(stderr,
					"[accept whitelist] [%s]",
						msgbuf);
			}
		}
		statistics.whitelisthits++;
		retval=NF_ACCEPT;
	} else
	if (check_packet_list(&ip, blacklist) == 1) {
		get_ip_string(&ip);
		if (!conf.quiet) {
			if (conf.debug == 0) {
				syslog(LOG_INFO,
					"[reject blacklist] [%s]",
						msgbuf);
			} else {
				fprintf(stderr,
					"[reject blacklist] [%s]",
						msgbuf);
			}
				
		}
		statistics.blacklisthits++;
		retval=NF_DROP;
	} else
	if (check_packet_dnsbl(&ip, whitelistbl) == 1) {
		get_ip_string(&ip);
		if (!conf.quiet) {
			if (conf.debug == 0) {
				syslog(LOG_INFO,
					"[accept dnsbl] [%s]",
						msgbuf);
			} else {
				fprintf(stderr,
					"[accept dnsbl] [%s]",
						msgbuf);
			}
		}
		statistics.whitelistblhits++;
		retval=NF_ACCEPT;
	} else
	if (check_packet_dnsbl(&ip, blacklistbl) == 1) {
		get_ip_string(&ip);
		if (!conf.quiet) {
			if (conf.debug == 0) {
				syslog(LOG_INFO,
					"[reject dnsbl] [%s]",
						msgbuf);
			} else {







|















|
















|















|







396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
	}
#endif

	/* the get_ip_string is set AFTER the check_packet_*
	 * calls because of the possibility they could screw with
	 * msgbuf.  They shouldn't, really, but better safe than
	 * sorry, at least for now. */
	if (check_packet_list(&ip, conf.whitelist) == 1) {
		get_ip_string(&ip);
		if (!conf.quiet) {
			if (conf.debug == 0) {
				syslog(LOG_INFO,
					"[accept whitelist] [%s]",
						msgbuf);
			} else {
				fprintf(stderr,
					"[accept whitelist] [%s]",
						msgbuf);
			}
		}
		statistics.whitelisthits++;
		retval=NF_ACCEPT;
	} else
	if (check_packet_list(&ip, conf.blacklist) == 1) {
		get_ip_string(&ip);
		if (!conf.quiet) {
			if (conf.debug == 0) {
				syslog(LOG_INFO,
					"[reject blacklist] [%s]",
						msgbuf);
			} else {
				fprintf(stderr,
					"[reject blacklist] [%s]",
						msgbuf);
			}
				
		}
		statistics.blacklisthits++;
		retval=NF_DROP;
	} else
	if (check_packet_dnsbl(&ip, conf.whitelistbl) == 1) {
		get_ip_string(&ip);
		if (!conf.quiet) {
			if (conf.debug == 0) {
				syslog(LOG_INFO,
					"[accept dnsbl] [%s]",
						msgbuf);
			} else {
				fprintf(stderr,
					"[accept dnsbl] [%s]",
						msgbuf);
			}
		}
		statistics.whitelistblhits++;
		retval=NF_ACCEPT;
	} else
	if (check_packet_dnsbl(&ip, conf.blacklistbl) == 1) {
		get_ip_string(&ip);
		if (!conf.quiet) {
			if (conf.debug == 0) {
				syslog(LOG_INFO,
					"[reject dnsbl] [%s]",
						msgbuf);
			} else {
834
835
836
837
838
839
840
841

842



843
844

845
846
847
848
849



850
851
852


853
854
855







856





























































































857

858






859






860


















861
862
863
864
865
866
867
 *   global variables.  It may cause the program to abort with a failure
 *   if the configuration is unreadable or unparsable.  Due to this fact,
 *   it should only be called during start-up and not from the main loop.
 *
 */
void parse_config(void) {

	configfile_t *configfile;

	struct bl_context context;




	context.pool = pool_new(NULL);

	configfile = dotconf_create(CONFIGFILE, options, (void *)&context,
		CASE_INSENSITIVE);
	if (!configfile) {
		fprintf(stderr, "Error opening config file\n");
		exit(EXIT_FAILURE);



	}
	if (dotconf_command_loop(configfile) == 0) {
		fprintf(stderr, "Error reading configuration file\n");


		exit(EXIT_FAILURE);
	}








	dotconf_cleanup(configfile);





























































































	pool_free(context.pool);








	return;






}


















/*
 * SYNOPSIS:
 *   void parse_arguments(
 *                        int argc,
 *                        char **argv
 *                       );
 *







|
>
|
>
>
>
|
|
>
|
<
|
|
<
>
>
>
|
|
|
>
>



>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825

826
827

828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
 *   global variables.  It may cause the program to abort with a failure
 *   if the configuration is unreadable or unparsable.  Due to this fact,
 *   it should only be called during start-up and not from the main loop.
 *
 */
void parse_config(void) {

	config_t *config = NULL;
	config_setting_t *config_setting = NULL;
	struct ce *config_entry = NULL;
	int result = 0;
	int i = 0;
	const char *facstr = NULL;
	
	config_init(config);
	result = config_read_file(config, "test.config");
	if (result == CONFIG_FALSE) {

		if (config_error_type(config) == CONFIG_ERR_PARSE) {
			fprintf (stderr, "Error parsing config file %s, line %d: %s\n",

				config_error_file(config),
				config_error_line(config),
				config_error_text(config));
		}
		if (config_error_type(config) == CONFIG_ERR_FILE_IO) {
			fprintf (stderr, "Error reading config file: %s\n",
				config_error_text(config));
		}
		exit(EXIT_FAILURE);
	}

	/* there are default, so I'm not checking return values.  If it fails,
	 * then we'll just stay with the default, whatever that might be. */
	config_lookup_bool(config, "options.fallthroughaccept", &conf.default_accept);
	config_lookup_bool(config, "options.allownonport25", &conf.allow_non25);
	config_lookup_bool(config, "options.dryrun", &conf.dryrun);
	config_lookup_bool(config, "options.allownonsyn", &conf.allow_nonsyn);
	config_lookup_bool(config, "options.quiet", &conf.quiet);

#ifdef USE_CACHE
	config_lookup_int(config, "cache.ttl", &packet_cache_ttl);

	if (packet_cache_ttl < 0) {
		packet_cache_ttl = USE_CACHE_DEF_TTL;
		fprintf(stderr, "config cache TTL negative - using default");
	}

	config_lookup_int(config, "cache.len", &packet_cache_len);

	if (packet_cache_len < 0) {
		packet_cache_len = USE_CACHE_DEF_LEN;
		fprintf(stderr, "config size TTL negative - using default");
	}
#endif

	config_lookup_string(config, "log.facility", &facstr);
	i = 0;
	while (&facenum[i] != NULL) {
		if (strcasecmp(facenum[i].string, facstr) == 0) {
			conf.log_facility = facenum[i].num;
			break;
		} else {
			i++;
		}
	}
	
	config_lookup_int(config, "config.queueno", &conf.queueno);
	
	if (conf.queueno < 0) {
		conf.queueno = 1;
		fprintf(stderr, "queueno negative - using default");
	}

	config_setting = config_lookup(config, "blacklistbl");
	parse_config_bl_list(config_setting, 1);
	config_setting = config_lookup(config, "whitelistbl");
	parse_config_bl_list(config_setting, 2);
	config_setting = config_lookup(config, "blacklist");
	parse_config_bl_list(config_setting, 3);
	config_setting = config_lookup(config, "whitelist");
	parse_config_bl_list(config_setting, 4);
	
}

parse_config_bl_list(config_setting_t *c, int type) {

	struct config_entry *ce, *tmp;
	int i = 0, len = 0;
	char *setting;
#ifdef HAVE_FIREDNS
	size_t blacklistlen = 0;
#endif

	len = config_setting_length(c);
	while (i++ < len) {
		setting = config_setting_get_string_elem(c, i);
		ce = malloc(sizeof(struct config_entry));
		if (ce == NULL) {
			/* shouldn't happen... */
			fprintf(stderr, "Failed to allocate memory for ce struct\n");
			exit(EXIT_FAILURE);
		}

		ce->string = (char *)strdup(setting);
		ce->next = NULL;
#ifdef HAVE_FIREDNS
		blacklistlen = strlen(ce->string);
		if (ce->string[blacklistlen - 1] == '.') {
			ce->string[blacklistlen - 1] = '\0';
		}
#endif

		switch (type) {
			case 1:
				if (conf.blacklistbl == NULL) {
					conf.blacklistbl = ce;
					continue;
				} else {
					tmp = conf.blacklistbl;
				}
				break;
			case 2:
				if (conf.whitelistbl == NULL) {
					conf.whitelistbl = ce;
					continue;
				} else {
					tmp = conf.whitelistbl;
				}
			case 3:
				if (parse_cidr(ce) == -1) {
					fprintf(stderr, "Error parsing CIDR in %s, ignoring\n", ce->string);
					free(ce->string);
					free(ce);
					continue;
				}
				if (conf.blacklist == NULL) {
					conf.blacklist = ce;
					continue;
				} else {
					tmp = conf.blacklist;
				}
				break;
			case 4:
				if (parse_cidr(ce) == -1) {
					fprintf(stderr, "Error parsing CIDR in %s, ignoring\n", ce->string);
					free(ce->string);
					free(ce);
					continue;
				}
				if (conf.whitelist == NULL) {
					conf.whitelist = ce;
					continue;
				} else {
					tmp = conf.whitelist;
				}
				break;
		}	

		while (tmp->next != NULL) {
			tmp = tmp->next;
		}

		tmp->next = ce;

	}
}
	
/*
 * SYNOPSIS:
 *   void parse_arguments(
 *                        int argc,
 *                        char **argv
 *                       );
 *
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
			default:
				exit(EXIT_FAILURE);
				break;
		}
	}

	return;
}

DOTCONF_CB(common_section_close) {

	struct bl_context *context = (struct bl_context *)ctx;

	return context->current_end_token;
}

DOTCONF_CB(toggle_option) {

	if (strcasecmp(cmd->name, "fallthroughaccept") == 0) {
		conf.default_accept = cmd->data.value;
		return NULL;
	}
	if (strcasecmp(cmd->name, "allownonport25") == 0) {
		conf.allow_non25 = cmd->data.value;
		return NULL;
	}
	if (strcasecmp(cmd->name, "dryrun") == 0) {
		conf.dryrun = cmd->data.value;
		return NULL;
	}
	if (strcasecmp(cmd->name, "allownonsyn") == 0) {
		conf.allow_nonsyn = cmd->data.value;
		return NULL;
	}
	if (strcasecmp(cmd->name, "quiet") == 0) {
		conf.quiet = cmd->data.value;
		return NULL;
	}
#ifdef USE_CACHE
	if (strcasecmp(cmd->name, "cachettl") == 0) {
		if (cmd->data.value < 0) {
			fprintf(stderr, "Error parsing config: cachettl cannot be a negative value\n");
			exit(EXIT_FAILURE);
		}
		packet_cache_ttl = cmd->data.value;
		return NULL;
	}
	if (strcasecmp(cmd->name, "cachesize") == 0) {
		if (cmd->data.value < 0) {
			fprintf(stderr, "Error parsing config: cachelen cannot be a negative value\n");
			exit(EXIT_FAILURE);
		}
		packet_cache_len = cmd->data.value;
		return NULL;
	}
#endif

	return NULL;
}

DOTCONF_CB(facility_option) {

	if (strcasecmp(cmd->data.str, "auth") == 0) {
		conf.log_facility = LOG_AUTH;
	} else if (strcasecmp(cmd->data.str, "authpriv") == 0) {
		conf.log_facility = LOG_AUTHPRIV;
	} else if (strcasecmp(cmd->data.str, "cron") == 0) {
		conf.log_facility = LOG_CRON;
	} else if (strcasecmp(cmd->data.str, "daemon") == 0) {
		conf.log_facility = LOG_DAEMON;
	} else if (strcasecmp(cmd->data.str, "kern") == 0) {
		conf.log_facility = LOG_KERN;
	} else if (strcasecmp(cmd->data.str, "lpr") == 0) {
		conf.log_facility = LOG_LPR;
	} else if (strcasecmp(cmd->data.str, "mail") == 0) {
		conf.log_facility = LOG_MAIL;
	} else if (strcasecmp(cmd->data.str, "news") == 0) {
		conf.log_facility = LOG_NEWS;
	} else if (strcasecmp(cmd->data.str, "syslog") == 0) {
		conf.log_facility = LOG_SYSLOG;
	} else if (strcasecmp(cmd->data.str, "user") == 0) {
		conf.log_facility = LOG_USER;
	} else if (strcasecmp(cmd->data.str, "uucp") == 0) {
		conf.log_facility = LOG_UUCP;
	} else if (strcasecmp(cmd->data.str, "local0") == 0) {
		conf.log_facility = LOG_LOCAL0;
	} else if (strcasecmp(cmd->data.str, "local1") == 0) {
		conf.log_facility = LOG_LOCAL1;
	} else if (strcasecmp(cmd->data.str, "local2") == 0) {
		conf.log_facility = LOG_LOCAL2;
	} else if (strcasecmp(cmd->data.str, "local3") == 0) {
		conf.log_facility = LOG_LOCAL3;
	} else if (strcasecmp(cmd->data.str, "local4") == 0) {
		conf.log_facility = LOG_LOCAL4;
	} else if (strcasecmp(cmd->data.str, "local5") == 0) {
		conf.log_facility = LOG_LOCAL5;
	} else if (strcasecmp(cmd->data.str, "local6") == 0) {
		conf.log_facility = LOG_LOCAL6;
	} else if (strcasecmp(cmd->data.str, "local7") == 0) {
		conf.log_facility = LOG_LOCAL7;
	} else {
		fprintf(stderr, "Log facility %s is invalid\n",
			cmd->data.str);
		exit(EXIT_FAILURE);
	}
	
	return NULL;
}

DOTCONF_CB(common_option) {

	struct config_entry *ce, *tmp=NULL;
#ifdef HAVE_FIREDNS
	size_t blacklistlen = 0;
#endif

	if (strcasecmp(cmd->name, "queueno") == 0) {
		conf.queueno = cmd->data.value;
		return NULL;
	}

	ce =  malloc(sizeof(struct config_entry));
	if (ce == NULL) {
		return NULL;
	}

	ce->string = (char *)strdup(cmd->data.str);
	ce->next = NULL;

	if (strcasecmp(cmd->name, "blacklistbl") == 0) {

#ifdef HAVE_FIREDNS
		blacklistlen = strlen(ce->string);
		if (ce->string[blacklistlen-1] == '.') {
			ce->string[blacklistlen-1]='\0';
		}
#endif

		/* resolution check completely removed.  Will put it back
		 * during config file and architectural revamp. */
		if (blacklistbl == NULL) {
			blacklistbl = ce;
			return NULL;
		} else {
			tmp = blacklistbl;
		}
	}

	if (strcasecmp(cmd->name, "whitelistbl") == 0) {

#ifdef HAVE_FIREDNS
		blacklistlen = strlen(ce->string);
		if (ce->string[blacklistlen-1] == '.') {
			ce->string[blacklistlen-1]='\0';
		}
#endif

		/* resolution check completely removed.  Will put it back
		 * during config file and architectural revamp. */
		if (whitelistbl == NULL) {
			whitelistbl = ce;
			return NULL;
		} else {
			tmp = whitelistbl;
		}
	}

	if (strcasecmp(cmd->name, "whitelist") == 0) {
		if (parse_cidr(ce) == -1) {
			fprintf(stderr, "Error parsing CIDR in %s, ignoring\n",
				ce->string);
			free(ce->string);
			free(ce);
			return NULL;
		}
		if (whitelist == NULL) {
			whitelist = ce;
			return NULL;
		} else {
			tmp = whitelist;
		}
	}

	if (strcasecmp(cmd->name, "blacklist") == 0) {
		if (parse_cidr(ce) == -1) {
			fprintf(stderr, "Error parsing CIDR in %s, ignoring\n",
				ce->string);
			free(ce->string);
			free(ce);
			return NULL;
		}
		if (blacklist == NULL) {
			blacklist = ce;
			return NULL;
		} else {
			tmp = blacklist;
		}
	}

	while (tmp->next != NULL) {
		tmp = tmp->next;
	}

	tmp->next = ce;

	return NULL;

}

DOTCONF_CB(host_section_open) {
	
	struct bl_context *context = (struct bl_context *)ctx;
	const char *old_end_token = context->current_end_token;
	int old_override = context->permissions;
	const char *err = NULL;

	context->permissions |= O_HOSTSECTION;
	context->current_end_token = end_host;

	while (!cmd->configfile->eof) {
		err = dotconf_command_loop_until_error(cmd->configfile);
		if (!err) {
			err = "</host> is missing";
			break;
		}
	
		if (err == context->current_end_token)
			break;
	
		dotconf_warning(cmd->configfile, DCLOG_ERR, 0, err);
	}

	context->current_end_token = old_end_token;
	context->permissions = old_override;

	if (err != end_host)
		return err;

	return NULL;

}

/*
 * SYNOPSIS:
 *   int parse_cidr(
 *                  struct config_entry *ce
 *                 );







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1015
1016
1017
1018
1019
1020
1021









































































































































































































































1022
1023
1024
1025
1026
1027
1028
			default:
				exit(EXIT_FAILURE);
				break;
		}
	}

	return;









































































































































































































































}

/*
 * SYNOPSIS:
 *   int parse_cidr(
 *                  struct config_entry *ce
 *                 );