mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Added PASSIVE option to paswwords.
This commit is contained in:
parent
139ca21d05
commit
900d5470ae
@ -19,7 +19,7 @@ CF_DECLS
|
|||||||
|
|
||||||
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
|
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
|
||||||
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE)
|
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE)
|
||||||
CF_KEYWORDS(PASSWORD, FROM, TO, ID)
|
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID)
|
||||||
|
|
||||||
%type <i> idval
|
%type <i> idval
|
||||||
%type <f> imexport
|
%type <f> imexport
|
||||||
@ -148,6 +148,7 @@ password_items:
|
|||||||
/* empty */ { }
|
/* empty */ { }
|
||||||
| FROM datetime password_items { last_password_item->from = $2; }
|
| FROM datetime password_items { last_password_item->from = $2; }
|
||||||
| TO datetime password_items { last_password_item->to = $2; }
|
| TO datetime password_items { last_password_item->to = $2; }
|
||||||
|
| PASSIVE datetime password_items { last_password_item->passive = $2; }
|
||||||
| ID NUM password_items { last_password_item->id = $2; }
|
| ID NUM password_items { last_password_item->id = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -10,3 +10,31 @@
|
|||||||
#include "nest/password.h"
|
#include "nest/password.h"
|
||||||
|
|
||||||
struct password_item *last_password_item = NULL;
|
struct password_item *last_password_item = NULL;
|
||||||
|
|
||||||
|
static int
|
||||||
|
password_goodness(struct password_item *i)
|
||||||
|
{
|
||||||
|
if (i->from > now)
|
||||||
|
return 0;
|
||||||
|
if (i->to < now)
|
||||||
|
return 0;
|
||||||
|
if (i->passive < now)
|
||||||
|
return 1;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct password_item *
|
||||||
|
get_best_password(struct password_item *head, int flags)
|
||||||
|
{
|
||||||
|
int good = -1;
|
||||||
|
struct password_item *best = NULL;
|
||||||
|
|
||||||
|
while (head) {
|
||||||
|
int cur = password_goodness(head);
|
||||||
|
if (cur > good) {
|
||||||
|
good = cur;
|
||||||
|
best = head;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
@ -8,12 +8,17 @@
|
|||||||
|
|
||||||
#ifndef PASSWORD_H
|
#ifndef PASSWORD_H
|
||||||
#define PASSWORD_H
|
#define PASSWORD_H
|
||||||
|
#include "lib/timer.h"
|
||||||
|
|
||||||
struct password_item {
|
struct password_item {
|
||||||
struct password_item *next;
|
struct password_item *next;
|
||||||
char *password;
|
char *password;
|
||||||
int id;
|
int id;
|
||||||
unsigned int from, to; /* We really don't care about time before 1970 */
|
bird_clock_t from, passive, to;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct password_item *last_password_item;
|
extern struct password_item *last_password_item;
|
||||||
|
|
||||||
|
struct password_item *get_best_password(struct password_item *head, int flags);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user