Added comparators for Packet-Type and Response-Packet-Type
authoraland <aland>
Mon, 3 Mar 2003 20:58:58 +0000 (20:58 +0000)
committeraland <aland>
Mon, 3 Mar 2003 20:58:58 +0000 (20:58 +0000)
These things should really be documented somewhere..

src/main/valuepair.c

index dcca408..610e112 100644 (file)
@@ -68,7 +68,7 @@ static struct cmp *cmp;
  *     Compare 2 attributes. May call the attribute compare function.
  */
 static int paircompare(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check,
-       VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
+                      VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
 {
        int ret = -2;
        struct cmp *c;
@@ -598,6 +598,34 @@ static int expirecmp(void *instance, REQUEST *req, VALUE_PAIR *request, VALUE_PA
 }
 
 /*
+ *     Compare the request packet type.
+ */
+static int packetcmp(void *instance, REQUEST *req, VALUE_PAIR *request,
+                    VALUE_PAIR *check,
+                    VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
+{
+       if (req->packet->code == check->lvalue) {
+               return 0;
+       }
+
+       return 1;
+}
+
+/*
+ *     Compare the response packet type.
+ */
+static int responsecmp(void *instance, REQUEST *req, VALUE_PAIR *request,
+                    VALUE_PAIR *check,
+                    VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
+{
+       if (req->reply->code == check->lvalue) {
+               return 0;
+       }
+
+       return 1;
+}
+
+/*
  *     Register server-builtin special attributes.
  */
 void pair_builtincompare_init(void)
@@ -609,6 +637,8 @@ void pair_builtincompare_init(void)
        paircompare_register(PW_CURRENT_TIME, 0, timecmp, NULL);
        paircompare_register(PW_NO_SUCH_ATTRIBUTE, 0, attrcmp, NULL);
        paircompare_register(PW_EXPIRATION, 0, expirecmp, NULL);
+       paircompare_register(PW_PACKET_TYPE, 0, packetcmp, NULL);
+       paircompare_register(PW_RESPONSE_PACKET_TYPE, 0, responsecmp, NULL);
 }
 
 /*