| 156 | } |
| 157 | |
| 158 | static int |
| 159 | enc_clone_create(struct if_clone *ifc, int unit, caddr_t params) |
| 160 | { |
| 161 | struct ifnet *ifp; |
| 162 | struct enc_softc *sc; |
| 163 | |
| 164 | sc = malloc(sizeof(struct enc_softc), M_DEVBUF, |
| 165 | M_WAITOK | M_ZERO); |
| 166 | ifp = sc->sc_ifp = if_alloc(IFT_ENC); |
| 167 | if (ifp == NULL) { |
| 168 | free(sc, M_DEVBUF); |
| 169 | return (ENOSPC); |
| 170 | } |
| 171 | if (V_enc_sc != NULL) { |
| 172 | if_free(ifp); |
| 173 | free(sc, M_DEVBUF); |
| 174 | return (EEXIST); |
| 175 | } |
| 176 | V_enc_sc = sc; |
| 177 | if_initname(ifp, encname, unit); |
| 178 | ifp->if_mtu = ENCMTU; |
| 179 | ifp->if_ioctl = enc_ioctl; |
| 180 | ifp->if_output = enc_output; |
| 181 | ifp->if_softc = sc; |
| 182 | if_attach(ifp); |
| 183 | bpfattach(ifp, DLT_ENC, sizeof(struct enchdr)); |
| 184 | return (0); |
| 185 | } |
| 186 | |
| 187 | static int |
| 188 | enc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, |