From e3c4c045c6f609551af9fa4c6fc354d3661017cc Mon Sep 17 00:00:00 2001 From: Damien Stuart Date: Sat, 1 Dec 2012 11:06:41 -0500 Subject: [PATCH] Changes to address header references, platform support, error messages, and the perl module test suite. Rearranged headers to reduce duplication and remove local header references from fko.h. Removed references to headers that did not need to be explicitly set. Moved the MAX_PROTO_STR_LEN and MAX_PORT_STR_LEN definitions to the fko_limits.h file. Fixed bug where invalid nat_access or command messages were returning FKO_ERROR_INVALID_SPA_ACCESS_MSG error code instead of the one appropriate to the message type. Fixed bad nat_access_msg test in Perl module test suite (caught by new validation code). --- android/project/jni/fwknop/fko.h | 2 -- android/project/jni/fwknop/fko_limits.h | 3 +++ android/project/jni/fwknop/fko_message.h | 13 ------------- common/common.h | 1 + fwknop.spec | 6 ++++-- lib/Makefile.am | 2 +- lib/fko.h | 2 -- lib/fko_limits.h | 3 +++ lib/fko_message.c | 6 +++--- lib/fko_message.h | 3 --- lib/fko_user.h | 2 +- perl/FKO/t/02_functions.t | 4 ++-- 12 files changed, 18 insertions(+), 29 deletions(-) diff --git a/android/project/jni/fwknop/fko.h b/android/project/jni/fwknop/fko.h index d59dbaa5..79be54c8 100644 --- a/android/project/jni/fwknop/fko.h +++ b/android/project/jni/fwknop/fko.h @@ -32,8 +32,6 @@ #define FKO_H 1 #include -#include "fko_limits.h" -#include "fko_message.h" #ifdef __cplusplus extern "C" { diff --git a/android/project/jni/fwknop/fko_limits.h b/android/project/jni/fwknop/fko_limits.h index 7efba4b3..01b85fd4 100644 --- a/android/project/jni/fwknop/fko_limits.h +++ b/android/project/jni/fwknop/fko_limits.h @@ -54,6 +54,9 @@ #define MAX_IPV4_STR_LEN 16 #define MIN_IPV4_STR_LEN 7 +#define MAX_PROTO_STR_LEN 4 /* tcp, udp, icmp for now */ +#define MAX_PORT_STR_LEN 5 + /* Misc. */ #define FKO_ENCODE_TMP_BUF_SIZE 1024 diff --git a/android/project/jni/fwknop/fko_message.h b/android/project/jni/fwknop/fko_message.h index 8c57252d..d36d58e7 100644 --- a/android/project/jni/fwknop/fko_message.h +++ b/android/project/jni/fwknop/fko_message.h @@ -32,19 +32,6 @@ #ifndef FKO_MESSAGE_H #define FKO_MESSAGE_H 1 -#if PLATFORM_OPENBSD - #include - #include -#else - #if HAVE_SYS_SOCKET_H - #include - #endif -#endif -#include - -#define MAX_PROTO_STR_LEN 4 /* tcp, udp, icmp for now */ -#define MAX_PORT_STR_LEN 5 - /* SPA message format validation functions. */ int validate_cmd_msg(const char *msg); diff --git a/common/common.h b/common/common.h index daddec7c..96ad4c41 100644 --- a/common/common.h +++ b/common/common.h @@ -99,6 +99,7 @@ #endif #include "fko.h" +#include "fko_limits.h" /* Get our program version from VERSION (defined in config.h). */ diff --git a/fwknop.spec b/fwknop.spec index 88b2c8d7..02a72b72 100644 --- a/fwknop.spec +++ b/fwknop.spec @@ -130,8 +130,6 @@ fi %files -n libfko-devel %defattr(-,root,root,-) %attr(0644,root,root) %{_includedir}/fko.h -%attr(0644,root,root) %{_includedir}/fko_limits.h -%attr(0644,root,root) %{_includedir}/fko_message.h %attr(0644,root,root) %{_infodir}/libfko.info* %files server @@ -143,6 +141,10 @@ fi %config(noreplace) %attr(0600,root,root) %{_sysconfdir}/fwknop/access.conf %changelog +* Sat Dec 1 2012 - 2.0.4-1 +- Removed uneeded include files (which had been added to address an issue that + has since been fixed). + * Thu Nov 15 2012 - fwknop-2.0.4 release. diff --git a/lib/Makefile.am b/lib/Makefile.am index 03a43c18..85c0bd3f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -16,4 +16,4 @@ libfko_la_LDFLAGS = -version-info 0:4:0 $(GPGME_LIBS) AM_CPPFLAGS = $(GPGME_CFLAGS) -I $(top_srcdir)/common -include_HEADERS = fko.h fko_limits.h fko_message.h +include_HEADERS = fko.h diff --git a/lib/fko.h b/lib/fko.h index d59dbaa5..79be54c8 100644 --- a/lib/fko.h +++ b/lib/fko.h @@ -32,8 +32,6 @@ #define FKO_H 1 #include -#include "fko_limits.h" -#include "fko_message.h" #ifdef __cplusplus extern "C" { diff --git a/lib/fko_limits.h b/lib/fko_limits.h index 7efba4b3..01b85fd4 100644 --- a/lib/fko_limits.h +++ b/lib/fko_limits.h @@ -54,6 +54,9 @@ #define MAX_IPV4_STR_LEN 16 #define MIN_IPV4_STR_LEN 7 +#define MAX_PROTO_STR_LEN 4 /* tcp, udp, icmp for now */ +#define MAX_PORT_STR_LEN 5 + /* Misc. */ #define FKO_ENCODE_TMP_BUF_SIZE 1024 diff --git a/lib/fko_message.c b/lib/fko_message.c index 98587c03..b057e36d 100644 --- a/lib/fko_message.c +++ b/lib/fko_message.c @@ -232,7 +232,7 @@ validate_cmd_msg(const char *msg) /* Should always have a valid allow IP regardless of message type */ if((res = have_allow_ip(msg)) != FKO_SUCCESS) - return(res); + return(FKO_ERROR_INVALID_SPA_COMMAND_MSG); /* Commands are fairly free-form so all we can really verify is * there is something at all. Get past the IP and comma, and make @@ -292,7 +292,7 @@ validate_nat_access_msg(const char *msg) /* Should always have a valid allow IP regardless of message type */ if((res = have_allow_ip(msg)) != FKO_SUCCESS) - return(res); + return(FKO_ERROR_INVALID_SPA_NAT_ACCESS_MSG); /* Position ourselves beyond the allow IP and make sure we have * a single port value @@ -304,7 +304,7 @@ validate_nat_access_msg(const char *msg) ndx++; if((res = have_port(ndx)) != FKO_SUCCESS) - return(res); + return(FKO_ERROR_INVALID_SPA_NAT_ACCESS_MSG); if(msg[startlen-1] == ',') return(FKO_ERROR_INVALID_SPA_NAT_ACCESS_MSG); diff --git a/lib/fko_message.h b/lib/fko_message.h index 9c192e13..d36d58e7 100644 --- a/lib/fko_message.h +++ b/lib/fko_message.h @@ -32,9 +32,6 @@ #ifndef FKO_MESSAGE_H #define FKO_MESSAGE_H 1 -#define MAX_PROTO_STR_LEN 4 /* tcp, udp, icmp for now */ -#define MAX_PORT_STR_LEN 5 - /* SPA message format validation functions. */ int validate_cmd_msg(const char *msg); diff --git a/lib/fko_user.h b/lib/fko_user.h index b521dca0..fa756139 100644 --- a/lib/fko_user.h +++ b/lib/fko_user.h @@ -1,7 +1,7 @@ /* ***************************************************************************** * - * File: fko_message.h + * File: fko_user.h * * Author: Michael Rash * diff --git a/perl/FKO/t/02_functions.t b/perl/FKO/t/02_functions.t index 4e57586c..fa63502f 100644 --- a/perl/FKO/t/02_functions.t +++ b/perl/FKO/t/02_functions.t @@ -179,8 +179,8 @@ is($f1->spa_message(), '1.1.1.1,udp/111', 'verify spa message'); # 91-92 - Nat Access # -ok($f1->spa_nat_access('1.2.1.1,udp/211') == 0, 'set nat_access message'); -is($f1->spa_nat_access(), '1.2.1.1,udp/211', 'verify nat_access message'); +ok($f1->spa_nat_access('1.2.1.1,211') == 0, 'set nat_access message'); +is($f1->spa_nat_access(), '1.2.1.1,211', 'verify nat_access message'); # 93-94 - Server Auth #