Home | History | Annotate | Download | only in npf

Lines Matching defs:nt

306 		npf_nat_t *nt;
309 LIST_FOREACH(nt, &np->n_nat_list, nt_entry) {
310 npf_conn_t *con = nt->nt_conn;
331 npf_nat_t *nt;
334 LIST_FOREACH(nt, &np->n_nat_list, nt_entry) {
335 if (nt->nt_alg == alg) {
336 npf_alg_destroy(np->n_npfctx, alg, nt, nt->nt_conn);
337 nt->nt_alg = NULL;
484 npf_nat_t *nt;
490 nt = pool_cache_get(nat_cache, PR_NOWAIT);
491 if (__predict_false(!nt)) {
495 nt->nt_natpolicy = np;
496 nt->nt_conn = con;
497 nt->nt_alg = NULL;
507 nt->nt_ifid = nbuf->nb_ifid;
517 pool_cache_put(nat_cache, nt);
520 memcpy(&nt->nt_taddr, taddr, alen);
525 npf_nat_algo_netmap(npc, np, which, &nt->nt_taddr);
526 taddr = &nt->nt_taddr;
530 memcpy(&nt->nt_taddr, taddr, alen);
532 nt->nt_alen = alen;
537 memcpy(&nt->nt_oaddr, npc->npc_ips[NPF_SRC], alen);
541 memcpy(&nt->nt_oaddr, npc->npc_ips[NPF_DST], alen);
549 nt->nt_oport = 0;
550 nt->nt_tport = 0;
557 nt->nt_oport = (np->n_type == NPF_NATOUT) ?
561 nt->nt_oport = (np->n_type == NPF_NATOUT) ?
568 nt->nt_tport = npf_portmap_get(pm, alen, taddr);
570 nt->nt_tport = np->n_tport;
574 LIST_INSERT_HEAD(&np->n_nat_list, nt, nt_entry);
577 return nt;
584 npf_dnat_translate(npf_cache_t *npc, npf_nat_t *nt, npf_flow_t flow)
586 const npf_natpolicy_t *np = nt->nt_natpolicy;
596 addr = &nt->nt_taddr;
597 port = nt->nt_tport;
600 addr = &nt->nt_oaddr;
601 port = nt->nt_oport;
608 npf_alg_exec(npc, nt, flow);
651 npf_nat_t *nt;
655 nt = npf_nat_create(npc, np, con);
656 if (__predict_false(nt == NULL)) {
662 ret = npf_conn_setnat(npc, con, nt, np->n_type);
665 npf_nat_destroy(con, nt);
668 return nt;
683 npf_nat_t *nt;
685 if ((nt = npf_conn_getnat(con)) == NULL) {
688 if (nt->nt_ifid != nbuf->nb_ifid) {
692 np = nt->nt_natpolicy;
700 return nt;
722 npf_nat_t *nt;
736 if (con && (nt = npf_nat_lookup(npc, con, di, &flow)) != NULL) {
737 np = nt->nt_natpolicy;
781 nt = npf_nat_create(npc, np, con);
782 if (nt == NULL) {
789 if (npf_alg_match(npc, nt, di)) {
790 KASSERT(nt->nt_alg != NULL);
794 error = npf_conn_setnat(npc, con, nt, np->n_type);
797 npf_nat_destroy(con, nt);
808 error = npf_dnat_translate(npc, nt, flow);
824 npf_nat_gettrans(npf_nat_t *nt, npf_addr_t **addr, in_port_t *port)
826 *addr = &nt->nt_taddr;
827 *port = nt->nt_tport;
834 npf_nat_getorig(npf_nat_t *nt, npf_addr_t **addr, in_port_t *port)
836 *addr = &nt->nt_oaddr;
837 *port = nt->nt_oport;
844 npf_nat_setalg(npf_nat_t *nt, npf_alg_t *alg, uintptr_t arg)
846 nt->nt_alg = alg;
847 nt->nt_alg_arg = arg;
851 npf_nat_getalg(const npf_nat_t *nt)
853 return nt->nt_alg;
857 npf_nat_getalgarg(const npf_nat_t *nt)
859 return nt->nt_alg_arg;
866 npf_nat_destroy(npf_conn_t *con, npf_nat_t *nt)
868 npf_natpolicy_t *np = nt->nt_natpolicy;
873 if ((alg = npf_nat_getalg(nt)) != NULL) {
874 npf_alg_destroy(npf, alg, nt, con);
875 nt->nt_alg = NULL;
879 if ((np->n_flags & NPF_NAT_PORTMAP) != 0 && nt->nt_tport) {
881 npf_portmap_put(pm, nt->nt_alen, &nt->nt_taddr, nt->nt_tport);
890 LIST_REMOVE(nt, nt_entry);
894 pool_cache_put(nat_cache, nt);
901 npf_nat_export(npf_t *npf, const npf_nat_t *nt, nvlist_t *con_nv)
903 npf_natpolicy_t *np = nt->nt_natpolicy;
904 unsigned alen = nt->nt_alen;
908 if (nt->nt_ifid) {
910 npf_ifmap_copyname(npf, nt->nt_ifid, ifname, sizeof(ifname));
915 nvlist_add_binary(nat_nv, "oaddr", &nt->nt_oaddr, alen);
916 nvlist_add_number(nat_nv, "oport", nt->nt_oport);
918 nvlist_add_binary(nat_nv, "taddr", &nt->nt_taddr, alen);
919 nvlist_add_number(nat_nv, "tport", nt->nt_tport);
933 npf_nat_t *nt;
943 nt = pool_cache_get(nat_cache, PR_WAITOK);
944 memset(nt, 0, sizeof(npf_nat_t));
947 if (ifname && (nt->nt_ifid = npf_ifmap_register(npf, ifname)) == 0) {
960 memcpy(&nt->nt_taddr, taddr, sizeof(npf_addr_t));
966 memcpy(&nt->nt_oaddr, oaddr, sizeof(npf_addr_t));
968 nt->nt_oport = dnvlist_get_number(nat, "oport", 0);
969 nt->nt_tport = dnvlist_get_number(nat, "tport", 0);
972 if ((np->n_flags & NPF_NAT_PORTMAP) != 0 && nt->nt_tport) {
975 if (!npf_portmap_take(pm, nt->nt_alen,
976 &nt->nt_taddr, nt->nt_tport)) {
986 nt->nt_natpolicy = np;
987 nt->nt_conn = con;
990 LIST_INSERT_HEAD(&np->n_nat_list, nt, nt_entry);
991 return nt;
993 pool_cache_put(nat_cache, nt);
1000 npf_nat_dump(const npf_nat_t *nt)
1005 np = nt->nt_natpolicy;
1006 memcpy(&ip, &nt->nt_taddr, sizeof(ip));
1009 memcpy(&ip, &nt->nt_oaddr, sizeof(ip));
1011 inet_ntoa(ip), ntohs(nt->nt_oport), ntohs(nt->nt_tport));
1012 if (nt->nt_alg) {
1014 nt->nt_alg, (void *)nt->nt_alg_arg);