From e7fc11f225307cf910ec8dc8e6a0b070bab60be2 Mon Sep 17 00:00:00 2001
From: Phil <phil@secdev.org>
Date: Tue, 10 Mar 2009 18:12:52 +0100
Subject: [PATCH] Added RandPool

---
 scapy/volatile.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/scapy/volatile.py b/scapy/volatile.py
index 9f7c03f2..c49bb2c3 100644
--- a/scapy/volatile.py
+++ b/scapy/volatile.py
@@ -507,10 +507,19 @@ class RandSingString(RandSingularity):
                          "foo.exe\\", ]
                              
 
-
-
-
-                             
+class RandPool(RandField):
+    def __init__(self, *args):
+        """Each parameter is a volatile object or a couple (volatile object, weight)"""
+        pool = []
+        for p in args:
+            w = 1
+            if type(p) is tuple:
+                p,w = p
+            pool += [p]*w
+        self._pool = pool
+    def _fix(self):
+        r = random.choice(self._pool)
+        return r._fix()
 
 # Automatic timestamp
 
-- 
GitLab