Bug 176645

Summary: The example in netmap.4 is wrong
Product: Documentation Reporter: mirnshi <mirnshi>
Component: Books & ArticlesAssignee: freebsd-doc (Nobody) <doc>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: bcr
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description mirnshi 2013-03-04 18:40:01 UTC
The example in man page netmap is wrong. Struct netmap_request can not be found, 'buf_index' is not a member of struct netmap_ring, etc.

     #include <net/netmap.h>
     #include <net/netmap_user.h>
     struct netmap_if *nifp;
     struct netmap_ring *ring;
     struct netmap_request nmr;

     fd = open("/dev/netmap", O_RDWR);
     bzero(&nmr, sizeof(nmr));
     strcpy(nmr.nm_name, "ix0");
     ioctl(fd, NIOCREG, &nmr);
     p = mmap(0, nmr.memsize, fd);
     nifp = NETMAP_IF(p, nmr.offset);
     ring = NETMAP_TXRING(nifp, 0);
     fds.fd = fd;
     fds.events = POLLOUT;
     for (;;) {
         poll(list, 1, -1);
         while (ring->avail-- > 0) {
             i = ring->cur;
             buf = NETMAP_BUF(ring, ring->slot[i].buf_index);
             ... prepare packet in buf ...
             ring->slot[i].len = ... packet length ...
             ring->cur = NETMAP_RING_NEXT(ring, i);
         }
     }

Fix: 

delete this example from the man page or copy from http://info.iet.unipi.it/~luigi/netmap/.
How-To-Repeat: man netmap
Comment 1 Benedict Reuschling freebsd_committer freebsd_triage 2017-08-04 22:02:12 UTC
The netmap man page was updated and the examples were also changed. I'll close this PR, but thanks for submitting it.