* General BPF functions. */
| 556 | * General BPF functions. |
| 557 | */ |
| 558 | static int |
| 559 | bpf_movein(struct uio *uio, int linktype, struct ifnet *ifp, struct mbuf **mp, |
| 560 | struct sockaddr *sockp, int *hdrlen, struct bpf_d *d) |
| 561 | { |
| 562 | const struct ieee80211_bpf_params *p; |
| 563 | struct ether_header *eh; |
| 564 | struct mbuf *m; |
| 565 | int error; |
| 566 | int len; |
| 567 | int hlen; |
| 568 | int slen; |
| 569 | |
| 570 | /* |
| 571 | * Build a sockaddr based on the data link layer type. |
| 572 | * We do this at this level because the ethernet header |
| 573 | * is copied directly into the data field of the sockaddr. |
| 574 | * In the case of SLIP, there is no header and the packet |
| 575 | * is forwarded as is. |
| 576 | * Also, we are careful to leave room at the front of the mbuf |
| 577 | * for the link level header. |
| 578 | */ |
| 579 | switch (linktype) { |
| 580 | case DLT_SLIP: |
| 581 | sockp->sa_family = AF_INET; |
| 582 | hlen = 0; |
| 583 | break; |
| 584 | |
| 585 | case DLT_EN10MB: |
| 586 | sockp->sa_family = AF_UNSPEC; |
| 587 | /* XXX Would MAXLINKHDR be better? */ |
| 588 | hlen = ETHER_HDR_LEN; |
| 589 | break; |
| 590 | |
| 591 | case DLT_FDDI: |
| 592 | sockp->sa_family = AF_IMPLINK; |
| 593 | hlen = 0; |
| 594 | break; |
| 595 | |
| 596 | case DLT_RAW: |
| 597 | sockp->sa_family = AF_UNSPEC; |
| 598 | hlen = 0; |
| 599 | break; |
| 600 | |
| 601 | case DLT_NULL: |
| 602 | /* |
| 603 | * null interface types require a 4 byte pseudo header which |
| 604 | * corresponds to the address family of the packet. |
| 605 | */ |
| 606 | sockp->sa_family = AF_UNSPEC; |
| 607 | hlen = 4; |
| 608 | break; |
| 609 | |
| 610 | case DLT_ATM_RFC1483: |
| 611 | /* |
| 612 | * en atm driver requires 4-byte atm pseudo header. |
| 613 | * though it isn't standard, vpi:vci needs to be |
| 614 | * specified anyway. |
| 615 | */ |