head	1.3;
access;
symbols
	milter-greylist-4-5-13:1.3
	milter-greylist-4-5-12:1.3
	milter-greylist-4-5-11:1.3
	milter-greylist-4-5-10:1.3
	milter-greylist-4-9-10:1.3
	milter-greylist-4-5-8:1.3
	milter-greylist-4-5-9:1.3
	milter-greylist-4-5-7:1.3
	milter-greylist-4-5-6:1.3
	milter-greylist-4-5:1.3
	milter-greylist-4-5-5:1.3
	milter-greylist-4-5-4:1.3
	milter-greylist-4-5-3:1.3
	milter-greylist-4-5-2:1.3
	milter-greylist-4-5-1:1.3
	milter-greylist-4-4-3:1.3
	milter-greylist-4-4-2:1.2
	milter-greylist-4-4-1:1.2
	milter-greylist-4-4:1.2
	milter-greylist-4-4-rc1:1.2
	milter-greylist-4-4-alpha4:1.2
	milter-greylist-4-4-alpha3:1.2
	milter-greylist-4-4-alpha2:1.2
	milter-greylist-4-4-alpha1:1.2
	milter-greylist-4-2-7:1.1.2.2
	milter-greylist-4-3-9:1.2
	milter-greylist-4-2-6:1.1.2.2
	milter-gresylit-4-2-6:1.1.2.2
	milter-greylist-4-3-8:1.2
	milter-greylist-4-3-7:1.2
	milter-greylist-4-2-5:1.1.2.2
	milter-greylist-4-3-6:1.1
	milter-greylist-4-2-4:1.1.2.2
	milter-greylist-4-2-branch:1.1.0.2;
locks; strict;
comment	@ * @;


1.3
date	2013.01.19.16.01.15;	author manu;	state Exp;
branches;
next	1.2;

1.2
date	2010.04.18.04.03.56;	author manu;	state Exp;
branches;
next	1.1;

1.1
date	2010.04.12.12.04.41;	author manu;	state Exp;
branches
	1.1.2.1;
next	;

1.1.2.1
date	2010.04.12.12.04.41;	author manu;	state dead;
branches;
next	1.1.2.2;

1.1.2.2
date	2010.04.14.04.41.22;	author manu;	state Exp;
branches;
next	;


desc
@@


1.3
log
@More Solaris build fixes (Jim Klimov)
@
text
@/* $Id: ratelimit.h,v 1.2 2010/04/18 04:03:56 manu Exp $ */

/*
 * Copyright (c) 2010 Emmanuel Dreyfus
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by Emmanuel Dreyfus
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,  
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef _RATELIMIT_H_
#define _RATELIMIT_H_

#include "config.h"
#if defined(HAVE_OLD_QUEUE_H) || !defined(HAVE_SYS_QUEUE_H)
#include "queue.h"
#else 
#include <sys/queue.h>
#endif

#include <stdio.h>
#include <pthread.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include "milter-greylist.h"

enum ratelimit_type { RL_SESS, RL_RCPT, RL_DATA };

#ifndef RATELIMIT_SAMPLES
#define RATELIMIT_SAMPLES 10
#endif

struct ratelimit_conf {
        char rc_name[QSTRLEN + 1];
	enum ratelimit_type rc_type;	
	size_t rc_limit;
	time_t rc_time;
	char rc_key[QSTRLEN + 1];
	LIST_ENTRY(ratelimit_conf) rc_list;
};

struct ratelimitacct_bucket { 
	TAILQ_HEAD(, ratelimit_acct) b_ratelimitacct_head;
};    


void ratelimit_init(void);
void ratelimit_conf_add(char *, enum ratelimit_type, size_t, time_t, char *);  
void ratelimit_clear(void);
struct ratelimit_conf *ratelimit_byname(char *);
int ratelimit_validate(acl_data_t *, acl_stage_t, 
		       struct acl_param *, struct mlfi_priv *);

#endif /* _RATELIMIT_H_ */
@


1.2
log
@More ratelimits: SMTP sessions and data payloads (headers + body)
@
text
@d1 1
a1 1
/* $Id: ratelimit.h,v 1.1 2010/04/12 12:04:41 manu Exp $ */
d35 1
a35 1
#ifdef HAVE_OLD_QUEUE_H
@


1.1
log
@New rate limiting feature. Account by IP, by recipient, account by
whatever you want!
@
text
@d1 1
a1 1
/* $Id$ */
d48 4
a55 2
#include "milter-greylist.h"

d58 1
d71 1
a71 1
void ratelimit_conf_add(char *, size_t, time_t, char *);  
@


1.1.2.1
log
@file ratelimit.h was added on branch milter-greylist-4-2-branch on 2010-04-14 04:41:22 +0000
@
text
@d1 74
@


1.1.2.2
log
@New ratelimit feature
@
text
@a0 74
/* $Id$ */

/*
 * Copyright (c) 2010 Emmanuel Dreyfus
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by Emmanuel Dreyfus
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,  
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef _RATELIMIT_H_
#define _RATELIMIT_H_

#include "config.h"
#ifdef HAVE_OLD_QUEUE_H
#include "queue.h"
#else 
#include <sys/queue.h>
#endif

#include <stdio.h>
#include <pthread.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#ifndef RATELIMIT_SAMPLES
#define RATELIMIT_SAMPLES 10
#endif

#include "milter-greylist.h"

struct ratelimit_conf {
        char rc_name[QSTRLEN + 1];
	size_t rc_limit;
	time_t rc_time;
	char rc_key[QSTRLEN + 1];
	LIST_ENTRY(ratelimit_conf) rc_list;
};

struct ratelimitacct_bucket { 
	TAILQ_HEAD(, ratelimit_acct) b_ratelimitacct_head;
};    


void ratelimit_init(void);
void ratelimit_conf_add(char *, size_t, time_t, char *);  
void ratelimit_clear(void);
struct ratelimit_conf *ratelimit_byname(char *);
int ratelimit_validate(acl_data_t *, acl_stage_t, 
		       struct acl_param *, struct mlfi_priv *);

#endif /* _RATELIMIT_H_ */
@


