summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2014-10-24 10:27:21 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2014-10-24 11:07:38 +0200
commitf8fefde318c6248ad94e7b6d60155deed9ab8eed (patch)
tree4edd3eb9b152f016afc2482555fb62b04f96eeb2 /nest
parent78342404ff573e85e396f0611014b90cea9b4c0a (diff)
Refactoring of OSPF messages.
Diffstat (limited to 'nest')
-rw-r--r--nest/password.c15
-rw-r--r--nest/password.h9
2 files changed, 20 insertions, 4 deletions
diff --git a/nest/password.c b/nest/password.c
index 179939e2..21e42e0e 100644
--- a/nest/password.c
+++ b/nest/password.c
@@ -36,9 +36,18 @@ password_find(list *l, int first_fit)
return pf;
}
-void password_cpy(char *dst, char *src, int size)
+struct password_item *
+password_find_by_id(list *l, int id)
{
- bzero(dst, size);
- memcpy(dst, src, (strlen(src) < (unsigned) size ? strlen(src) : (unsigned) size));
+ struct password_item *pi;
+
+ if (!l)
+ return NULL;
+
+ WALK_LIST(pi, *l)
+ if ((pi->id == id) && (pi->accfrom <= now_real) && (now_real < pi->accto))
+ return pi;
+
+ return NULL;
}
diff --git a/nest/password.h b/nest/password.h
index 726af733..cd120d70 100644
--- a/nest/password.h
+++ b/nest/password.h
@@ -23,6 +23,13 @@ struct password_item {
extern struct password_item *last_password_item;
struct password_item *password_find(list *l, int first_fit);
-void password_cpy(char *dst, char *src, int size);
+struct password_item *password_find_by_id(list *l, int id);
+
+static inline int password_verify(struct password_item *p1, char *p2, uint size)
+{
+ char buf[size];
+ strncpy(buf, p1->password, size);
+ return !memcmp(buf, p2, size);
+}
#endif