57 static const int drop_freq[] = { 500, 100, 50 };
62 static const int corrupt_freq[] = { 500, 100, 50 };
68 static const int up_low[] = { 60, 10, 5 };
69 static const int up_high[] = { 600, 60, 10 };
75 static const int down_low[] = { 5, 10, 10 };
76 static const int down_high[] = { 10, 60, 120 };
82 static const struct packet_flood_parms packet_flood_data[] =
83 {{10, 100}, {10, 1500}, {100, 1500}};
85 struct packet_flood_parms
86 get_packet_flood_parms(int level)
88 ASSERT(level > 0 && level < 4);
89 return packet_flood_data [level - 1];
106 roll(
int low,
int high)
110 ret = low + (
get_random() % (high - low + 1));
111 ASSERT(ret >= low && ret <= high);
115 static bool initialized;
123 ask_gremlin(
int flags)
125 const int up_down_level = GREMLIN_UP_DOWN_LEVEL(flags);
126 const int drop_level = GREMLIN_DROP_LEVEL(flags);
151 delta = roll(down_low[up_down_level-1], down_high[up_down_level-1]);
156 delta = roll(up_low[up_down_level-1], up_high[up_down_level-1]);
161 "GREMLIN: CONNECTION GOING %s FOR %d SECONDS",
162 (up ?
"UP" :
"DOWN"),
170 if (up && flip(drop_freq[drop_level-1]))
184 corrupt_gremlin(
struct buffer *buf,
int flags)
186 const int corrupt_level = GREMLIN_CORRUPT_LEVEL(flags);
189 if (flip(corrupt_freq[corrupt_level-1]))
195 uint8_t r = roll(0, 255);
196 int method = roll(0, 5);
205 *(
BPTR(buf) + buf->
len - 1) = r;
209 *(
BPTR(buf) + roll(0, buf->
len - 1)) = r;
221 buf->
len -= roll(0, buf->
len - 1);