patch-2.1.132 linux/net/bridge/br_tree.c

Next file: linux/net/core/dev.c
Previous file: linux/net/bridge/br.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.131/linux/net/bridge/br_tree.c linux/net/bridge/br_tree.c
@@ -426,3 +426,46 @@
 	return(0);
 }
 
+/* Vova Oksman: function for copy tree to the buffer */
+void sprintf_avl (char **pbuffer, struct fdb * tree, off_t *pos,
+					int* len, off_t offset, int length)
+{
+	int size;
+
+	if( 0 == *pos){
+		if(avl_br_empty == tree)
+		/* begin from the root */
+			tree = fhp;
+		*pos = *len;
+	}
+
+	if (*pos >= offset+length)
+		return;
+
+	if (tree != avl_br_empty) {
+		/* don't write the local device */
+		if(tree->port != 0){
+			size = sprintf(*pbuffer,
+				   "%02x:%02x:%02x:%02x:%02x:%02x     eth%d       %d         %d\n",
+				   tree->ula[0],tree->ula[1],tree->ula[2],
+				   tree->ula[3],tree->ula[4],tree->ula[5], 
+				   tree->port-1, tree->flags,CURRENT_TIME-tree->timer);
+
+			(*pos)+=size;
+			(*len)+=size;
+			(*pbuffer)+=size;
+		}
+		if (*pos <= offset)
+			*len=0;
+
+		if (tree->fdb_avl_left != avl_br_empty) {
+			sprintf_avl (pbuffer,tree->fdb_avl_left,pos,len,offset,length);
+		}
+		if (tree->fdb_avl_right != avl_br_empty) {
+			sprintf_avl (pbuffer,tree->fdb_avl_right,pos,len,offset,length);
+		}
+
+	}
+
+	return;
+}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov