Skip to content

Commit

Permalink
udp_proxy: support dropping a packet of a specific size
Browse files Browse the repository at this point in the history
  • Loading branch information
rizlik authored and julek-wolfssl committed Oct 7, 2022
1 parent 6bcbd42 commit 244c5ac
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion udp_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ int serverLen = sizeof(server); /* server address len */
int dropPacket = 0; /* dropping packet interval */
int delayPacket = 0; /* delay packet interval */
int dropNth = 0;
int dropBySize = 0; /* drop first packet of specific size */
int dropSize = 0; /* specific size to drop */
int dropPacketNo = 0;
int dropSpecific = 0; /* specific seq to drop in epoch */
int dropSpecificSeq = 0; /* specific seq to drop */
Expand Down Expand Up @@ -577,6 +579,12 @@ static void Msg(evutil_socket_t fd, short which, void* arg)
return;
}

if (dropBySize && ret == dropSize) {
LOG("*** but dropping the %d packet of size %d\n", msgCount, ret);
dropBySize = 0;
return;
}

/* should we delay the current packet */
if (delayPacket && (msgCount % delayPacket) == 0) {
LOG("*** but delaying this packet\n");
Expand Down Expand Up @@ -773,6 +781,7 @@ static void Usage(void)
printf("-l <log file> Use the provided argument as the log file\n");
printf("-t <delays> Comma seperated list of delays for each \n"
" subsequent packet in seconds.\n");
printf("-F <size> Drop first packet of <size> bytes\n");
}


Expand All @@ -786,7 +795,7 @@ int main(int argc, char** argv)

setlocale(LC_ALL, ""); /* Make portable */

while ( (ch = GetOpt(argc, argv, "?Dap:s:d:y:x:b:R:S:r:f:ul:t:")) != -1) {
while ( (ch = GetOpt(argc, argv, "?Dap:s:d:y:x:b:R:S:r:f:ul:t:F:")) != -1) {
switch (ch) {
case '?' :
Usage();
Expand Down Expand Up @@ -878,6 +887,11 @@ int main(int argc, char** argv)
dropPacketNo = atoi(myoptarg);
break;

case 'F':
dropBySize = 1;
dropSize = atoi(myoptarg);
break;

case 'u':
isDtls13 = 1;
break;
Expand Down

0 comments on commit 244c5ac

Please sign in to comment.