Subject: Re: sockets in AF_LINK family ? (patches attached)
To: None <tech-net@NetBSD.org>
From: Dheeraj S <dheeraj@ece.gatech.edu>
List: tech-net
Date: 03/25/2005 06:34:44
--2B/JsCI69OhZNC5r
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello David/else,
A rough cut attempt at the following is attached. It atleast does address
a few data link functions.
Kindly comment/criticize.
truely
dheeraj
PS: I realize that one of the files is not related.
On Sun, Mar 20, 2005 at 01:24:29AM -0600, David Young wrote:
> On Sat, Mar 12, 2005 at 02:04:26PM -0500, Dheeraj S wrote:
> > Hello all,
> > Is is possible to create sockets in the AF_LINK/PF_LINK family ?
> > for example,
> > socket(PF_LINK, SOCK_DGRAM/SOCK_RAW, 0).
>
> Not yet. It is a very desirable feature, to me. Do you think you will
> send a patch?
>
> Dave
--
"Nature wants us to react, return blow for blow, cheating for cheating, lie for
lie, and then it requires a Divine power not to hit-back, keep control and
remain unattached, and act with prudence."
--2B/JsCI69OhZNC5r
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch-dlsock.txt"
--- /dev/null 2005-03-25 05:20:57.000000000 -0500
+++ net/dlsock.c 2005-03-25 05:18:08.000000000 -0500
@@ -0,0 +1,110 @@
+/*
+ Copyright Dheeraj Reddy. dheeraj@ece.gatech.edu
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/domain.h>
+#include <sys/protosw.h>
+
+#include <net/if.h>
+#include <net/route.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/in.h>
+#include <netinet/in_pcb.h>
+
+
+DOMAIN_DEFINE(dltdomain);
+
+struct sockproto dlt_proto = {PF_LINK, };
+
+void dlt_init (void);
+void dlt_input (struct mbuf *, ...);
+int dlt_ctloutput (int, struct socket*, int, int, struct mbuf**);
+int dlt_usrreq (struct socket*,
+ int, struct mbuf*, struct mbuf*, struct mbuf*, struct proc* );
+int dlt_output (struct mbuf *, ...);
+
+struct inpcbtable dltbtable;
+int dltbhashsize = 64;
+
+void dlt_init (void)
+{
+ in_pcbinit(&dltbtable, dltbhashsize, dltbhashsize);
+}
+
+void dlt_input (struct mbuf *m, ...)
+{
+}
+
+int dlt_ctloutput(int cmd, struct socket *sock, int i, int j,
+ struct mbuf** m)
+{
+ return 0;
+}
+
+int dlt_usrreq(struct socket *so, int req, struct mbuf *cmd,
+ struct mbuf *data_, struct mbuf *ifp_, struct proc *p)
+{
+ struct inpcb *inp;
+ struct ifnet *ifp = (struct ifnet*)(ifp_);
+ caddr_t data = (caddr_t)(data_);
+ int retval = 0;
+ int s;
+
+ s = splsoftnet();
+ inp = sotoinpcb(so);
+
+ switch (req) {
+
+ case PRU_ATTACH:
+ if (inp !=0 ) {
+ retval = EISCONN;
+ break;
+ }
+ retval = in_pcballoc(so, &dltbtable);
+ if (retval)
+ break;
+ inp = sotoinpcb(so);
+ break;
+
+ case PRU_DETACH:
+ in_pcbdetach(inp);
+ break;
+
+ case PRU_CONTROL:
+ retval = ifp->if_ioctl(ifp, (u_long)cmd, data);
+ break;
+
+ default:
+ retval = EOPNOTSUPP;
+ }
+
+ splx(s);
+ return retval;
+}
+
+int dlt_output (struct mbuf *m, ...)
+{
+ return (EOPNOTSUPP);
+}
+
+const struct protosw dltsw[] = {
+{
+ SOCK_DGRAM, &dltdomain, 0, PR_ATOMIC|PR_ADDR,
+ dlt_input, dlt_output, 0, dlt_ctloutput,
+ dlt_usrreq,
+ dlt_init, 0, 0, 0,
+} };
+
+struct domain dltdomain = {
+ PF_LINK, "dlt", 0, 0, 0,
+ dltsw, &dltsw[sizeof(dltsw)/sizeof(dltsw[0])]
+};
--2B/JsCI69OhZNC5r
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch-conf-files.txt"
--- conf/files 2005-03-25 05:27:49.000000000 -0500
+++ conf/files.new 2005-03-25 05:27:20.000000000 -0500
@@ -137,6 +137,7 @@
include "netns/files.netns"
include "netsmb/files.netsmb"
include "net/files.pf"
+include "net80211/files.net80211"
defflag IPX # IPX network stack
defflag PFIL_HOOKS # pfil(9)
@@ -1326,17 +1327,9 @@
file net/raw_usrreq.c
file net/route.c
file net/rtsock.c
+file net/dlsock.c
file net/slcompress.c sl | ppp | strip | (irip & irip_vj)
file net/zlib.c (ppp & ppp_deflate) | ipsec | opencrypto
-file net80211/ieee80211.c wlan
-file net80211/ieee80211_compat.c wlan
-file net80211/ieee80211_crypto.c wlan
-file net80211/ieee80211_input.c wlan
-file net80211/ieee80211_ioctl.c wlan
-file net80211/ieee80211_node.c wlan
-file net80211/ieee80211_output.c wlan
-file net80211/ieee80211_proto.c wlan
-file net80211/ieee80211_rssadapt.c wlan
file netinet/if_arp.c arp | netatalk needs-flag
file netinet/if_atm.c atm
file netinet/in_gif.c gif & inet
--2B/JsCI69OhZNC5r
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch-net80211.txt"
--- /dev/null 2005-03-24 19:42:51.000000000 -0500
+++ net80211/files.net80211 2005-03-24 19:57:45.000000000 -0500
@@ -0,0 +1,10 @@
+
+file net80211/ieee80211.c wlan
+file net80211/ieee80211_compat.c wlan
+file net80211/ieee80211_crypto.c wlan
+file net80211/ieee80211_input.c wlan
+file net80211/ieee80211_ioctl.c wlan
+file net80211/ieee80211_node.c wlan
+file net80211/ieee80211_output.c wlan
+file net80211/ieee80211_proto.c wlan
+file net80211/ieee80211_rssadapt.c wlan
--2B/JsCI69OhZNC5r--