Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111967
b: refs/heads/master
c: 3bb91bf
h: refs/heads/master
i:
  111965: 87bcbec
  111963: df36de0
  111959: f7e8dd6
  111951: f642eb7
  111935: 625964b
v: v3
  • Loading branch information
Larry Finger authored and John W. Linville committed Sep 30, 2008
1 parent 7256604 commit fefb983
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 66 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6e50e8a2136f1a90de251c653226ded447c5c915
refs/heads/master: 3bb91bff8165223aa14f015a6c9150a536b40d9b
32 changes: 11 additions & 21 deletions trunk/Documentation/networking/phonet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ depending on the device, such as:
Packets format
--------------

Phonet packets have a common header as follows:
Phonet packet have a common header as follow:

struct phonethdr {
uint8_t pn_media; /* Media type (link-layer identifier) */
Expand All @@ -33,17 +33,14 @@ Phonet packets have a common header as follows:
uint8_t pn_sobj; /* Sender object ID */
};

On Linux, the link-layer header includes the pn_media byte (see below).
The next 7 bytes are part of the network-layer header.

The device ID is split: the 6 higher-order bits consitute the device
address, while the 2 lower-order bits are used for multiplexing, as are
the 8-bit object identifiers. As such, Phonet can be considered as a
The device ID is split: the 6 higher order bits consitutes the device
address, while the 2 lower order bits are used for multiplexing, as are
the 8-bits object identifiers. As such, Phonet can be considered as a
network layer with 6 bits of address space and 10 bits for transport
protocol (much like port numbers in IP world).

The modem always has address number zero. All other device have a their
own 6-bit address.
The modem always has address number zero. Each other device has a its
own 6-bits address.


Link layer
Expand All @@ -52,18 +49,11 @@ Link layer
Phonet links are always point-to-point links. The link layer header
consists of a single Phonet media type byte. It uniquely identifies the
link through which the packet is transmitted, from the modem's
perspective. Each Phonet network device shall prepend and set the media
type byte as appropriate. For convenience, a common phonet_header_ops
link-layer header operations structure is provided. It sets the
media type according to the network device hardware address.

Linux Phonet network interfaces support a dedicated link layer packets
type (ETH_P_PHONET) which is out of the Ethernet type range. They can
only send and receive Phonet packets.

The virtual TUN tunnel device driver can also be used for Phonet. This
requires IFF_TUN mode, _without_ the IFF_NO_PI flag. In this case,
there is no link-layer header, so there is no Phonet media type byte.
perspective.

Linux Phonet network interfaces use a dedicated link layer type
(ETH_P_PHONET) which is out of the Ethernet type range. They can only
send and receive Phonet packets.

Note that Phonet interfaces are not allowed to re-order packets, so
only the (default) Linux FIFO qdisc should be used with them.
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/net/wireless/b43/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4545,7 +4545,8 @@ static void b43_sprom_fixup(struct ssb_bus *bus)
IS_PDEV(pdev, BROADCOM, 0x4320, DELL, 0x0003) ||
IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0015) ||
IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0014) ||
IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0013))
IS_PDEV(pdev, BROADCOM, 0x4320, LINKSYS, 0x0013) ||
IS_PDEV(pdev, BROADCOM, 0x4320, MOTOROLA, 0x7010))
bus->sprom.boardflags_lo &= ~B43_BFL_BTCOEXIST;
}
}
Expand Down
2 changes: 0 additions & 2 deletions trunk/include/linux/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ header-y += pci_regs.h
header-y += pfkeyv2.h
header-y += pg.h
header-y += phantom.h
header-y += phonet.h
header-y += pkt_cls.h
header-y += pkt_sched.h
header-y += posix_types.h
Expand Down Expand Up @@ -233,7 +232,6 @@ unifdef-y += if_fddi.h
unifdef-y += if_frad.h
unifdef-y += if_ltalk.h
unifdef-y += if_link.h
unifdef-y += if_phonet.h
unifdef-y += if_pppol2tp.h
unifdef-y += if_pppox.h
unifdef-y += if_tr.h
Expand Down
11 changes: 5 additions & 6 deletions trunk/include/linux/if_phonet.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
*
* Copyright (C) 2008 Nokia Corporation. All rights reserved.
*/
#ifndef LINUX_IF_PHONET_H
#define LINUX_IF_PHONET_H

#define PHONET_MIN_MTU 6 /* pn_length = 0 */
#define PHONET_MAX_MTU 65541 /* pn_length = 0xffff */
#define PHONET_HEADER_LEN 8 /* Phonet header length */

#define PHONET_MIN_MTU 6
/* 6 bytes header + 65535 bytes payload */
#define PHONET_MAX_MTU 65541
#define PHONET_DEV_MTU PHONET_MAX_MTU

#ifdef __KERNEL__
extern struct header_ops phonet_header_ops;
#endif

#endif
91 changes: 56 additions & 35 deletions trunk/net/phonet/pn_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,11 @@ static void rtmsg_notify(int event, struct net_device *dev, u8 addr)
rtnl_set_sk_err(dev_net(dev), RTNLGRP_PHONET_IFADDR, err);
}

static const struct nla_policy ifa_phonet_policy[IFA_MAX+1] = {
[IFA_LOCAL] = { .type = NLA_U8 },
};

static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *attr)
static int newaddr_doit(struct sk_buff *skb, struct nlmsghdr *nlm, void *attr)
{
struct net *net = sock_net(skb->sk);
struct nlattr *tb[IFA_MAX+1];
struct rtattr **rta = attr;
struct ifaddrmsg *ifm = NLMSG_DATA(nlm);
struct net_device *dev;
struct ifaddrmsg *ifm;
int err;
u8 pnaddr;

Expand All @@ -72,28 +67,52 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *attr)

ASSERT_RTNL();

err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_phonet_policy);
if (err < 0)
return err;
if (rta[IFA_LOCAL - 1] == NULL)
return -EINVAL;

dev = __dev_get_by_index(&init_net, ifm->ifa_index);
if (dev == NULL)
return -ENODEV;

ifm = nlmsg_data(nlh);
if (tb[IFA_LOCAL] == NULL)
if (ifm->ifa_prefixlen > 0)
return -EINVAL;
pnaddr = nla_get_u8(tb[IFA_LOCAL]);
if (pnaddr & 3)
/* Phonet addresses only have 6 high-order bits */

memcpy(&pnaddr, RTA_DATA(rta[IFA_LOCAL - 1]), 1);

err = phonet_address_add(dev, pnaddr);
if (!err)
rtmsg_notify(RTM_NEWADDR, dev, pnaddr);
return err;
}

static int deladdr_doit(struct sk_buff *skb, struct nlmsghdr *nlm, void *attr)
{
struct rtattr **rta = attr;
struct ifaddrmsg *ifm = NLMSG_DATA(nlm);
struct net_device *dev;
int err;
u8 pnaddr;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;

ASSERT_RTNL();

if (rta[IFA_LOCAL - 1] == NULL)
return -EINVAL;

dev = __dev_get_by_index(net, ifm->ifa_index);
dev = __dev_get_by_index(&init_net, ifm->ifa_index);
if (dev == NULL)
return -ENODEV;

if (nlh->nlmsg_type == RTM_NEWADDR)
err = phonet_address_add(dev, pnaddr);
else
err = phonet_address_del(dev, pnaddr);
if (ifm->ifa_prefixlen > 0)
return -EADDRNOTAVAIL;

memcpy(&pnaddr, RTA_DATA(rta[IFA_LOCAL - 1]), 1);

err = phonet_address_del(dev, pnaddr);
if (!err)
rtmsg_notify(nlh->nlmsg_type, dev, pnaddr);
rtmsg_notify(RTM_DELADDR, dev, pnaddr);
return err;
}

Expand All @@ -102,23 +121,25 @@ static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr,
{
struct ifaddrmsg *ifm;
struct nlmsghdr *nlh;
unsigned int orig_len = skb->len;

nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), 0);
if (nlh == NULL)
return -EMSGSIZE;

ifm = nlmsg_data(nlh);
nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(struct ifaddrmsg));
ifm = NLMSG_DATA(nlh);
ifm->ifa_family = AF_PHONET;
ifm->ifa_prefixlen = 0;
ifm->ifa_flags = IFA_F_PERMANENT;
ifm->ifa_scope = RT_SCOPE_LINK;
ifm->ifa_scope = RT_SCOPE_HOST;
ifm->ifa_index = dev->ifindex;
NLA_PUT_U8(skb, IFA_LOCAL, addr);
return nlmsg_end(skb, nlh);
RTA_PUT(skb, IFA_LOCAL, 1, &addr);
nlh->nlmsg_len = skb->len - orig_len;

return 0;

nlmsg_failure:
rtattr_failure:
skb_trim(skb, orig_len);

nla_put_failure:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
return -1;
}

static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
Expand Down Expand Up @@ -159,7 +180,7 @@ static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)

void __init phonet_netlink_register(void)
{
rtnl_register(PF_PHONET, RTM_NEWADDR, addr_doit, NULL);
rtnl_register(PF_PHONET, RTM_DELADDR, addr_doit, NULL);
rtnl_register(PF_PHONET, RTM_NEWADDR, newaddr_doit, NULL);
rtnl_register(PF_PHONET, RTM_DELADDR, deladdr_doit, NULL);
rtnl_register(PF_PHONET, RTM_GETADDR, NULL, getaddr_dumpit);
}

0 comments on commit fefb983

Please sign in to comment.