Mercurial > notdcc
view srvrlib/srvr_defs.h @ 1:9b8d79ac0dc3
blindly adding debian patch for old version
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Tue, 10 Mar 2009 14:25:08 +0100 |
parents | c7f6b056b673 |
children |
line wrap: on
line source
/* Distributed Checksum Clearinghouse * * common server definitions * * Copyright (c) 2008 by Rhyolite Software, LLC * * This agreement is not applicable to any entity which sells anti-spam * solutions to others or provides an anti-spam solution as part of a * security solution sold to other entities, or to a private network * which employs the DCC or uses data provided by operation of the DCC * but does not provide corresponding data to other users. * * Permission to use, copy, modify, and distribute this software without * changes for any purpose with or without fee is hereby granted, provided * that the above copyright notice and this permission notice appear in all * copies and any distributed versions or copies are either unchanged * or not called anything similar to "DCC" or "Distributed Checksum * Clearinghouse". * * Parties not eligible to receive a license under this agreement can * obtain a commercial license to use DCC by contacting Rhyolite Software * at sales@rhyolite.com. * * A commercial license would be for Distributed Checksum and Reputation * Clearinghouse software. That software includes additional features. This * free license for Distributed ChecksumClearinghouse Software does not in any * way grant permision to use Distributed Checksum and Reputation Clearinghouse * software * * THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Rhyolite Software DCC 1.3.103-1.85 $Revision$ */ #ifndef SRVR_DEFS_H #define SRVR_DEFS_H #include "dcc_clnt.h" #include "dcc_ids.h" #include "dcc_heap_debug.h" #include "db.h" typedef int64_t SCNTR; typedef struct { struct timeval reset; SCNTR nops; /* DCC_OP_NOP packets */ SCNTR reports; /* DCC_OP_REPORT or DCC_OP_REPORT_REP */ SCNTR report_retrans; /* duplicate reports */ SCNTR report_reject; /* reports ignored by -Q */ SCNTR report10; /* reports of >10 targets */ SCNTR report100; /* reports of >100 targets */ SCNTR report1000; /* reports of >1000 targets */ SCNTR reportmany; /* reports of spam */ SCNTR queries; /* DCC_OP_QUERY */ SCNTR resp10; /* responses of >10 targets */ SCNTR resp100; /* " " >100 targets */ SCNTR resp1000; /* " " >1000 targets */ SCNTR respmany; /* " " spam */ SCNTR respwhite; /* whitelisted responses */ SCNTR bad_op; /* unknown, blacklisted, over active */ SCNTR bad_passwd; /* requests with bad passwords */ SCNTR blist; /* blacklisted requests */ SCNTR send_error; /* error responses sent */ SCNTR admin; /* DCC_OP_ADMN */ SCNTR rl; /* responses rate-limited */ SCNTR anon_rl; /* anonymous responses rate-limited */ SCNTR adds; /* reports added */ SCNTR iflod_total; /* total reports received */ SCNTR iflod_accepted; /* timely and properly signed */ SCNTR iflod_stale; SCNTR iflod_dup; SCNTR iflod_wlist; /* locally whitelisted */ SCNTR iflod_not_deleted; /* delete commands ignored */ SCNTR norep; SCNTR rep1; SCNTR rep10; SCNTR rep20; SCNTR rep30; SCNTR rep60; SCNTR report_reps; /* DCC_OP_REPORT_REP packets */ } DCCD_STATS; typedef char FLOD_EMSG[DCC_FLOD_MAX_RESP]; typedef struct { int trace_gen; /* to get at least one trace message */ u_char complained; FLOD_EMSG trace_msg; FLOD_EMSG msg; } LAST_ERROR; /* memory mapped file of flooding information * it is memory mapped so that dblist can report the state of flooding * and so dbclean can see when flooding has stopped */ #define GREY_FLOD_NM "grey_flod" #define DCCD_FLOD_NM "flod" extern DCC_PATH flod_mmap_path, flod_path; #ifndef DCCD_MAX_FLOODS #define DCCD_MAX_FLOODS 32 #endif typedef struct { /* timer and backoff for ordinary connect() */ time_t retry; int retry_secs; /* timer for complaints about missing incoming connection */ time_t msg; int msg_secs; } CONN_TIMERS; typedef u_int32_t FLOD_MMAP_FLAGS; typedef struct { char rem_hostname[DCC_MAXDOMAINLEN]; char rem_portname[MAXPORTNAMELEN+1]; u_int16_t rem_port; DCC_SOCKU rem_su; /* address for hostname */ int host_error; /* for failure to resolve hostname */ DB_PTR confirm_pos; /* confirmed sent to here */ DCC_SRVR_ID rem_id, in_passwd_id, out_passwd_id; CONN_TIMERS otimers, itimers; time_t ids_mtime; /* mtime ids file when we checked */ FLOD_MMAP_FLAGS flags; # define FLODMAP_FG_MARK 0x00000001 # define FLODMAP_FG_IN_OFF 0x00000002 # define FLODMAP_FG_OUT_OFF 0x00000004 # define FLODMAP_FG_ROGUE 0x00000008 /* evil server */ # define FLODMAP_FG_IN_CONN 0x00000010 /* input connected */ # define FLODMAP_FG_OUT_CONN 0x00000020 /* output connected */ # define FLODMAP_FG_IPv4 0x00000040 /* override IPv6 choice */ # define FLODMAP_FG_IPv6 0x00000080 /* override IPv6 choice */ # define FLODMAP_FG_PASSIVE 0x00000100 /* peer uses SOCKS */ # define FLODMAP_FG_SOCKS 0x00000200 # define FLODMAP_FG_NAT 0x00000400 /* SOCKS without library */ # define FLODMAP_FG_NAT_AUTO 0x00000800 /* assumed NAT */ # define FLODMAP_FG_ACT (FLODMAP_FG_SOCKS | FLODMAP_FG_NAT \ | FLODMAP_FG_NAT_AUTO) # define FLODMAP_FG_OUT_SRVR 0x00001000 /* connected by peer */ # define FLODMAP_FG_IN_SRVR 0x00002000 /* connected by peer */ # define FLODMAP_FG_REWINDING 0x00004000 /* answering rewind */ # define FLODMAP_FG_NEED_REWIND 0x00008000 /* database purged */ # define FLODMAP_FG_FFWD_IN 0x00010000 /* want fastforward */ # define FLODMAP_FG_USE_2PASSWD 0x00020000 # define FLODMAP_FG_LEAF 0x00040000 /* path length restricted */ # define FLODMAP_FG_MAPPED 0x00080000 /* server-IDs translated */ u_char iversion; /* incoming flood protocol */ struct { time_t cnts_cleared; time_t in_conn_changed; time_t out_conn_changed; u_int out_total_conn; /* seconds connected */ u_int in_total_conn; SCNTR out_reports; /* total reports sent */ SCNTR total; /* received */ SCNTR accepted; SCNTR stale; /* too old or in the future */ SCNTR dup; /* already received */ SCNTR wlist; /* whitelisted */ SCNTR not_deleted; /* delete commands ignored */ } cnts; LAST_ERROR oflod_err; LAST_ERROR iflod_err; } FLOD_MMAP; typedef struct { char magic[32]; # define FLOD_MMAP_MAGIC "DCC flod map version 18" char pad[32-sizeof(DB_PTR)]; DB_PTR delay_pos; /* delay flooding newer than this */ DB_SN sn; /* ensure match with database */ FLOD_MMAP mmaps[DCCD_MAX_FLOODS]; DCCD_STATS dccd_stats; } FLOD_MMAPS; extern FLOD_MMAPS *flod_mmaps; static inline void dcc_secs2ts(DCC_TS *ts, time_t secs) { u_int64_t t; t = ((u_int64_t)secs) << DCC_TS_SECS_LSHIFT; ts->b[0] = t>>40; ts->b[1] = t>>32; ts->b[2] = t>>24; ts->b[3] = t>>16; ts->b[4] = t>>8; ts->b[5] = t; } static inline void dcc_timeval2ts(DCC_TS *ts, const struct timeval *tv, int delta_secs) { u_int64_t t; t = ((u_int64_t)tv->tv_sec+delta_secs) << DCC_TS_SECS_LSHIFT; t += tv->tv_usec >> DCC_TS_US_RSHIFT; ts->b[0] = t>>40; ts->b[1] = t>>32; ts->b[2] = t>>24; ts->b[3] = t>>16; ts->b[4] = t>>8; ts->b[5] = t; } static inline void dcc_ts2timeval(struct timeval *tv, const DCC_TS *ts) { u_int64_t t = ((((u_int64_t)ts->b[0])<<40) + (((u_int64_t)ts->b[1])<<32) + (((u_int64_t)ts->b[2])<<24) + (((u_int64_t)ts->b[3])<<16) + (((u_int64_t)ts->b[4])<<8) + ts->b[5]); tv->tv_sec = t >> DCC_TS_SECS_LSHIFT; tv->tv_usec = ((t & DCC_TS_US_MASK) << DCC_TS_US_RSHIFT); } static inline int dcc_ts_newer_ts(const DCC_TS *ts1, const DCC_TS *ts2) { return memcmp(ts1, ts2, sizeof(DCC_TS)) > 0; } static inline int dcc_ts_older_ts(const DCC_TS *ts1, const DCC_TS *ts2) { return memcmp(ts1, ts2, sizeof(DCC_TS)) < 0; } #define DB_TYPE2STR(t) dcc_type2str_err(t,0,1,grey_on) /* not thread safe */ extern DCC_PATH db_path_buf; #define DB_NM2PATH_ERR(nm) fnm2abs_err(db_path_buf, nm) extern void flod_mmap_path_set(void); extern u_char flod_mmap_sync(DCC_EMSG, u_char); extern u_char flod_unmap(DCC_EMSG, const DCCD_STATS *); extern u_char flod_mmap(DCC_EMSG, const DB_SN *, const DCCD_STATS *, u_char, u_char); extern const char *flod_stats_printf(char *, int, int, int, int, int); extern const char *flodmap_fg(char *, int, const char *, const FLOD_MMAP *); extern int flod_running(const char *); extern int read_db(DCC_EMSG, void *, u_int, int, off_t, const char *); extern u_char read_db_hdr(DCC_EMSG, DB_HDR *, int fd, const char *); extern void read_rcd_invalidate(u_int); extern int read_rcd(DCC_EMSG, DB_RCD *, int, off_t, const char *); extern char *ts2str(char *, u_int, const DCC_TS *); extern const char *ts2str_err(const DCC_TS *); extern char *dcc_srvr_id2str(char *, u_int, DCC_SRVR_ID); #endif /* SRVR_DEFS_H */