This source file includes following definitions.
- encattach
- encstart
- encoutput
- encioctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/mbuf.h>
43 #include <sys/socket.h>
44 #include <sys/ioctl.h>
45
46 #include <net/if.h>
47 #include <net/if_types.h>
48 #include <net/route.h>
49 #include <net/bpf.h>
50
51 #include <net/if_enc.h>
52
53 #ifdef INET
54 #include <netinet/in.h>
55 #include <netinet/in_var.h>
56 #endif
57
58 #ifdef INET6
59 #ifndef INET
60 #include <netinet/in.h>
61 #endif
62 #include <netinet6/nd6.h>
63 #endif
64
65 #include "bpfilter.h"
66 #include "enc.h"
67
68 #ifdef ENCDEBUG
69 #define DPRINTF(x) do { if (encdebug) printf x ; } while (0)
70 #else
71 #define DPRINTF(x)
72 #endif
73
74 struct enc_softc encif[NENC];
75
76 void encattach(int);
77 int encoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
78 struct rtentry *);
79 int encioctl(struct ifnet *, u_long, caddr_t);
80 void encstart(struct ifnet *);
81
82 void
83 encattach(int nenc)
84 {
85 struct ifnet *ifp;
86 int i;
87
88 bzero(encif, sizeof(encif));
89
90 for (i = 0; i < NENC; i++) {
91 ifp = &encif[i].sc_if;
92 snprintf(ifp->if_xname, sizeof ifp->if_xname, "enc%d", i);
93 ifp->if_softc = &encif[i];
94 ifp->if_mtu = ENCMTU;
95 ifp->if_ioctl = encioctl;
96 ifp->if_output = encoutput;
97 ifp->if_start = encstart;
98 ifp->if_type = IFT_ENC;
99 ifp->if_snd.ifq_maxlen = ifqmaxlen;
100 ifp->if_hdrlen = ENC_HDRLEN;
101 if_attach(ifp);
102 if_alloc_sadl(ifp);
103
104 #if NBPFILTER > 0
105 bpfattach(&encif[i].sc_if.if_bpf, ifp, DLT_ENC, ENC_HDRLEN);
106 #endif
107 }
108 }
109
110
111
112
113 void
114 encstart(struct ifnet *ifp)
115 {
116 struct mbuf *m;
117 int s;
118
119 for (;;) {
120 s = splnet();
121 IF_DROP(&ifp->if_snd);
122 IF_DEQUEUE(&ifp->if_snd, m);
123 splx(s);
124
125 if (m == NULL)
126 return;
127 else
128 m_freem(m);
129 }
130 }
131
132 int
133 encoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
134 struct rtentry *rt)
135 {
136 m_freem(m);
137 return (0);
138 }
139
140
141 int
142 encioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
143 {
144 switch (cmd) {
145 case SIOCSIFADDR:
146 case SIOCAIFADDR:
147 case SIOCSIFDSTADDR:
148 case SIOCSIFFLAGS:
149 if (ifp->if_flags & IFF_UP)
150 ifp->if_flags |= IFF_RUNNING;
151 else
152 ifp->if_flags &= ~IFF_RUNNING;
153 break;
154 default:
155 return (EINVAL);
156 }
157
158 return 0;
159 }