<HTML ><HEAD ><TITLE >hostdb</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ "><LINK REL="HOME" TITLE="Prelude API Reference Manual" HREF="book1.html"><LINK REL="UP" TITLE="Prelude Functions used by Core And Plugins" HREF="prelude-shared-api.html"><LINK REL="PREVIOUS" TITLE="rqueue" HREF="prelude-rqueue.html"><LINK REL="NEXT" TITLE="Prelude Core functions" HREF="prelude-core.html"></HEAD ><BODY CLASS="REFENTRY" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" BGCOLOR="#000000" CELLPADDING="1" CELLSPACING="0" ><TR ><TH COLSPAN="4" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="5" >Prelude API Reference Manual</FONT ></TH ></TR ><TR ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="left" ><A HREF="prelude-rqueue.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><<< Previous Page</B ></FONT ></A ></TD ><TD WIDTH="25%" BGCOLOR="#0000C0" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="book1.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Home</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#00C000" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="prelude-shared-api.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Up</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="right" ><A HREF="prelude-core.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Next Page >>></B ></FONT ></A ></TD ></TR ></TABLE ></DIV ><H1 ><A NAME="PRELUDE-HOSTDB">hostdb</H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN596" ></A ><H2 >Name</H2 >hostdb -- Host Database, to associate persistant data with a connection.</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN599"><H2 >Synopsis</H2 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="SYNOPSIS" > struct <A HREF="prelude-hostdb.html#HOSTDB" >hostdb</A >; hostdb_t* <A HREF="prelude-hostdb.html#HOSTDB-SEARCH" >hostdb_search</A > (const struct ip *ip); hostdb_t* <A HREF="prelude-hostdb.html#HOSTDB-NEW" >hostdb_new</A > (const struct ip *ip); void <A HREF="prelude-hostdb.html#HOSTDB-DEL" >hostdb_del</A > (hostdb_t *h, unsigned int pid); int <A HREF="prelude-hostdb.html#HOSTDB-INIT" >hostdb_init</A > (void); #define <A HREF="prelude-hostdb.html#HOSTDB-GET-PLUGIN-DATA" >hostdb_get_plugin_data</A > (h, pid) #define <A HREF="prelude-hostdb.html#HOSTDB-SET-PLUGIN-DATA" >hostdb_set_plugin_data</A > (h, pid, data)</PRE ></TD ></TR ></TABLE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN614" ></A ><H2 >Description</H2 ><P >This interface permit Detection Plugins to associate data with a connection.</P ><P >Here is an exemple about how to use the hostdb database: <FONT COLOR="RED" > <P ><B >Using the Host Database</B ></P > <TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >static void handle_connection(struct ip *ipcur, void *data) { void *p; hostdb_t *hdb; hdb = hostdb_search(ipcur); if ( ! hdb ) { /* * No entry for this connection exist yet. */ hdb = hostdb_new(ipcur); if ( ! hdb ) return; hostdb_set_plugin_data(hdb, plug_id, (unsigned long) data); } else { p = hostdb_get_plugin_data(hdb, plug_id); if ( ! p ) /* * No data associated with this connection by this plugin (identified by plug_id). */ hostdb_set_plugin_data(hdb, plug_id, (unsigned long) data); } } </PRE ></TD ></TR ></TABLE ></FONT ></P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN621" ></A ><H2 >Details</H2 ><DIV CLASS="REFSECT2" ><A NAME="AEN623" ></A ><H3 ><A NAME="HOSTDB" ></A >struct hostdb</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >struct hostdb { const struct ip *ip; int key_cache; unsigned long *pdata; unsigned int refcount; struct _hostdb *prev; struct _hostdb *next; };</PRE ></TD ></TR ></TABLE ><P ></P ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN628" ></A ><H3 ><A NAME="HOSTDB-SEARCH" ></A >hostdb_search ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >hostdb_t* hostdb_search (const struct ip *ip);</PRE ></TD ></TR ></TABLE ><P >Search for a host in the database.</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN636"><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >ip</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > ip header to match.</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > a pointer on the <A HREF="prelude-hostdb.html#HOSTDB" >hostdb</A > entry if host was found or <TT CLASS="LITERAL" >NULL</TT >.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN652" ></A ><H3 ><A NAME="HOSTDB-NEW" ></A >hostdb_new ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >hostdb_t* hostdb_new (const struct ip *ip);</PRE ></TD ></TR ></TABLE ><P >Create a new hostdb entry and allocate space for plugin to associate data with this entry.</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN660"><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >ip</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > the ip header used to match this entry.</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > A new <A HREF="prelude-hostdb.html#HOSTDB" >hostdb</A > structure or <TT CLASS="LITERAL" >NULL</TT > on error.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN676" ></A ><H3 ><A NAME="HOSTDB-DEL" ></A >hostdb_del ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >void hostdb_del (hostdb_t *h, unsigned int pid);</PRE ></TD ></TR ></TABLE ><P >Delete a <A HREF="prelude-hostdb.html#HOSTDB" >hostdb</A > entry if the decreased refcount for this entry is now 0.</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN684"><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >h</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > The <A HREF="prelude-hostdb.html#HOSTDB" >hostdb</A > entry to delete.</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >pid</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > The id for the calling plugin.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN698" ></A ><H3 ><A NAME="HOSTDB-INIT" ></A >hostdb_init ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >int hostdb_init (void);</PRE ></TD ></TR ></TABLE ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN703"><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > </TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN712" ></A ><H3 ><A NAME="HOSTDB-GET-PLUGIN-DATA" ></A >hostdb_get_plugin_data()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >#define hostdb_get_plugin_data(h, pid) (h)->pdata[(pid)]</PRE ></TD ></TR ></TABLE ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN717"><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >h</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > </TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >pid</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > </TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN730" ></A ><H3 ><A NAME="HOSTDB-SET-PLUGIN-DATA" ></A >hostdb_set_plugin_data()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >#define hostdb_set_plugin_data(h, pid, data) (h)->pdata[(pid)] = (data); (h)->refcount++</PRE ></TD ></TR ></TABLE ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN735"><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >h</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > </TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >pid</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > </TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >data</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > </TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><BR CLEAR="all"><BR><TABLE WIDTH="100%" BORDER="0" BGCOLOR="#000000" CELLPADDING="1" CELLSPACING="0" ><TR ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="left" ><A HREF="prelude-rqueue.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><<< Previous Page</B ></FONT ></A ></TD ><TD WIDTH="25%" BGCOLOR="#0000C0" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="book1.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Home</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#00C000" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="prelude-shared-api.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Up</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="right" ><A HREF="prelude-core.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Next Page >>></B ></FONT ></A ></TD ></TR ><TR ><TD COLSPAN="2" ALIGN="left" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >rqueue</B ></FONT ></TD ><TD COLSPAN="2" ALIGN="right" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Prelude Core functions</B ></FONT ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >