]> git.ipfire.org Git - thirdparty/bird.git/blame - nest/password.c
Filter: Expand testing of large community sets
[thirdparty/bird.git] / nest / password.c
CommitLineData
1a2ded45
PM
1/*
2 * BIRD -- Password handling
3 *
5236fb03
OF
4 * (c) 1999 Pavel Machek <pavel@ucw.cz>
5 * (c) 2004 Ondrej Filip <feela@network.cz>
1a2ded45
PM
6 *
7 * Can be freely distributed and used under the terms of the GNU GPL.
8 */
9
10#include "nest/bird.h"
11#include "nest/password.h"
7d875e09 12#include "lib/string.h"
1a2ded45
PM
13
14struct password_item *last_password_item = NULL;
900d5470 15
900d5470 16struct password_item *
b21f68b4 17password_find(list *l, int first_fit)
900d5470 18{
5236fb03 19 struct password_item *pi;
b21f68b4 20 struct password_item *pf = NULL;
900d5470 21
02ad2737 22 if (l)
5236fb03 23 {
02ad2737
OF
24 WALK_LIST(pi, *l)
25 {
fd91ae33 26 if ((pi->genfrom < now_real) && (pi->gento > now_real))
b21f68b4
OZ
27 {
28 if (first_fit)
29 return pi;
30
31 if (!pf || pf->genfrom < pi->genfrom)
32 pf = pi;
33 }
02ad2737 34 }
900d5470 35 }
b21f68b4 36 return pf;
900d5470 37}
2e6197d6 38
f8fefde3
OZ
39struct password_item *
40password_find_by_id(list *l, int id)
2e6197d6 41{
f8fefde3
OZ
42 struct password_item *pi;
43
44 if (!l)
45 return NULL;
46
47 WALK_LIST(pi, *l)
48 if ((pi->id == id) && (pi->accfrom <= now_real) && (now_real < pi->accto))
49 return pi;
50
51 return NULL;
2e6197d6
PM
52}
53
8465dccb
OZ
54struct password_item *
55password_find_by_value(list *l, char *pass, uint size)
56{
57 struct password_item *pi;
58
59 if (!l)
60 return NULL;
61
62 WALK_LIST(pi, *l)
63 if (password_verify(pi, pass, size) && (pi->accfrom <= now_real) && (now_real < pi->accto))
64 return pi;
65
66 return NULL;
67}
68