]> git.ipfire.org Git - thirdparty/bird.git/blob - nest/password.c
Merge remote-tracking branch 'origin/soft-int'
[thirdparty/bird.git] / nest / password.c
1 /*
2 * BIRD -- Password handling
3 *
4 * (c) 1999 Pavel Machek <pavel@ucw.cz>
5 * (c) 2004 Ondrej Filip <feela@network.cz>
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"
12 #include "lib/string.h"
13
14 struct password_item *last_password_item = NULL;
15
16 struct password_item *
17 password_find(list *l, int first_fit)
18 {
19 struct password_item *pi;
20 struct password_item *pf = NULL;
21
22 if (l)
23 {
24 WALK_LIST(pi, *l)
25 {
26 if ((pi->genfrom < now_real) && (pi->gento > now_real))
27 {
28 if (first_fit)
29 return pi;
30
31 if (!pf || pf->genfrom < pi->genfrom)
32 pf = pi;
33 }
34 }
35 }
36 return pf;
37 }
38
39 struct password_item *
40 password_find_by_id(list *l, int id)
41 {
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;
52 }
53