Lines Matching defs:tdbp
202 struct tdb *tdbp = NULL;
280 tdbp = gettdb(rtable_l2(m->m_pkthdr.ph_rtableid),
282 if (tdbp == NULL) {
289 if (tdbp->tdb_flags & TDBF_INVALID) {
292 ntohl(spi), tdbp->tdb_sproto);
297 if (udpencap && !(tdbp->tdb_flags & TDBF_UDPENCAP)) {
300 ntohl(spi), tdbp->tdb_sproto);
305 if (!udpencap && (tdbp->tdb_flags & TDBF_UDPENCAP)) {
308 ntohl(spi), tdbp->tdb_sproto);
313 if (tdbp->tdb_xform == NULL) {
316 ntohl(spi), tdbp->tdb_sproto);
323 if (tdbp->tdb_first_use == 0) {
324 tdbp->tdb_first_use = gettime();
325 if (tdbp->tdb_flags & TDBF_FIRSTUSE) {
326 if (timeout_add_sec(&tdbp->tdb_first_tmo,
327 tdbp->tdb_exp_first_use))
328 tdb_ref(tdbp);
330 if (tdbp->tdb_flags & TDBF_SOFT_FIRSTUSE) {
331 if (timeout_add_sec(&tdbp->tdb_sfirst_tmo,
332 tdbp->tdb_soft_first_use))
333 tdb_ref(tdbp);
337 tdbstat_pkt(tdbp, tdb_ipackets, tdb_ibytes, m->m_pkthdr.len);
343 prot = (*(tdbp->tdb_xform->xf_input))(mp, tdbp, skip, protoff);
346 tdbstat_inc(tdbp, tdb_idrops);
348 tdb_unref(tdbp);
355 if (tdbp != NULL)
356 tdbstat_inc(tdbp, tdb_idrops);
357 tdb_unref(tdbp);
366 ipsec_common_input_cb(struct mbuf **mp, struct tdb *tdbp, int skip, int protoff)
384 af = tdbp->tdb_dst.sa.sa_family;
385 sproto = tdbp->tdb_sproto;
387 tdbp->tdb_last_used = gettime();
394 ipsp_address(&tdbp->tdb_dst, buf, sizeof(buf)),
395 ntohl(tdbp->tdb_spi));
413 ipsp_address(&tdbp->tdb_dst, buf, sizeof(buf)),
414 ntohl(tdbp->tdb_spi));
432 (tdbp->tdb_flags & TDBF_UDPENCAP) &&
433 (tdbp->tdb_flags & TDBF_TUNNELING) == 0) {
482 if (tdbp->tdb_sproto != IPPROTO_IPCOMP) {
492 tdbi->dst = tdbp->tdb_dst;
493 tdbi->proto = tdbp->tdb_sproto;
494 tdbi->spi = tdbp->tdb_spi;
495 tdbi->rdomain = tdbp->tdb_rdomain;
503 if (tdbp->tdb_encalgxform)
507 if (tdbp->tdb_authalgxform)
523 pf_tag_packet(m, tdbp->tdb_tag, -1);
526 if (tdbp->tdb_rdomain != tdbp->tdb_rdomain_post)
527 m->m_pkthdr.ph_rtableid = tdbp->tdb_rdomain_post;
529 if (tdbp->tdb_flags & TDBF_TUNNELING)
533 tdbstat_add(tdbp, tdb_idecompbytes, m->m_pkthdr.len);
536 encif = enc_getif(tdbp->tdb_rdomain_post, tdbp->tdb_tap);
549 hdr.spi = tdbp->tdb_spi;
558 if (ISSET(tdbp->tdb_flags, TDBF_IFACE)) {
560 if (ISSET(tdbp->tdb_flags, TDBF_TUNNELING) &&
561 tdbp->tdb_iface_dir == IPSP_DIRECTION_IN) {
562 struct sec_softc *sc = sec_get(tdbp->tdb_iface);
581 if ((tdbp->tdb_flags & TDBF_TUNNELING) == 0) {
845 ipsec_set_mtu(struct tdb *tdbp, u_int32_t mtu)
852 for (; tdbp != NULL; tdbp = tdbp->tdb_inext) {
853 if (tdbp->tdb_flags & TDBF_INVALID ||
854 (adjust = ipsec_hdrsz(tdbp)) == -1)
860 tdbp->tdb_mtu = mtu;
861 tdbp->tdb_mtutimeout = gettime() + ip_mtudisc_timeout;
863 ntohl(tdbp->tdb_spi), tdbp->tdb_mtu, adjust);
874 struct tdb *tdbp;
899 tdbp = gettdb_rev(rdomain, spi, (union sockaddr_union *)&dst,
901 ipsec_set_mtu(tdbp, mtu);
902 tdb_unref(tdbp);
910 struct tdb *tdbp, *first;
942 for (tdbp = first; tdbp != NULL; tdbp = tdbp->tdb_snext) {
943 if (tdbp->tdb_sproto == IPPROTO_ESP &&
944 ((tdbp->tdb_flags & (TDBF_INVALID|TDBF_UDPENCAP)) ==
946 !memcmp(&tdbp->tdb_dst, &dst, su_dst->sa.sa_len) &&
947 !memcmp(&tdbp->tdb_src, &src, su_src->sa.sa_len))
948 ipsec_set_mtu(tdbp, mtu);