1 /* @(#) $Id: ./src/headers/validate_op.h, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
13 /* Part of the OSSEC HIDS
14 * Available at http://www.ossec.net
26 unsigned int ip_address;
31 /* Getting the netmask based on the integer value. */
32 int getNetmask(int mask, char *strmask, int size);
35 /* Run time definitions. */
36 int getDefine_Int(char *high_name, char *low_name, int min, int max);
40 /** int OS_IPFound(char *ip_address, os_ip *that_ip)
41 * Checks if ip_address is present at that_ip.
42 * Returns 1 on success or 0 on failure.
44 int OS_IPFound(char *ip_address, os_ip *that_ip);
48 /** int OS_IPFoundList(char *ip_address, char **list_of_ips)
49 * Checks if ip_address is present on the "list_of_ips".
50 * Returns 1 on success or 0 on failure.
51 * The list MUST be NULL terminated
53 int OS_IPFoundList(char *ip_address, os_ip **list_of_ips);
57 /** int OS_IsValidIP(char *ip)
58 * Validates if an ip address is in the right
60 * Returns 0 if doesn't match or 1 if it does (or 2 if it has a cidr).
61 * ** On success this function may modify the value of ip_address
63 int OS_IsValidIP(char *ip_address, os_ip *final_ip);
66 /** Time range validations **/
68 /** char *OS_IsValidTime(char *time_str)
69 * Validates if a time is in an acceptable format
71 * Returns 0 if doesn't match or a valid string for
72 * ossec usage in success.
73 * ** On success this function may modify the value of date
75 * hh:mm - hh:mm (24 hour format)
76 * !hh:mm -hh:mm (24 hour format)
77 * hh - hh (24 hour format)
78 * hh:mm am - hh:mm pm (12 hour format)
79 * hh am - hh pm (12 hour format)
81 char *OS_IsValidTime(char *time_str);
83 /* Same as above, but only accepts a unique time, not a range. */
84 char *OS_IsValidUniqueTime(char *time_str);
88 /** int OS_IsonTime(char *time_str, char *ossec_time)
89 * Must be a valid string, called after OS_IsValidTime.
90 * Returns 1 on success or 0 on failure.
92 int OS_IsonTime(char *time_str, char *ossec_time);
94 /* Same as above, but checks if time is the same or has passed a specified one. */
95 int OS_IsAfterTime(char *time_str, char *ossec_time);
99 /** Day validations **/
102 /** int OS_IsonDay(int week_day, char *ossec_day)
103 * Checks if the specified week day is in the
106 int OS_IsonDay(int week_day, char *ossec_day);
109 /** char *OS_IsValidDay(char *day_str)
110 * Validates if an day is in an acceptable format
112 * Returns 0 if doesn't match or a valid string for
113 * ossec usage in success.
114 * ** On success this function may modify the value of date
115 * Acceptable formats:
116 * weekdays, weekends, monday, tuesday, thursday,..
120 char *OS_IsValidDay(char *day_str);
125 /* Checks if the ip is a single host, not a network with a netmask */
126 #define isSingleHost(x) (x->netmask == 0xFFFFFFFF)