summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/ip_netbios_pxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ipfilter/ip_netbios_pxy.c')
-rw-r--r--contrib/ipfilter/ip_netbios_pxy.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/contrib/ipfilter/ip_netbios_pxy.c b/contrib/ipfilter/ip_netbios_pxy.c
index ee9b0c4..0ff6d25 100644
--- a/contrib/ipfilter/ip_netbios_pxy.c
+++ b/contrib/ipfilter/ip_netbios_pxy.c
@@ -1,11 +1,13 @@
+/* $NetBSD$ */
+
/*
* Simple netbios-dgm transparent proxy for in-kernel use.
* For use with the NAT code.
- * $Id: ip_netbios_pxy.c,v 1.1.2.3 2002/01/09 09:28:37 darrenr Exp $
+ * Id: ip_netbios_pxy.c,v 2.8 2003/12/01 02:52:16 darrenr Exp
*/
/*-
- * Copyright (c) 2002 Paul J. Ledbetter III
+ * Copyright (c) 2002-2003 Paul J. Ledbetter III
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,16 +31,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ip_netbios_pxy.c,v 1.1.2.3 2002/01/09 09:28:37 darrenr Exp $
+ * Id: ip_netbios_pxy.c,v 2.8 2003/12/01 02:52:16 darrenr Exp
*/
#define IPF_NETBIOS_PROXY
int ippr_netbios_init __P((void));
-int ippr_netbios_out __P((fr_info_t *, ip_t *, ap_session_t *, nat_t *));
+void ippr_netbios_fini __P((void));
+int ippr_netbios_out __P((fr_info_t *, ap_session_t *, nat_t *));
static frentry_t netbiosfr;
+int netbios_proxy_init = 0;
+
/*
* Initialize local structures.
*/
@@ -47,43 +52,55 @@ int ippr_netbios_init()
bzero((char *)&netbiosfr, sizeof(netbiosfr));
netbiosfr.fr_ref = 1;
netbiosfr.fr_flags = FR_INQUE|FR_PASS|FR_QUICK|FR_KEEPSTATE;
+ MUTEX_INIT(&netbiosfr.fr_lock, "NETBIOS proxy rule lock");
+ netbios_proxy_init = 1;
+
return 0;
}
-int ippr_netbios_out(fin, ip, aps, nat)
+
+void ippr_netbios_fini()
+{
+ if (netbios_proxy_init == 1) {
+ MUTEX_DESTROY(&netbiosfr.fr_lock);
+ netbios_proxy_init = 0;
+ }
+}
+
+
+int ippr_netbios_out(fin, aps, nat)
fr_info_t *fin;
-ip_t *ip;
ap_session_t *aps;
nat_t *nat;
{
char dgmbuf[6];
-
int off, dlen;
udphdr_t *udp;
+ ip_t *ip;
mb_t *m;
+ aps = aps; /* LINT */
+ nat = nat; /* LINT */
+
+ ip = fin->fin_ip;
m = *(mb_t **)fin->fin_mp;
off = fin->fin_hlen + sizeof(udphdr_t);
-#if SOLARIS
- dlen = msgdsize(m);
-#else
- dlen = mbufchainlen(m);
-#endif
+ dlen = M_LEN(m);
dlen -= off;
/*
* no net bios datagram could possibly be shorter than this
*/
- if (dlen < 11)
+ if (dlen < 11)
return 0;
udp = (udphdr_t *)fin->fin_dp;
- /*
+ /*
* move past the
* ip header;
* udp header;
- * 4 bytes into the net bios dgm header.
+ * 4 bytes into the net bios dgm header.
* According to rfc1002, this should be the exact location of
* the source address/port
*/
@@ -99,11 +116,7 @@ nat_t *nat;
dgmbuf[5] = (char)((udp->uh_sport >> 8)&0xFF);
/* replace data in packet */
-#if SOLARIS
- copyin_mblk(m, off, sizeof(dgmbuf), dgmbuf);
-#else
- m_copyback(m, off, sizeof(dgmbuf), dgmbuf);
-#endif
+ COPYBACK(m, off, sizeof(dgmbuf), dgmbuf);
return 0;
}
OpenPOWER on IntegriCloud