<commit_before>#include "warpcore.h"
#include "ip.h"


void iov_fill(struct w_iov *v)
{
	while (v) {
		log("%d bytes in buf %d", v->len, v->idx);
		for (uint_fast16_t l = 0; l < v->len; l++) {
			v->buf[l] = (char)(l % 0xff);
		}
		v = SLIST_NEXT(v, next);
	}
}


void iov_dump(struct w_iov *v)
{
	while (v) {
		log("%d bytes in buf %d", v->len, v->idx);
		hexdump(v->buf, v->len);
		v = SLIST_NEXT(v, next);
	}
}


int main(void)
{
#ifdef __linux__
	const char *ifname = "eth1";
#else
	const char *ifname = "em1";
#endif

	struct warpcore *w = w_init(ifname);;
	log("main process ready");

	struct w_sock *s = w_bind(w, IP_P_UDP, 7);
	w_connect(s, ip_aton("192.168.125.129"), 7);

	for (int i = 0; i < 3; i++) {
		int len = 1200;
		struct w_iov *o = w_tx_alloc(s, len);
		iov_fill(o);
		// iov_dump(o);
		w_tx(s);

		while (len > 0) {
			// run the receive loop
			log("call poll");
			if (w_poll(w) == false)
				goto done;

			// read any data
			struct w_iov *i = w_rx(s);

			// access the read data
			while (i) {
				log("%d bytes in buf %d", i->len, i->idx);
				len -= i->len;
				// hexdump(i->buf, i->len);
				i = SLIST_NEXT(i, next);
			}

			// read is done, release the iov
			w_rx_done(s);
		}
	}
done:
	w_close(s);

	// keep running
	while (w_poll(w)) {}

	log("main process exiting");
	w_cleanup(w);

	return 0;
}
<commit_msg>Make the test program do some bulk transfers<commit_after> #include <stdio.h>

#include "warpcore.h"
#include "ip.h"


void iov_fill(struct w_iov *v)
{
	while (v) {
		// log("%d bytes in buf %d", v->len, v->idx);
		for (uint16_t l = 0; l < v->len; l++) {
			v->buf[l] = (char)(l % 0xff);
		}
		v = SLIST_NEXT(v, next);
	}
}


void iov_dump(struct w_iov *v)
{
	while (v) {
		log("%d bytes in buf %d", v->len, v->idx);
		hexdump(v->buf, v->len);
		v = SLIST_NEXT(v, next);
	}
}


int main(void)
{
#ifdef __linux__
	const char *ifname = "eth1";
#else
	const char *ifname = "em1";
#endif

	struct warpcore *w = w_init(ifname);;
	log("main process ready");

	struct w_sock *s = w_bind(w, IP_P_UDP, 77);
	w_connect(s, ip_aton("192.168.125.129"), 7);


	for (long n = 1; n <= 10000; n++) {
		// TODO: figure out why 128 is too much here
		uint32_t len = 64 * (1500 - sizeof(struct eth_hdr) -
			  sizeof(struct ip_hdr) - sizeof(struct udp_hdr));
		struct w_iov *o = w_tx_alloc(s, len);
		// iov_fill(o);
		// iov_dump(o);
		w_tx(s);

#ifdef NDEBUG
		if (n % 100 == 0) {
			printf("%ld\r", n);
			fflush(stdout);
		}
#endif

		while (len > 0) {
			// run the receive loop
			if (w_poll(w) == false)
				goto done;

			// read any data
			struct w_iov *i = w_rx(s);

			// access the read data
			while (i) {
				// log("%d bytes in buf %d", i->len, i->idx);
				len -= i->len;
				// hexdump(i->buf, i->len);
				i = SLIST_NEXT(i, next);
			}

			// read is done, release the iov
			w_rx_done(s);
		}
	}
done:
	w_close(s);

#ifdef NDEBUG
	printf("\n");
#endif

	// keep running
	// while (w_poll(w)) {}

	log("main process exiting");
	w_cleanup(w);

	return 0;
}

{'fraction_non_alphanumeric': 0.1930643547849283, 'fraction_numerical': 0.02400800266755585, 'mean_word_length': 2.821656050955414, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3117086', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1318, 'n_words': 350}