* FIONREAD Check for read packet available. * BIOCGBLEN Get buffer len [for read()]. * BIOCSETF Set read filter. * BIOCSETFNR Set read filter without resetting descriptor. * BIOCSETWF Set write filter. * BIOCFLUSH Flush read packet buffer. * BIOCPROMISC Put interface into promiscuous mode. * BIOCGDLT Get link layer type. * BIOCGETIF Get interface name. * BIOCSETIF Set
| 1351 | */ |
| 1352 | /* ARGSUSED */ |
| 1353 | static int |
| 1354 | bpfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, |
| 1355 | struct thread *td) |
| 1356 | { |
| 1357 | struct bpf_d *d; |
| 1358 | int error; |
| 1359 | |
| 1360 | error = devfs_get_cdevpriv((void **)&d); |
| 1361 | if (error != 0) |
| 1362 | return (error); |
| 1363 | |
| 1364 | /* |
| 1365 | * Refresh PID associated with this descriptor. |
| 1366 | */ |
| 1367 | BPFD_LOCK(d); |
| 1368 | BPF_PID_REFRESH(d, td); |
| 1369 | if (d->bd_state == BPF_WAITING) |
| 1370 | callout_stop(&d->bd_callout); |
| 1371 | d->bd_state = BPF_IDLE; |
| 1372 | BPFD_UNLOCK(d); |
| 1373 | |
| 1374 | if (d->bd_locked == 1) { |
| 1375 | switch (cmd) { |
| 1376 | case BIOCGBLEN: |
| 1377 | case BIOCFLUSH: |
| 1378 | case BIOCGDLT: |
| 1379 | case BIOCGDLTLIST: |
| 1380 | #ifdef COMPAT_FREEBSD32 |
| 1381 | case BIOCGDLTLIST32: |
| 1382 | #endif |
| 1383 | case BIOCGETIF: |
| 1384 | case BIOCGRTIMEOUT: |
| 1385 | #if defined(COMPAT_FREEBSD32) && defined(__amd64__) |
| 1386 | case BIOCGRTIMEOUT32: |
| 1387 | #endif |
| 1388 | case BIOCGSTATS: |
| 1389 | case BIOCVERSION: |
| 1390 | case BIOCGRSIG: |
| 1391 | case BIOCGHDRCMPLT: |
| 1392 | case BIOCSTSTAMP: |
| 1393 | case BIOCFEEDBACK: |
| 1394 | case FIONREAD: |
| 1395 | case BIOCLOCK: |
| 1396 | case BIOCSRTIMEOUT: |
| 1397 | #if defined(COMPAT_FREEBSD32) && defined(__amd64__) |
| 1398 | case BIOCSRTIMEOUT32: |
| 1399 | #endif |
| 1400 | case BIOCIMMEDIATE: |
| 1401 | case TIOCGPGRP: |
| 1402 | case BIOCROTZBUF: |
| 1403 | break; |
| 1404 | default: |
| 1405 | return (EPERM); |
| 1406 | } |
| 1407 | } |
| 1408 | #ifdef COMPAT_FREEBSD32 |
| 1409 | /* |
| 1410 | * If we see a 32-bit compat ioctl, mark the stream as 32-bit so |
nothing calls this directly
no test coverage detected