2 * Copyright (C) 2009, 2010 Daniel Borkmann <daniel@netsniff-ng.org> and
3 * Emmanuel Roullit <emmanuel@netsniff-ng.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
20 #ifndef _NET_RXTX_COMMON_H_
21 #define _NET_RXTX_COMMON_H_
35 # define POLLRDNORM 0x0040
38 # define POLLWRNORM 0x0100
44 * prepare_polling - Sets params for ringbuff polling
46 * @pfd: file descriptor for polling
48 static inline void prepare_polling(int sock
, struct pollfd
*pfd
)
52 memset(pfd
, 0, sizeof(*pfd
));
56 pfd
->events
= POLLIN
| POLLRDNORM
| POLLOUT
| POLLWRNORM
| POLLERR
;
60 * alloc_frame_buffer - Allocates frame buffer
61 * @rb: ring buff struct
63 static inline void alloc_frame_buffer(struct ring_buff
*rb
)
69 rb
->frames
= xzmalloc(rb
->layout
.tp_frame_nr
* sizeof(*rb
->frames
));
71 for (i
= 0; i
< rb
->layout
.tp_frame_nr
; ++i
) {
72 rb
->frames
[i
].iov_base
= (uint8_t *) ((long)rb
->buffer
) +
73 (i
* rb
->layout
.tp_frame_size
);
74 rb
->frames
[i
].iov_len
= rb
->layout
.tp_frame_size
;
78 #endif /* _NET_RXTX_COMMON_H_ */