1 /* 2 * aprsc 3 * 4 * (c) Matti Aarnio, OH2MQK, <oh2mqk@sral.fi> 5 * 6 * This program is licensed under the BSD license, which can be found 7 * in the file LICENSE. 8 * 9 */ 10 11 12 13 /* 14 * The historydb contains positional packet data in form of: 15 * - position packet 16 * - objects 17 * - items 18 * Keying varies, origination callsign of positions, name 19 * for object/item. 20 * 21 * Uses RW-locking, W for inserts/cleanups, R for lookups. 22 * 23 * Inserting does incidential cleanup scanning while traversing 24 * hash chains. 25 * 26 * In APRS-IS there are about 25 000 distinct callsigns or 27 * item or object names with position information PER WEEK. 28 * DB lifetime of 48 hours cuts that down a bit more. 29 * Memory usage is around 3-4 MB 30 */ 31 32 #ifndef __HISTORYDB_H__ 33 #define __HISTORYDB_H__ 34 35 #include "cellmalloc.h" 36 37 struct history_cell_t { 38 struct history_cell_t *next; 39 40 time_t arrivaltime; 41 int keylen; 42 char key[CALLSIGNLEN_MAX+2]; 43 uint32_t hash1; 44 45 float lat, coslat, lon; 46 47 int packettype; 48 int flags; 49 }; 50 51 #define HISTORYDB_CELL_SIZE sizeof(struct history_cell_t) 52 53 extern long historydb_inserts; 54 extern long historydb_lookups; 55 extern long historydb_hashmatches; 56 extern long historydb_keymatches; 57 extern long historydb_cellgauge; 58 extern long historydb_noposcount; 59 extern long historydb_cleanup_cleaned; 60 61 extern void historydb_init(void); 62 63 extern int historydb_dump(FILE *fp); 64 extern int historydb_load(FILE *fp); 65 66 extern void historydb_cleanup(void); 67 extern void historydb_atend(void); 68 69 /* insert and lookup... interface yet unspecified */ 70 extern int historydb_insert(struct pbuf_t*); 71 extern int historydb_lookup(const char *keybuf, const int keylen, struct history_cell_t **result); 72 73 /* cellmalloc status */ 74 #ifndef _FOR_VALGRIND_ 75 extern void historydb_cell_stats(struct cellstatus_t *cellst); 76 #endif 77 78 #endif 79