]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Better progdocs for filters
authorPavel Machek <pavel@ucw.cz>
Wed, 7 Jun 2000 13:54:06 +0000 (13:54 +0000)
committerPavel Machek <pavel@ucw.cz>
Wed, 7 Jun 2000 13:54:06 +0000 (13:54 +0000)
filter/Doc
filter/filter.c
filter/tree.c

index 407a44ba01789b50b0387ba007c0c41a0fbba335..a21b6fab1f9d6d6f21113d0d6bea8f500f84c0aa 100644 (file)
@@ -1,2 +1,3 @@
 H Filters
-S filter.c
\ No newline at end of file
+S filter.c
+S tree.c
\ No newline at end of file
index b4e01056eda4c7a33fd555275e55914c26941377..540ce1323be5b2484b317f6fea0bc47e94719349 100644 (file)
@@ -260,6 +260,16 @@ rta_cow(void)
  *
  * Interpret given tree of filter instructions. This is core function
  * of filter system and does all the hard work.
+ *
+ * Each instruction has 4 fields: code (which is instruction code),
+ * aux (which is extension to instruction code, typically type),
+ * arg1 and arg2 - arguments. Depending on instruction, arguments
+ * are either integers, or pointers to instruction trees. Common 
+ * instructions like +, that have two expressions as arguments use
+ * TWOARGS macro to get both of them evaluated.
+ *
+ * &f_val structures are copied around, so there are no problems with
+ * memory managment.
  */
 static struct f_val
 interpret(struct f_inst *what)
index 1d329695ea3b986ab413a189e69493ee2cd1c25e..56b3209c273018fb3e1c20a3166b34e48d1cd92a 100644 (file)
@@ -10,7 +10,9 @@
 #include "conf/conf.h"
 #include "filter/filter.h"
 
-/* Finds n-th item in list linked by right. Trashes pointers in right. */
+/*
+ * find_nth - finds n-th element in linked list. Don't be confused by tree structures.
+ */
 static struct f_tree *
 find_nth(struct f_tree *from, int nth)
 {
@@ -41,7 +43,9 @@ find_nth(struct f_tree *from, int nth)
   return find_nth(left, nth);
 }
 
-/* Gets list linked by left, finds its median, trashes pointers in right */
+/*
+ * Gets list linked by left, finds its median, trashes pointers in right */
+ */
 static struct f_tree *
 find_median(struct f_tree *from)
 {
@@ -57,6 +61,15 @@ find_median(struct f_tree *from)
   return find_nth(from, cnt/2);
 }
 
+/**
+ * find_tree
+ * @t: tree to search in
+ * @val: value to find
+ *
+ * Search for given value in the tree. I relies on fact that sorted tree is populated
+ * by &f_val structures (that can be compared by val_compare()). In each node of tree, 
+ * either single value (then t->from==t->to) or range is present.
+ */
 struct f_tree *
 find_tree(struct f_tree *t, struct f_val val)
 {
@@ -71,7 +84,12 @@ find_tree(struct f_tree *t, struct f_val val)
     return find_tree(t->left, val);
 }
 
-/* Gets list linked by left */
+/**
+ * build_tree
+ * @from: degenerated tree (linked by tree->left) to be transformed into form suitable for find_tree()
+ *
+ * Transforms denerated tree into balanced tree.
+ */
 struct f_tree *
 build_tree(struct f_tree *from)
 {