Windows PowerShell command on Get-command packet
MyWebUniversity

Manual Pages for UNIX Operating System command usage for man packet

Protocols packet(7P)

NAME

packet, PF_PACKET - packet interface on device level

SYNOPSIS

#include

#include

#include

packet_socket = socket(2,7,n)(PF_PACKET, int socket_type, int protocol);

DESCRIPTION

Packet sockets are used to receive or send packets at the

device driver (OSI Layer 2) level. These allow users to implement protocol modules in (1,8) user space on top of the physical layer.

The socket_type is either SOCK_RAW for raw packets including

the link (1,2) level header or SOCK_DGRAM for cooked packets

with the link (1,2) level header removed. The link (1,2)

level header information is available in (1,8) a common for-

mat in (1,8) a sockaddr_ll. protocol is the IEEE 802.3 pro-

tocol number in (1,8) network order. See the include file (1,n) for a list of allowed protocols. When protocol is set (7,n,1 builtins) to htons

(ETH_P_ALL) then all protocols are received. All incoming

packets of that protocol type is passed to the packet socket

(2,7,n) before they are passed to the protocols implemented in (1,8) the kernel.

Only process with the net_rawaccesss privilege may create

PF_PACKET sockets. Processes in the global zone may bind to

any network interface that is displayed using the command:

dladm show-link.

SOCK_RAW packets are passed to and from the device driver

without any changes in (1,8) the packet data. When receiving

a packet, the address is still parsed and passed in (1,8) a

standard sockaddr_ll address structure. When transmitting a

packet, the user supplied buffer should contain the physical

layer header. That packet is then queued unmodified to the

network driver of the interface defined by the destination address.

SunOS 5.11 Last change: 4 Oct 2010 1

Protocols packet(7P)

SOCK_DGRAM operates on a slightly higher level. The physical

header is removed before the packet is passed to the user.

Packets sent through a SOCK_DGRAM packet socket (2,7,n) get

a suitable physical layer header based on the information in

(1,8) the sockaddr_ll destination address before they are

queued.

By default, all packets of the specified protocol type are

passed to a packet socket. To only get packets from a

specific interface use bind (2,n,1 builtins)(2) specifying

an address in (1,8) a struct sockaddr_ll to bind (2,n,1

builtins) the packet socket (2,7,n) to an interface. Only

the sll_protocol and the sll_ifindex address fields are used

for purposes of binding.

The connect(3SOCKET) operation is not supported on packet

sockets. Address Types

The sockaddr_ll is a device independent physical layer

address.

struct sockaddr_ll {

unsigned short sll_family; /* Always AF_PACKET */

unsigned short sll_protocol; /* Physical layer protocol */

int sll_ifindex; /* Interface number */

unsigned short sll_hatype; /* Header type */

unsigned char sll_pkttype; /* Packet type */

unsigned char sll_halen; /* Length of address */

unsigned char sll_addr[8]; /* Physical layer address */

};

sll_protocol is the standard ethernet protocol type in (1,8)

network order as defined in (1,8) the sys/ethernet.h include file. It defaults to the socket (2,7,n)'s protocol.

sll_ifindex is the interface index of the interface.

sll_hatype is a ARP type as defined in (1,8) the

sys/ethernet.h include file. sll_pkttype contains the packet

type. Valid types are PACKET_HOST for a packet addressed to

the local host(1,5), PACKET_BROADCAST for a physical layer

broadcast packet, PACKET_MULTICAST for a packet sent to a

physical layer multicast address, PACKET_OTHERHOST for a

packet to some other host (1,5) that has been caught by a

device driver in (1,8) promiscuous mode, and PACKET_OUTGOING

for a packet originated from the local host (1,5) that is

looped back to a packet socket. These types make only sense

for receiving. sll_addr and sll_halen contain the physical

layer, for example, IEEE 802.3, address and its length. The

SunOS 5.11 Last change: 4 Oct 2010 2

Protocols packet(7P)

exact interpretation depends on the device.

When you send (2,n) packets it is enough to specify

sll_family, sll_addr, sll_halen, sll_ifindex. The other

fields should be 0. sll_hatype and sll_pkttype are set

(7,n,1 builtins) on received packets for your information.

For bind (2,n,1 builtins) only sll_protocol and sll_ifindex

are used. Socket Options

Packet sockets can be used to configure physical layer mul-

ticasting and promiscuous mode. It works by calling

setsockopt(3SOCKET) on a packet socket (2,7,n) for

SOL_PACKET and one of the options PACKET_ADD_MEMBERSHIP to

add a binding or PACKET_DROP_MEMBERSHIP to drop it. They

both expect a packet_mreq structure as argument:

struct packet_mreq

{

int mr_ifindex; /* interface index */

unsigned short mr_type; /* action */

unsigned short mr_alen; /* address length */

unsigned char mr_address[8]; /* physical layer address */

};

mr_ifindex contains the interface index for the interface

whose status should be changed. The mr_type parameter speci-

fies which action to perform. PACKET_MR_PROMISC enables

receiving all packets on a shared medium often known as

promiscuous mode, PACKET_MR_MULTICAST binds the socket

(2,7,n) to the physical layer multicast group specified in

(1,8) mr_address and mr_alen. PACKET_MR_ALLMULTI sets the

socket (2,7,n) up to receive all multicast packets arriving

at the interface. In addition the traditional ioctls, SIOCSIFFLAGS,

SIOCADDMULTI, and SIOCDELMULTI can be used for the same pur-

pose.

SEE ALSO

connect(3SOCKET), setsockopt(3SOCKET) NOTES For portable programs it is suggested to usepcap(3C) instead

of PF_PACKET; although this only covers a subset of the

PF_PACKET features.

SunOS 5.11 Last change: 4 Oct 2010 3

Protocols packet(7P)

The SOCK_DGRAM packet sockets make no attempt to create or

parse the IEEE 802.2 LLC header for a IEEE 802.3 frame. When

ETH_P_802_3 is specified as protocol for sending the kernel

creates the 802.3 frame and fills out the length field; the user has to supply the LLC header to get a fully conforming

packet. Incoming 802.3 packets are not multiplexed on the

DSAP/SSAP protocol fields; instead they are supplied to the

user as protocol ETH_P_802_2 with the LLC header prepended.

It is therefore not possible to bind (2,n,1 builtins) to

ETH_P_802_3; bind (2,n,1 builtins) to ETH_P_802_2 instead

and do the protocol multiplex yourself. The default for sending is the standard Ethernet DIX encapsulation with the protocol filled in. Packet sockets are not subject to the input or output firewall chains.

SunOS 5.11 Last change: 4 Oct 2010 4




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™