GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.sbin/smtpd/smtpctl/../limit.c Lines: 0 63 0.0 %
Date: 2017-11-07 Branches: 0 40 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: limit.c,v 1.5 2016/06/15 19:59:03 gilles Exp $	*/
2
3
/*
4
 * Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 */
18
19
#include <sys/types.h>
20
#include <sys/queue.h>
21
#include <sys/tree.h>
22
#include <sys/socket.h>
23
24
#include <ctype.h>
25
#include <err.h>
26
#include <event.h>
27
#include <fcntl.h>
28
#include <imsg.h>
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <limits.h>
32
#include <string.h>
33
34
#include "smtpd.h"
35
#include "log.h"
36
37
void
38
limit_mta_set_defaults(struct mta_limits *limits)
39
{
40
	limits->maxconn_per_host = 10;
41
	limits->maxconn_per_route = 5;
42
	limits->maxconn_per_source = 100;
43
	limits->maxconn_per_connector = 20;
44
	limits->maxconn_per_relay = 100;
45
	limits->maxconn_per_domain = 100;
46
47
	limits->conndelay_host = 0;
48
	limits->conndelay_route = 5;
49
	limits->conndelay_source = 0;
50
	limits->conndelay_connector = 0;
51
	limits->conndelay_relay = 2;
52
	limits->conndelay_domain = 0;
53
54
	limits->discdelay_route = 3;
55
56
	limits->max_mail_per_session = 100;
57
	limits->sessdelay_transaction = 0;
58
	limits->sessdelay_keepalive = 10;
59
60
	limits->max_failures_per_session = 25;
61
62
	limits->family = AF_UNSPEC;
63
64
	limits->task_hiwat = 50;
65
	limits->task_lowat = 30;
66
	limits->task_release = 10;
67
}
68
69
int
70
limit_mta_set(struct mta_limits *limits, const char *key, int64_t value)
71
{
72
	if (!strcmp(key, "max-conn-per-host"))
73
		limits->maxconn_per_host = value;
74
	else if (!strcmp(key, "max-conn-per-route"))
75
		limits->maxconn_per_route = value;
76
	else if (!strcmp(key, "max-conn-per-source"))
77
		limits->maxconn_per_source = value;
78
	else if (!strcmp(key, "max-conn-per-connector"))
79
		limits->maxconn_per_connector = value;
80
	else if (!strcmp(key, "max-conn-per-relay"))
81
		limits->maxconn_per_relay = value;
82
	else if (!strcmp(key, "max-conn-per-domain"))
83
		limits->maxconn_per_domain = value;
84
85
	else if (!strcmp(key, "conn-delay-host"))
86
		limits->conndelay_host = value;
87
	else if (!strcmp(key, "conn-delay-route"))
88
		limits->conndelay_route = value;
89
	else if (!strcmp(key, "conn-delay-source"))
90
		limits->conndelay_source = value;
91
	else if (!strcmp(key, "conn-delay-connector"))
92
		limits->conndelay_connector = value;
93
	else if (!strcmp(key, "conn-delay-relay"))
94
		limits->conndelay_relay = value;
95
	else if (!strcmp(key, "conn-delay-domain"))
96
		limits->conndelay_domain = value;
97
98
	else if (!strcmp(key, "reconn-delay-route"))
99
		limits->discdelay_route = value;
100
101
	else if (!strcmp(key, "session-mail-max"))
102
		limits->max_mail_per_session = value;
103
	else if (!strcmp(key, "session-transaction-delay"))
104
		limits->sessdelay_transaction = value;
105
	else if (!strcmp(key, "session-keepalive"))
106
		limits->sessdelay_keepalive = value;
107
108
	else if (!strcmp(key, "max-failures-per-session"))
109
		limits->max_failures_per_session = value;
110
111
	else if (!strcmp(key, "task-hiwat"))
112
		limits->task_hiwat = value;
113
	else if (!strcmp(key, "task-lowat"))
114
		limits->task_lowat = value;
115
	else if (!strcmp(key, "task-release"))
116
		limits->task_release = value;
117
118
	else
119
		return (0);
120
121
	return (1);
122
}