Back to index

opendkim  2.6.4
Defines | Typedefs | Functions | Variables
repute.h File Reference
#include <sys/param.h>
#include <sys/types.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define FALSE   0
#define TRUE   1
#define REPUTE_STAT_UNKNOWN   (-1) /* unknown status */
#define REPUTE_STAT_OK   0 /* successful completion */
#define REPUTE_STAT_INTERNAL   1 /* internal error */
#define REPUTE_STAT_PARSE   2 /* parse failure */
#define REPUTE_STAT_QUERY   3 /* query failure */
#define REPUTE_CACHE   86400 /* XXX -- make this configurable */
#define REPUTE_NAME_REPUTATION   "reputation"
#define REPUTE_NAME_REPUTON   "reputon"
#define REPUTE_URI_APPLICATION   "email-id"
#define REPUTE_URI_SCHEME   "http"
#define REPUTE_URI_TEMPLATE   "{scheme}://{service}/.well-known/repute-template"
#define REPUTE_XML_CODE_UNKNOWN   (-1)
#define REPUTE_XML_CODE_ASSERTION   0
#define REPUTE_XML_CODE_EXTENSION   1
#define REPUTE_XML_CODE_RATED   2
#define REPUTE_XML_CODE_RATER   3
#define REPUTE_XML_CODE_RATER_AUTH   4
#define REPUTE_XML_CODE_RATING   5
#define REPUTE_XML_CODE_SAMPLE_SIZE   6
#define REPUTE_XML_CODE_UPDATED   7
#define REPUTE_XML_ASSERTION   "assertion"
#define REPUTE_XML_EXTENSION   "extension"
#define REPUTE_XML_RATED   "rated"
#define REPUTE_XML_RATER   "rater"
#define REPUTE_XML_RATER_AUTH   "rater-authenticity"
#define REPUTE_XML_RATING   "rating"
#define REPUTE_XML_SAMPLE_SIZE   "sample-size"
#define REPUTE_XML_UPDATED   "updated"
#define REPUTE_ASSERT_SPAM   "spam"
#define REPUTE_EXT_ID_BOTH   "IDENTITY: DKIM"
#define REPUTE_EXT_RATE_COLON   "RATE:"
#define REPUTE_EXT_ID   "IDENTITY"
#define REPUTE_EXT_ID_DKIM   "DKIM"
#define REPUTE_EXT_RATE   "RATE"

Typedefs

typedef int REPUTE_STAT
typedef struct repute_handleREPUTE

Functions

void repute_close (REPUTE)
const char * repute_curlversion (REPUTE)
const char * repute_error (REPUTE)
void repute_init (void)
REPUTE repute_new (const char *, unsigned int)
REPUTE_STAT repute_query (REPUTE, const char *, float *, float *, unsigned long *, unsigned long *, time_t *)
void repute_useragent (REPUTE, const char *)

Variables

static char repute_h_id [] = "$Id$"

Define Documentation

#define FALSE   0

Definition at line 18 of file repute.h.

#define REPUTE_ASSERT_SPAM   "spam"

Definition at line 62 of file repute.h.

#define REPUTE_CACHE   86400 /* XXX -- make this configurable */

Definition at line 31 of file repute.h.

#define REPUTE_EXT_ID   "IDENTITY"

Definition at line 67 of file repute.h.

#define REPUTE_EXT_ID_BOTH   "IDENTITY: DKIM"

Definition at line 64 of file repute.h.

#define REPUTE_EXT_ID_DKIM   "DKIM"

Definition at line 68 of file repute.h.

#define REPUTE_EXT_RATE   "RATE"

Definition at line 69 of file repute.h.

#define REPUTE_EXT_RATE_COLON   "RATE:"

Definition at line 65 of file repute.h.

#define REPUTE_NAME_REPUTATION   "reputation"

Definition at line 36 of file repute.h.

#define REPUTE_NAME_REPUTON   "reputon"

Definition at line 37 of file repute.h.

#define REPUTE_STAT_INTERNAL   1 /* internal error */

Definition at line 27 of file repute.h.

#define REPUTE_STAT_OK   0 /* successful completion */

Definition at line 26 of file repute.h.

#define REPUTE_STAT_PARSE   2 /* parse failure */

Definition at line 28 of file repute.h.

#define REPUTE_STAT_QUERY   3 /* query failure */

Definition at line 29 of file repute.h.

#define REPUTE_STAT_UNKNOWN   (-1) /* unknown status */

Definition at line 25 of file repute.h.

#define REPUTE_URI_APPLICATION   "email-id"

Definition at line 39 of file repute.h.

#define REPUTE_URI_SCHEME   "http"

Definition at line 40 of file repute.h.

#define REPUTE_URI_TEMPLATE   "{scheme}://{service}/.well-known/repute-template"

Definition at line 41 of file repute.h.

#define REPUTE_XML_ASSERTION   "assertion"

Definition at line 53 of file repute.h.

#define REPUTE_XML_CODE_ASSERTION   0

Definition at line 44 of file repute.h.

#define REPUTE_XML_CODE_EXTENSION   1

Definition at line 45 of file repute.h.

#define REPUTE_XML_CODE_RATED   2

Definition at line 46 of file repute.h.

#define REPUTE_XML_CODE_RATER   3

Definition at line 47 of file repute.h.

Definition at line 48 of file repute.h.

#define REPUTE_XML_CODE_RATING   5

Definition at line 49 of file repute.h.

Definition at line 50 of file repute.h.

#define REPUTE_XML_CODE_UNKNOWN   (-1)

Definition at line 43 of file repute.h.

#define REPUTE_XML_CODE_UPDATED   7

Definition at line 51 of file repute.h.

#define REPUTE_XML_EXTENSION   "extension"

Definition at line 54 of file repute.h.

#define REPUTE_XML_RATED   "rated"

Definition at line 55 of file repute.h.

#define REPUTE_XML_RATER   "rater"

Definition at line 56 of file repute.h.

#define REPUTE_XML_RATER_AUTH   "rater-authenticity"

Definition at line 57 of file repute.h.

#define REPUTE_XML_RATING   "rating"

Definition at line 58 of file repute.h.

#define REPUTE_XML_SAMPLE_SIZE   "sample-size"

Definition at line 59 of file repute.h.

#define REPUTE_XML_UPDATED   "updated"

Definition at line 60 of file repute.h.

#define TRUE   1

Definition at line 21 of file repute.h.


Typedef Documentation

typedef struct repute_handle* REPUTE

Definition at line 73 of file repute.h.

typedef int REPUTE_STAT

Definition at line 33 of file repute.h.


Function Documentation

void repute_close ( REPUTE  )

Definition at line 826 of file repute.c.

{
       struct repute_io *rio;
       struct repute_io *next;

       assert(rep != NULL);

       rio = rep->rep_ios;
       while (rio != NULL)
       {
              next = rio->repute_next;

              if (rio->repute_buf != NULL)
                     free(rio->repute_buf);
              if (rio->repute_curl != NULL)
                     curl_easy_cleanup(rio->repute_curl);
              free(rio);

              rio = next;
       }

       pthread_mutex_destroy(&rep->rep_lock);

       free((void *) rep->rep_server);

       free(rep);
}

Here is the caller graph for this function:

const char* repute_curlversion ( REPUTE  )

Definition at line 865 of file repute.c.

{
       assert(rep != NULL);

       return rep->rep_curlversion;
}

Here is the caller graph for this function:

const char* repute_error ( REPUTE  )

Definition at line 1026 of file repute.c.

{
       assert(rep != NULL);

       return rep->rep_error;
}

Here is the caller graph for this function:

void repute_init ( void  )

Definition at line 764 of file repute.c.

{
#ifdef USE_XML2
       xmlInitParser();
#endif /* USE_XML2 */

       curl_global_init(CURL_GLOBAL_ALL);
}

Here is the caller graph for this function:

REPUTE repute_new ( const char *  ,
unsigned  int 
)

Definition at line 785 of file repute.c.

{
       struct repute_handle *new;
       curl_version_info_data *vinfo;

       assert(server != NULL);

       new = malloc(sizeof *new);
       if (new == NULL)
              return NULL;

       memset(new, '\0', sizeof *new);

       new->rep_reporter = reporter;
       new->rep_server = strdup(server);
       if (new->rep_server == NULL)
       {
              free(new);
              return NULL;
       }

       vinfo = curl_version_info(CURLVERSION_NOW);
       if (vinfo != NULL && vinfo->version != NULL)
              new->rep_curlversion = strdup(vinfo->version);

       pthread_mutex_init(&new->rep_lock, NULL);

       return new;
}

Here is the caller graph for this function:

REPUTE_STAT repute_query ( REPUTE  ,
const char *  ,
float *  ,
float *  ,
unsigned long *  ,
unsigned long *  ,
time_t *   
)

Definition at line 909 of file repute.c.

{
       REPUTE_STAT status;
       float conf;
       float reputation;
       unsigned long samples;
       unsigned long limit;
       time_t when;
       struct repute_io *rio;
       URITEMP ut;
       char genurl[REPUTE_URL];
       char template[REPUTE_URL];

       assert(rep != NULL);
       assert(domain != NULL);
       assert(repout != NULL);

       if (rep->rep_uritemp[0] == '\0')
       {
              if (repute_get_template(rep) != REPUTE_STAT_OK)
                     return REPUTE_STAT_QUERY;
       }

       ut = ut_init();
       if (ut == NULL)
              return REPUTE_STAT_INTERNAL;

       if (rep->rep_reporter != 0)
       {
              snprintf(genurl, sizeof genurl, "%u", rep->rep_reporter);
              if (ut_keyvalue(ut, UT_KEYTYPE_STRING,
                              "reporter", genurl) != 0)
              {
                     ut_destroy(ut);
                     return REPUTE_STAT_INTERNAL;
              }
       }

       if (ut_keyvalue(ut, UT_KEYTYPE_STRING,
                       "subject", (void *) domain) != 0 ||
#ifdef USE_JANSSON
           ut_keyvalue(ut, UT_KEYTYPE_STRING, "format", "json") != 0 ||
#endif /* USE_JANSSON */
#ifdef USE_XML2
           ut_keyvalue(ut, UT_KEYTYPE_STRING, "format", "xml") != 0 ||
#endif /* USE_XML2 */
           ut_keyvalue(ut, UT_KEYTYPE_STRING,
                       "scheme", REPUTE_URI_SCHEME) != 0 ||
           ut_keyvalue(ut, UT_KEYTYPE_STRING,
                       "service", (void *) rep->rep_server) != 0 ||
           ut_keyvalue(ut, UT_KEYTYPE_STRING,
                       "application", REPUTE_URI_APPLICATION) != 0 ||
           ut_keyvalue(ut, UT_KEYTYPE_STRING,
                       "assertion", REPUTE_ASSERT_SPAM) != 0)
       {
              ut_destroy(ut);
              return REPUTE_STAT_INTERNAL;
       }

       if (ut_generate(ut, rep->rep_uritemp, genurl, sizeof genurl) <= 0)
       {
              ut_destroy(ut);
              return REPUTE_STAT_INTERNAL;
       }

       ut_destroy(ut);

       rio = repute_get_io(rep);
       if (rio == NULL)
              return REPUTE_STAT_INTERNAL;

       status = repute_doquery(rio, genurl);
       if (status != REPUTE_STAT_OK)
       {
              repute_get_error(rio, rep->rep_error, sizeof rep->rep_error);
              repute_put_io(rep, rio);
              return status;
       }

       status = repute_parse(rio->repute_buf, rio->repute_offset,
                             &reputation, &conf, &samples, &limit, &when);
       if (status != REPUTE_STAT_OK)
       {
              snprintf(rep->rep_error, sizeof rep->rep_error,
                       "error parsing reply");
              repute_put_io(rep, rio);
              return status;
       }

       *repout = reputation;
       if (confout != NULL)
              *confout = conf;
       if (sampout != NULL)
              *sampout = samples;
       if (whenout != NULL)
              *whenout = when;
       if (limitout != NULL)
              *limitout = limit;

       repute_put_io(rep, rio);

       return REPUTE_STAT_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void repute_useragent ( REPUTE  ,
const char *   
)

Definition at line 884 of file repute.c.

{
       if (rep->rep_useragent != NULL)
              free((void *) rep->rep_useragent);

       rep->rep_useragent = strdup(ua);
}

Here is the caller graph for this function:


Variable Documentation

char repute_h_id[] = "$Id$" [static]

Definition at line 6 of file repute.h.