#include "gwlib/gwlib.h"Include dependency graph for check_ipcheck.c:

Go to the source code of this file.
Functions | |
| int | main (void) |
|
|
Definition at line 67 of file check_ipcheck.c. References GW_INFO, gwlib_init(), gwlib_shutdown(), is_allowed_ip(), log_set_output_level(), octstr_get_cstr, octstr_imm(), panic, and result. 00068 {
00069 Octstr *ip;
00070 Octstr *allowed;
00071 Octstr *denied;
00072 int result;
00073 int i;
00074 static struct {
00075 char *allowed;
00076 char *denied;
00077 char *ip;
00078 int should_be_allowed;
00079 } tab[] = {
00080 { "127.0.0.1", "", "127.0.0.1", 1 },
00081 { "127.0.0.1", "", "127.0.0.2", 1 },
00082 { "127.0.0.1", "*.*.*.*", "127.0.0.1", 1 },
00083 { "127.0.0.1", "*.*.*.*", "1.2.3.4", 0 },
00084 { "127.0.0.1", "127.0.0.*", "1.2.3.4", 1 },
00085 { "127.0.0.1", "127.0.0.*", "127.0.0.2", 0 },
00086 };
00087
00088 gwlib_init();
00089 log_set_output_level(GW_INFO);
00090
00091 for (i = 0; (size_t) i < sizeof(tab) / sizeof(tab[0]); ++i) {
00092 allowed = octstr_imm(tab[i].allowed);
00093 denied = octstr_imm(tab[i].denied);
00094 ip = octstr_imm(tab[i].ip);
00095 result = is_allowed_ip(allowed, denied, ip);
00096 if (!!result != !!tab[i].should_be_allowed) {
00097 panic(0, "is_allowed_ip did not work for "
00098 "allowed=<%s> denied=<%s> ip=<%s>, "
00099 "returned %d should be %d",
00100 octstr_get_cstr(allowed),
00101 octstr_get_cstr(denied),
00102 octstr_get_cstr(ip),
00103 result,
00104 tab[i].should_be_allowed);
00105 }
00106 }
00107
00108 gwlib_shutdown();
00109 return 0;
00110 }
|
Here is the call graph for this function:
