[AF_PACKET]: annotate

Weirdness: the third argument of socket() is net-endian
here.  Oh, well - it's documented in packet(7).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Al Viro 2006-11-08 00:26:29 -08:00 committed by David S. Miller
parent 3fbd418acc
commit 0e11c91e1e
2 changed files with 14 additions and 10 deletions

View File

@ -1,17 +1,19 @@
#ifndef __LINUX_IF_PACKET_H
#define __LINUX_IF_PACKET_H
#include <linux/types.h>
struct sockaddr_pkt
{
unsigned short spkt_family;
unsigned char spkt_device[14];
unsigned short spkt_protocol;
__be16 spkt_protocol;
};
struct sockaddr_ll
{
unsigned short sll_family;
unsigned short sll_protocol;
__be16 sll_protocol;
int sll_ifindex;
unsigned short sll_hatype;
unsigned char sll_pkttype;

View File

@ -201,7 +201,7 @@ struct packet_sock {
spinlock_t bind_lock;
char running; /* prot_hook is attached*/
int ifindex; /* bound device */
unsigned short num;
__be16 num;
#ifdef CONFIG_PACKET_MULTICAST
struct packet_mclist *mclist;
#endif
@ -331,7 +331,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name;
struct sk_buff *skb;
struct net_device *dev;
unsigned short proto=0;
__be16 proto=0;
int err;
/*
@ -704,7 +704,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name;
struct sk_buff *skb;
struct net_device *dev;
unsigned short proto;
__be16 proto;
unsigned char *addr;
int ifindex, err, reserve = 0;
@ -858,7 +858,7 @@ static int packet_release(struct socket *sock)
* Attach a packet hook.
*/
static int packet_do_bind(struct sock *sk, struct net_device *dev, int protocol)
static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protocol)
{
struct packet_sock *po = pkt_sk(sk);
/*
@ -983,6 +983,7 @@ static int packet_create(struct socket *sock, int protocol)
{
struct sock *sk;
struct packet_sock *po;
__be16 proto = (__force __be16)protocol; /* weird, but documented */
int err;
if (!capable(CAP_NET_RAW))
@ -1010,7 +1011,7 @@ static int packet_create(struct socket *sock, int protocol)
po = pkt_sk(sk);
sk->sk_family = PF_PACKET;
po->num = protocol;
po->num = proto;
sk->sk_destruct = packet_sock_destruct;
atomic_inc(&packet_socks_nr);
@ -1027,8 +1028,8 @@ static int packet_create(struct socket *sock, int protocol)
#endif
po->prot_hook.af_packet_priv = sk;
if (protocol) {
po->prot_hook.type = protocol;
if (proto) {
po->prot_hook.type = proto;
dev_add_pack(&po->prot_hook);
sock_hold(sk);
po->running = 1;
@ -1624,7 +1625,8 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing
{
char **pg_vec = NULL;
struct packet_sock *po = pkt_sk(sk);
int was_running, num, order = 0;
int was_running, order = 0;
__be16 num;
int err = 0;
if (req->tp_block_nr) {