aboutsummaryrefslogtreecommitdiffstats
path: root/net/llc
diff options
context:
space:
mode:
authorOctavian Purdila <opurdila@ixiacom.com>2009-12-26 06:51:00 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-26 23:40:34 -0500
commite5cd6fe391aa8c93560bb7ffdfe334cf4d0a02e4 (patch)
tree018cf6c943ba0292c33118920a356a0b0a31e00d /net/llc
parentbf9ae5386bca8836c16e69ab8fdbe46767d7452a (diff)
llc: add support for LLC_OPT_PKTINFO
Signed-off-by: Octavian Purdila <opurdila@ixiacom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/llc')
-rw-r--r--net/llc/af_llc.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 3a66546cad06..ac691fe08076 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -47,6 +47,10 @@ static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout);
47#define dprintk(args...) 47#define dprintk(args...)
48#endif 48#endif
49 49
50/* Maybe we'll add some more in the future. */
51#define LLC_CMSG_PKTINFO 1
52
53
50/** 54/**
51 * llc_ui_next_link_no - return the next unused link number for a sap 55 * llc_ui_next_link_no - return the next unused link number for a sap
52 * @sap: Address of sap to get link number from. 56 * @sap: Address of sap to get link number from.
@@ -591,6 +595,20 @@ static int llc_wait_data(struct sock *sk, long timeo)
591 return rc; 595 return rc;
592} 596}
593 597
598static void llc_cmsg_rcv(struct msghdr *msg, struct sk_buff *skb)
599{
600 struct llc_sock *llc = llc_sk(skb->sk);
601
602 if (llc->cmsg_flags & LLC_CMSG_PKTINFO) {
603 struct llc_pktinfo info;
604
605 info.lpi_ifindex = llc_sk(skb->sk)->dev->ifindex;
606 llc_pdu_decode_dsap(skb, &info.lpi_sap);
607 llc_pdu_decode_da(skb, info.lpi_mac);
608 put_cmsg(msg, SOL_LLC, LLC_OPT_PKTINFO, sizeof(info), &info);
609 }
610}
611
594/** 612/**
595 * llc_ui_accept - accept a new incoming connection. 613 * llc_ui_accept - accept a new incoming connection.
596 * @sock: Socket which connections arrive on. 614 * @sock: Socket which connections arrive on.
@@ -812,6 +830,8 @@ copy_uaddr:
812 memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr)); 830 memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr));
813 msg->msg_namelen = sizeof(*uaddr); 831 msg->msg_namelen = sizeof(*uaddr);
814 } 832 }
833 if (llc_sk(sk)->cmsg_flags)
834 llc_cmsg_rcv(msg, skb);
815 goto out; 835 goto out;
816} 836}
817 837
@@ -1030,6 +1050,12 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
1030 goto out; 1050 goto out;
1031 llc->rw = opt; 1051 llc->rw = opt;
1032 break; 1052 break;
1053 case LLC_OPT_PKTINFO:
1054 if (opt)
1055 llc->cmsg_flags |= LLC_CMSG_PKTINFO;
1056 else
1057 llc->cmsg_flags &= ~LLC_CMSG_PKTINFO;
1058 break;
1033 default: 1059 default:
1034 rc = -ENOPROTOOPT; 1060 rc = -ENOPROTOOPT;
1035 goto out; 1061 goto out;
@@ -1083,6 +1109,9 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
1083 val = llc->k; break; 1109 val = llc->k; break;
1084 case LLC_OPT_RX_WIN: 1110 case LLC_OPT_RX_WIN:
1085 val = llc->rw; break; 1111 val = llc->rw; break;
1112 case LLC_OPT_PKTINFO:
1113 val = (llc->cmsg_flags & LLC_CMSG_PKTINFO) != 0;
1114 break;
1086 default: 1115 default:
1087 rc = -ENOPROTOOPT; 1116 rc = -ENOPROTOOPT;
1088 goto out; 1117 goto out;