Skip to content

Commit 603978b

Browse files
some help
1 parent a08625e commit 603978b

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

forward.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ main_loop(const char *netmap_port_one, const char *netmap_port_two, int udp_port
115115
printf("zerocopy %sabled\n", zerocopy ? "en" : "dis");
116116

117117
while (!stop) {
118+
struct pollfd pfd[2];
119+
pfd[0].fd = nmd_one->fd;
120+
pfd[0].events = 0;
121+
pfd[1].fd = nmd_two->fd;
122+
pfd[1].events = 0;
123+
/* if port one has RX packets then
124+
* POLLOUT on port two else POLLIN on
125+
* port one */
126+
127+
poll(pfd, 2, 1000);
128+
129+
/* try to copy as many packets as possible
130+
* from port 1 to port 2
131+
*/
118132
}
119133

120134
nm_close(nmd_one);

sink.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,32 @@ udp_port_match(const char *buf, unsigned len, int udp_port)
5757
static int
5858
main_loop(const char *netmap_port, int udp_port)
5959
{
60+
struct nm_desc *nmd;
61+
62+
nmd = nm_open(netmap_port, NULL, 0, NULL);
63+
/* check for errors */
6064

6165
while (!stop) {
66+
int r;
67+
/* for each ring index from nmd->first_rx_ring to
68+
* nmd->last_rx_ring (included)
69+
*/
70+
/* synchronize! */
71+
ioctl(nmd->fd, NIOCRXSYNC);
72+
for (r = nmd->first_rx_ring; r <= nmd->last_rx_ring; r++) {
73+
struct netmap_ring *ring = NETMAP_RXRING(nifp, r);
74+
75+
/* for each packet from ring->head to ring->tail
76+
* (excluded) */
77+
for ( ; ring->head != ring->tail;
78+
ring->head = nm_ring_next(ring, ring->head)) {
79+
struct netmap_slot *slot = &ring->slot[ring->head];
80+
void *buf = NETMAP_BUF(ring, slot->buf_idx);
81+
/* count if match */
82+
}
83+
/* update ring->head and ring->cur */
84+
ring->cur = ring->head;
85+
}
6286
}
6387

6488

0 commit comments

Comments
 (0)