]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Added PASSIVE option to paswwords.
authorPavel Machek <pavel@ucw.cz>
Mon, 31 May 1999 17:12:00 +0000 (17:12 +0000)
committerPavel Machek <pavel@ucw.cz>
Mon, 31 May 1999 17:12:00 +0000 (17:12 +0000)
nest/config.Y
nest/password.c
nest/password.h

index b0634a628ba4bf0959ed73930a3110675928d7a1..bb1328cc227dc19b5e43e73d3f5a0059da1b857f 100644 (file)
@@ -19,7 +19,7 @@ CF_DECLS
 
 CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
 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 <f> imexport
@@ -148,6 +148,7 @@ password_items:
    /* empty */ { } 
  | FROM datetime password_items { last_password_item->from = $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; }
  ;
 
index ff084b4120649b629623ad8dedd2813a86cef8e5..ce7941ea88a2e9b16aa41d745a8b84af6e0cb735 100644 (file)
 #include "nest/password.h"
 
 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;
+}
index b457495ae3f90962074c3aa4b3b52cefa7a9caa3..16f4385a176bcee2a97fbb2657d11ff4fcf31cd9 100644 (file)
@@ -8,12 +8,17 @@
 
 #ifndef PASSWORD_H
 #define PASSWORD_H
+#include "lib/timer.h"
+
 struct password_item {
   struct password_item *next;
   char *password;
   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;
+
+struct password_item *get_best_password(struct password_item *head, int flags);
+
 #endif