/* ** Modular Logfile Analyzer ** Copyright 2000 Jan Kneschke ** ** Homepage: http://www.modlogan.org ** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version, and provided that the above copyright and permission notice is included with all distributed copies of this or derived software. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA ** ** $Id: mstate.h,v 1.36 2004/08/27 20:07:37 ostborn Exp $ */ #ifndef _M_STATE_H_ #define _M_STATE_H_ #include #include "mconfig.h" #include "mhash.h" #include "mlist.h" #include "marray.h" enum { M_STATE_TYPE_UNSET, M_STATE_TYPE_WEB, M_STATE_TYPE_TELECOM, M_STATE_TYPE_GLOBAL, M_STATE_TYPE_TRAFFIC, M_STATE_TYPE_MAIL, M_STATE_TYPE_IPPL }; #define M_STATE_SECTION_WEB "sec_web" #define M_STATE_SECTION_TELECOM "sec_telecom" #define M_STATE_SECTION_TRAFFIC "sec_traffic" #define M_STATE_SECTION_GLOBAL "sec_global" #define M_STATE_SECTION_MAIL "sec_mail" #define M_STATE_SUMMARY "summary" #define M_STATE_WEB_SUMMARY "web_summary" #define M_STATE_WEB_REQ_URL "web_req_url" #define M_STATE_WEB_REQ_METHOD "web_req_meth" #define M_STATE_WEB_REQ_PROTOCOL "web_req_prot" #define M_STATE_WEB_REF_URL "web_ref_url" #define M_STATE_WEB_OS "web_os" #define M_STATE_WEB_USERAGENT "web_useragent" #define M_STATE_WEB_HOST "web_host" #define M_STATE_WEB_STATUS "web_status" #define M_STATE_WEB_VISIT "web_visit" #define M_STATE_WEB_HOURS "web_hours" #define M_STATE_WEB_DAYS "web_days" #define M_STATE_WEB_COUNTRIES "web_countries" #define M_STATE_WEB_ROBOTS "web_robots" #define M_STATE_WEB_SEARCHSITE "web_searchsite" #define M_STATE_WEB_SEARCHSTRING "web_searchstring" #define M_STATE_WEB_INT_ERROR "web_int_error" #define M_STATE_WEB_MISSING_FILE "web_missing_file" #define M_STATE_WEB_BOOKMARKS "web_bookmarks" #define M_STATE_WEB_INDEXED_PAGES "web_indexed_pages" #define M_STATE_WEB_EXTENSIONS "web_extensions" #define M_STATE_WEB_VISITS "web_visit_path" #define M_STATE_WEB_VIEWS "web_views" #define M_STATE_WEB_SRVHOST "web_srvhost" #define M_STATE_WEB_REQ_USERS "web_users" #define M_STATE_WEB_LOCATION "web_location" #define M_STATE_WEB_HOST_TRAFFIC "web_host_traffic" #define M_STATE_TRAFFIC_INCOMING "traffic_incoming" #define M_STATE_TRAFFIC_OUTGOING "traffic_outgoing" #define M_STATE_TRAFFIC_INTERNAL "traffic_internal" #define M_STATE_TRAFFIC_EXTERNAL "traffic_external" #define M_STATE_MAIL_SENDER "mail_sender" #define M_STATE_MAIL_RECEIPIENT "mail_receipient" #define M_STATE_MAIL_VIRUS "mail_virus" #define M_STATE_MAIL_SCANNER "mail_scanner" #define M_STATE_MAIL_SUBJECT "mail_subject" #define M_STATE_MAIL_SEND_DOMAIN "mail_send_domain" #define M_STATE_MAIL_RECP_DOMAIN "mail_recp_domain" #define M_STATE_MAIL_HOURS "mail_hours" #define M_STATE_MAIL_DAYS "mail_days" #define M_STATE_TELECOM_CALLING "telecom_calling" #define M_STATE_TELECOM_CALLED "telecom_called" #define M_STATE_TELECOM_HOURS "telecom_hours" #define M_STATE_TELECOM_DAYS "telecom_days" #define M_STATE_IPPL_SRC_IP "ippl_src_ip" #define M_STATE_IPPL_DST_IP "ippl_dst_ip" #define M_STATE_IPPL_SRC_PORTS "ippl_src_ports" #define M_STATE_IPPL_DST_PORTS "ippl_dst_ports" #define M_STATE_IPPL_REMIDENTS "ippl_remident" #define M_STATE_IPPL_PROTOCOLS "ippl_protocols" #define M_STATE_WRITE_DEFAULT 0 #define M_STATE_WRITE_BY_MONTH 1 typedef struct { long hits; long files; long pages; long visits; long hosts; double xfersize; } marray_web; typedef struct { int year; /* summary */ int month; /* summary */ int week; /* summary */ time_t timestamp; /* summary */ int ext_type; void *ext; } mstate; typedef struct { /* datatype */ /* saved as */ mhash *visit_hash; /* data_StrInt */ /* visit */ mhash *indexed_pages; /* data_StrInt */ /* */ mhash *os_hash; /* data_Str3Int */ /* os */ mhash *req_url_hash; /* data_StrInt */ /* req_url */ mhash *ua_hash; /* data_Str3Int */ /* useragent */ mhash *req_prot_hash; /* data_StrInt */ /* req_prot */ mhash *req_meth_hash; /* data_StrInt */ /* req_meth */ mhash *host_hash; /* data_Str3Int */ /* host */ mhash *status_hash; /* data_StrInt */ /* status */ mhash *ref_url_hash; /* data_StrInt */ /* ref_url */ mhash *robots; /* data_StrInt */ /* robots */ mhash *bookmarks; /* data_StrInt */ /* bookmarks */ mhash *status_missing_file; /* data_BrokenLink */ /* missing_file */ mhash *status_internal_error; /* data_BrokenLink */ /* int_error */ mhash *searchstring; /* data_StrInt */ /* searchstring */ mhash *searchsite; /* data_StrInt */ /* searchsite */ mhash *country_hash; /* data_Str3Int */ /* countries */ mhash *extension; /* data_Count */ /* extensions */ mhash *visits; /* data_SubList */ /* visits */ mhash *views; /* data_StrInt */ /* time per page */ mhash *vhost_hash; /* data_Visited */ /* srvhost */ mhash *users; /* data_Visited */ /* users */ marray *host_array; /* data_Str3Int */ /* host */ mhash *location; /* data_Location */ /* location */ marray_web hours[24]; /* hours */ marray_web days[31]; /* days */ mhash *host_traffic; /* data_Str3Int */ /* host */ } mstate_web; typedef struct { long incoming_calls; long outgoing_calls; } marray_telecom; typedef struct { mhash *called_numbers; mhash *calling_numbers; marray_telecom hours[24]; /* hours */ marray_telecom days[31]; /* days */ } mstate_telecom; typedef struct { mhash *incoming; mhash *outgoing; mhash *external; mhash *internal; } mstate_traffic; typedef struct { long packets; long hosts; long ports; long portscannum; } marray_ippl; typedef struct { long icmp; long tcp; long udp; long other; } marray_ippl_protocol; typedef struct { long has_ipopts; long has_no_ipopts; } marray_ippl_ipopts; typedef struct { mhash *source_ips; mhash *destination_ips; mhash *source_ports; mhash *destination_ports; mhash *watched_shosts; mhash *watched_dports; mhash *remote_idents; mhash *protocol_names; marray_ippl_protocol protocols; marray_ippl_ipopts ipopts; mhash *icmp_params; marray_ippl hours[24]; marray_ippl days[31]; } mstate_ippl; typedef struct { long incoming_mails; long outgoing_mails; long incoming_bytes; long outgoing_bytes; } marray_mail; typedef struct { double local_cur; double local_max; double remote_cur; double remote_max; double deliver_cur; double queue_cur; int count; } marray_qmail_status; typedef struct { mhash *sender; mhash *receipient; mhash *send_domain; mhash *recp_domain; mhash *virus; mhash *scanner; mhash *subject; marray_mail hours[24]; /* hours */ marray_mail days[31]; /* days */ marray_qmail_status qstat[31][24]; } mstate_mail; mstate *mstate_init(); mstate_web *mstate_init_web(); mstate_telecom *mstate_init_telecom(); mstate_traffic *mstate_init_traffic(); mstate_ippl *mstate_init_ippl(); mstate_mail *mstate_init_mail(); void mstate_free(mstate *state); void mstate_free_web(mstate_web *state); void mstate_free_telecom(mstate_telecom *state); void mstate_free_traffic(mstate_traffic *state); void mstate_free_ippl(mstate_ippl *state); void mstate_free_mail(mstate_mail *state); int mstate_read (mconfig *conf, mstate *state, int year, int month, char *subpath); int mstate_write (mconfig *conf, mstate *state, int _add_month, char *subpath); int mstate_is_section_end(const char *s); #endif