diff options
| author | Darren Reed <darrenr@FreeBSD.org> | 2000-05-24 04:21:35 +0000 |
|---|---|---|
| committer | Darren Reed <darrenr@FreeBSD.org> | 2000-05-24 04:21:35 +0000 |
| commit | 255c925eefa1c53c8ed4c76c1c30678e26eec165 (patch) | |
| tree | 7568d7611b8de4c369f3b58a434e07048abeafa4 /sys/netinet/ip_proxy.c | |
| parent | 6dda709260bd447dceadfc177961ff67987fce69 (diff) | |
Notes
Diffstat (limited to 'sys/netinet/ip_proxy.c')
| -rw-r--r-- | sys/netinet/ip_proxy.c | 104 |
1 files changed, 84 insertions, 20 deletions
diff --git a/sys/netinet/ip_proxy.c b/sys/netinet/ip_proxy.c index 3a038632148f..47d0e5ea0de3 100644 --- a/sys/netinet/ip_proxy.c +++ b/sys/netinet/ip_proxy.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-1998 by Darren Reed. + * Copyright (C) 1997-2000 by Darren Reed. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and due credit is given @@ -99,23 +99,62 @@ static int appr_fixseqack __P((fr_info_t *, ip_t *, ap_session_t *, int )); ap_session_t *ap_sess_tab[AP_SESS_SIZE]; ap_session_t *ap_sess_list = NULL; +aproxy_t *ap_proxylist = NULL; aproxy_t ap_proxies[] = { #ifdef IPF_FTP_PROXY - { "ftp", (char)IPPROTO_TCP, 0, 0, ippr_ftp_init, NULL, - ippr_ftp_in, ippr_ftp_out }, + { NULL, "ftp", (char)IPPROTO_TCP, 0, 0, ippr_ftp_init, NULL, + ippr_ftp_new, ippr_ftp_in, ippr_ftp_out }, #endif #ifdef IPF_RCMD_PROXY - { "rcmd", (char)IPPROTO_TCP, 0, 0, ippr_rcmd_init, ippr_rcmd_new, - NULL, ippr_rcmd_out }, + { NULL, "rcmd", (char)IPPROTO_TCP, 0, 0, ippr_rcmd_init, NULL, + ippr_rcmd_new, NULL, ippr_rcmd_out }, #endif #ifdef IPF_RAUDIO_PROXY - { "raudio", (char)IPPROTO_TCP, 0, 0, ippr_raudio_init, + { NULL, "raudio", (char)IPPROTO_TCP, 0, 0, ippr_raudio_init, NULL, ippr_raudio_new, ippr_raudio_in, ippr_raudio_out }, #endif - { "", '\0', 0, 0, NULL, NULL } + { NULL, "", '\0', 0, 0, NULL, NULL } }; +int appr_add(ap) +aproxy_t *ap; +{ + aproxy_t *a; + + for (a = ap_proxies; a->apr_p; a++) + if ((a->apr_p == ap->apr_p) && + !strncmp(a->apr_label, ap->apr_label, + sizeof(ap->apr_label))) + return -1; + + for (a = ap_proxylist; a->apr_p; a = a->apr_next) + if ((a->apr_p == ap->apr_p) && + !strncmp(a->apr_label, ap->apr_label, + sizeof(ap->apr_label))) + return -1; + ap->apr_next = ap_proxylist; + ap_proxylist = ap; + return (*ap->apr_init)(); +} + + +int appr_del(ap) +aproxy_t *ap; +{ + aproxy_t *a, **app; + + for (app = &ap_proxylist; (a = *app); app = &a->apr_next) + if (a == ap) { + if (ap->apr_ref != 0) + return 1; + *app = a->apr_next; + return 0; + } + return -1; +} + + int appr_ok(ip, tcp, nat) ip_t *ip; tcphdr_t *tcp; @@ -153,16 +192,18 @@ nat_t *nat; if (!aps) return NULL; bzero((char *)aps, sizeof(*aps)); - aps->aps_next = ap_sess_list; aps->aps_p = ip->ip_p; aps->aps_data = NULL; aps->aps_apr = apr; aps->aps_psiz = 0; - ap_sess_list = aps; - aps->aps_nat = nat; - nat->nat_aps = aps; if (apr->apr_new != NULL) - (void) (*apr->apr_new)(fin, ip, aps, nat); + if ((*apr->apr_new)(fin, ip, aps, nat) == -1) { + KFREE(aps); + return NULL; + } + aps->aps_nat = nat; + aps->aps_next = ap_sess_list; + ap_sess_list = aps; return aps; } @@ -180,6 +221,7 @@ nat_t *nat; aproxy_t *apr; tcphdr_t *tcp = NULL; u_32_t sum; + short rv; int err; if (nat->nat_aps == NULL) @@ -214,8 +256,12 @@ nat_t *nat; err = (*apr->apr_inpkt)(fin, ip, aps, nat); } + rv = APR_EXIT(err); + if (rv == -1) + return rv; + if (tcp != NULL) { - err = appr_fixseqack(fin, ip, aps, err); + err = appr_fixseqack(fin, ip, aps, APR_INC(err)); #if SOLARIS && defined(_KERNEL) tcp->th_sum = fr_tcpsum(fin->fin_qfm, ip, tcp); #else @@ -224,9 +270,9 @@ nat_t *nat; } aps->aps_bytes += ip->ip_len; aps->aps_pkts++; - return 2; + return 1; } - return -1; + return 0; } @@ -242,6 +288,13 @@ char *name; ap->apr_ref++; return ap; } + + for (ap = ap_proxylist; ap; ap = ap->apr_next) + if ((ap->apr_p == pr) && + !strncmp(name, ap->apr_label, sizeof(ap->apr_label))) { + ap->apr_ref++; + return ap; + } return NULL; } @@ -267,11 +320,9 @@ ap_session_t *aps; break; } - if (a) { - if ((aps->aps_data != NULL) && (aps->aps_psiz != 0)) - KFREES(aps->aps_data, aps->aps_psiz); - KFREE(aps); - } + if ((aps->aps_data != NULL) && (aps->aps_psiz != 0)) + KFREES(aps->aps_data, aps->aps_psiz); + KFREE(aps); } @@ -386,3 +437,16 @@ int appr_init() } return err; } + + +void appr_unload() +{ + aproxy_t *ap; + + for (ap = ap_proxies; ap->apr_p; ap++) + if (ap->apr_fini) + (*ap->apr_fini)(); + for (ap = ap_proxylist; ap; ap = ap->apr_next) + if (ap->apr_fini) + (*ap->apr_fini)(); +} |
