1 /* @(#) $Id: validate_op.h,v 1.13 2009/06/24 17:06:26 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
12 /* Part of the OSSEC HIDS
13 * Available at http://www.ossec.net
25 unsigned int ip_address;
30 /* Getting the netmask based on the integer value. */
31 int getNetmask(int mask, char *strmask, int size);
34 /* Run time definitions. */
35 int getDefine_Int(char *high_name, char *low_name, int min, int max);
39 /** int OS_IPFound(char *ip_address, os_ip *that_ip)
40 * Checks if ip_address is present at that_ip.
41 * Returns 1 on success or 0 on failure.
43 int OS_IPFound(char *ip_address, os_ip *that_ip);
47 /** int OS_IPFoundList(char *ip_address, char **list_of_ips)
48 * Checks if ip_address is present on the "list_of_ips".
49 * Returns 1 on success or 0 on failure.
50 * The list MUST be NULL terminated
52 int OS_IPFoundList(char *ip_address, os_ip **list_of_ips);
56 /** int OS_IsValidIP(char *ip)
57 * Validates if an ip address is in the right
59 * Returns 0 if doesn't match or 1 if it does (or 2 if it has a cidr).
60 * ** On success this function may modify the value of ip_address
62 int OS_IsValidIP(char *ip_address, os_ip *final_ip);
65 /** Time range validations **/
67 /** char *OS_IsValidTime(char *time_str)
68 * Validates if a time is in an acceptable format
70 * Returns 0 if doesn't match or a valid string for
71 * ossec usage in success.
72 * ** On success this function may modify the value of date
74 * hh:mm - hh:mm (24 hour format)
75 * !hh:mm -hh:mm (24 hour format)
76 * hh - hh (24 hour format)
77 * hh:mm am - hh:mm pm (12 hour format)
78 * hh am - hh pm (12 hour format)
80 char *OS_IsValidTime(char *time_str);
82 /* Same as above, but only accepts a unique time, not a range. */
83 char *OS_IsValidUniqueTime(char *time_str);
87 /** int OS_IsonTime(char *time_str, char *ossec_time)
88 * Must be a valid string, called after OS_IsValidTime.
89 * Returns 1 on success or 0 on failure.
91 int OS_IsonTime(char *time_str, char *ossec_time);
93 /* Same as above, but checks if time is the same or has passed a specified one. */
94 int OS_IsAfterTime(char *time_str, char *ossec_time);
98 /** Day validations **/
101 /** int OS_IsonDay(int week_day, char *ossec_day)
102 * Checks if the specified week day is in the
105 int OS_IsonDay(int week_day, char *ossec_day);
108 /** char *OS_IsValidDay(char *day_str)
109 * Validates if an day is in an acceptable format
111 * Returns 0 if doesn't match or a valid string for
112 * ossec usage in success.
113 * ** On success this function may modify the value of date
114 * Acceptable formats:
115 * weekdays, weekends, monday, tuesday, thursday,..
119 char *OS_IsValidDay(char *day_str);
124 /* Checks if the ip is a single host, not a network with a netmask */
125 #define isSingleHost(x) (x->netmask == 0xFFFFFFFF)