From: Ted Lemon Date: Mon, 6 Mar 2000 19:39:54 +0000 (+0000) Subject: Add interface deregistration routines (Brian Murrell). X-Git-Tag: V3-BETA-2-PATCH-1~301 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7203e8eedf1c42849337d1bdde3fb33e4941835b;p=thirdparty%2Fdhcp.git Add interface deregistration routines (Brian Murrell). --- diff --git a/common/bpf.c b/common/bpf.c index 150a89471..fd307fc28 100644 --- a/common/bpf.c +++ b/common/bpf.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: bpf.c,v 1.33 2000/01/26 14:55:33 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: bpf.c,v 1.34 2000/03/06 19:39:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -130,6 +130,27 @@ void if_register_send (info) (info -> shared_network ? info -> shared_network -> name : "")); } + +void if_deregister_send (info) + struct interface_info *info; +{ + /* If we're using the bpf API for sending and receiving, + we don't need to register this interface twice. */ +#ifndef USE_BPF_RECEIVE + close (info -> wfdesc); +#endif + info -> wfdesc = -1; + + if (!quiet_interface_discovery) + log_info ("Disabling output on BPF/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], + info -> hw_address.hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} #endif /* USE_BPF_SEND */ #if defined (USE_BPF_RECEIVE) || defined (USE_LPF_RECEIVE) @@ -253,6 +274,23 @@ void if_register_receive (info) (info -> shared_network ? info -> shared_network -> name : "")); } + +void if_deregister_receive (info) + struct interface_info *info; +{ + close (info -> rfdesc); + info -> rfdesc = -1; + + if (!quiet_interface_discovery) + log_info ("Disabling input on BPF/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], + info -> hw_address.hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} #endif /* USE_BPF_RECEIVE */ #ifdef USE_BPF_SEND diff --git a/common/dlpi.c b/common/dlpi.c index 26601fbf5..e4a60c646 100644 --- a/common/dlpi.c +++ b/common/dlpi.c @@ -70,7 +70,7 @@ #ifndef lint static char copyright[] = -"$Id: dlpi.c,v 1.17 2000/01/25 01:05:01 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dlpi.c,v 1.18 2000/03/06 19:39:53 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -357,6 +357,27 @@ void if_register_send (info) # endif #endif } + +void if_deregister_send (info) + struct interface_info *info; +{ + /* If we're using the DLPI API for sending and receiving, + we don't need to register this interface twice. */ +#ifndef USE_DLPI_RECEIVE + close (info -> wfdesc); +#endif + info -> wfdesc = -1; + + if (!quiet_interface_discovery) + log_info ("Disabling output on DLPI/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], + info -> hw_address.hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} #endif /* USE_DLPI_SEND */ #ifdef USE_DLPI_RECEIVE @@ -440,6 +461,27 @@ void if_register_receive (info) # endif #endif } + +void if_deregister_receive (info) + struct interface_info *info; +{ + /* If we're using the DLPI API for sending and receiving, + we don't need to register this interface twice. */ +#ifndef USE_DLPI_SEND + close (info -> rfdesc); +#endif + info -> rfdesc = -1; + + if (!quiet_interface_discovery) + log_info ("Disabling input on DLPI/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], + info -> hw_address.hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} #endif /* USE_DLPI_RECEIVE */ #ifdef USE_DLPI_SEND diff --git a/common/lpf.c b/common/lpf.c index e1a88be1e..37fce8fa8 100644 --- a/common/lpf.c +++ b/common/lpf.c @@ -23,7 +23,7 @@ #ifndef lint static char copyright[] = -"$Id: lpf.c,v 1.21 2000/02/15 20:40:30 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: lpf.c,v 1.22 2000/03/06 19:39:53 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -131,9 +131,9 @@ void if_deregister_send (info) are closed */ close (info -> wfdesc); #endif - info -> wfdesc = 0; + info -> wfdesc = -1; if (!quiet_interface_discovery) - log_info ("NOT Sending on LPF/%s/%s%s%s", + log_info ("Disabling output on LPF/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.hbuf [0], info -> hw_address.hlen - 1, @@ -183,9 +183,9 @@ void if_deregister_receive (info) /* for LPF this is simple, packet filters are removed when sockets are closed */ close (info -> rfdesc); - info -> rfdesc = 0; + info -> rfdesc = -1; if (!quiet_interface_discovery) - log_info ("NOT Listening on LPF/%s/%s%s%s", + log_info ("Disabling input on LPF/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.hbuf [0], info -> hw_address.hlen - 1, diff --git a/common/nit.c b/common/nit.c index 0f4191bd6..6c28a54f8 100644 --- a/common/nit.c +++ b/common/nit.c @@ -23,7 +23,7 @@ #ifndef lint static char copyright[] = -"$Id: nit.c,v 1.26 2000/01/25 01:07:41 mellon Exp $ Copyright (c) 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: nit.c,v 1.27 2000/03/06 19:39:53 mellon Exp $ Copyright (c) 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -145,6 +145,25 @@ void if_register_send (info) (info -> shared_network ? info -> shared_network -> name : "")); } + +void if_deregister_send (info) + struct interface_info *info; +{ + /* If we're using the nit API for sending and receiving, + we don't need to register this interface twice. */ +#ifndef USE_NIT_RECEIVE + close (info -> wfdesc); +#endif + info -> wfdesc = -1; + if (!quiet_interface_discovery) + log_info ("Disabling output on NIT/%s%s%s", + print_hw_addr (info -> hw_address.hbuf [0], + info -> hw_address.hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} #endif /* USE_NIT_SEND */ #ifdef USE_NIT_RECEIVE @@ -229,6 +248,24 @@ void if_register_receive (info) (info -> shared_network ? info -> shared_network -> name : "")); } + +void if_deregister_receive (info) + struct interface_info *info; +{ + /* If we're using the nit API for sending and receiving, + we don't need to register this interface twice. */ + close (info -> rfdesc); + info -> rfdesc = -1; + + if (!quiet_interface_discovery) + log_info ("Disabling input on NIT/%s%s%s", + print_hw_addr (info -> hw_address.hbuf [0], + info -> hw_address.hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} #endif /* USE_NIT_RECEIVE */ #ifdef USE_NIT_SEND diff --git a/common/raw.c b/common/raw.c index fd2c06320..042ad9515 100644 --- a/common/raw.c +++ b/common/raw.c @@ -35,7 +35,7 @@ #ifndef lint static char copyright[] = -"$Id: raw.c,v 1.15 1999/03/16 06:37:50 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: raw.c,v 1.16 2000/03/06 19:39:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -85,6 +85,20 @@ void if_register_send (info) info -> shared_network -> name : "")); } +void if_deregister_send (info) + struct interface_info *info; +{ + close (info -> wfdesc); + info -> wfdesc = -1; + + if (!quiet_interface_discovery) + log_info ("Disabling output on Raw/%s%s%s", + info -> name, + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} + size_t send_packet (interface, packet, raw, len, from, to, hto) struct interface_info *interface; struct packet *packet; diff --git a/common/socket.c b/common/socket.c index 72a6da13c..1ca2d5d89 100644 --- a/common/socket.c +++ b/common/socket.c @@ -30,7 +30,7 @@ #ifndef lint static char copyright[] = -"$Id: socket.c,v 1.45 2000/02/03 03:43:51 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: socket.c,v 1.46 2000/03/06 19:39:54 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -153,6 +153,24 @@ void if_register_send (info) (info -> shared_network ? info -> shared_network -> name : "")); } + +#if !defined (USE_SOCKET_FALLBACK) +void if_deregister_send (info) + struct interface_info *info; +{ +#ifndef USE_SOCKET_RECEIVE + close (info -> wfdesc); +#endif + info -> wfdesc = -1; + + if (!quiet_interface_discovery) + log_info ("Disabling output on Socket/%s%s%s", + info -> name, + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} +#endif /* !USE_SOCKET_FALLBACK */ #endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */ #ifdef USE_SOCKET_RECEIVE @@ -169,6 +187,19 @@ void if_register_receive (info) (info -> shared_network ? info -> shared_network -> name : "")); } + +void if_deregister_receive (info) + struct interface_info *info; +{ + close (info -> rfdesc); + info -> rfdesc = -1; + + if (!quiet_interface_discovery) + log_info ("Disabling input on Socket/%s%s%s", + info -> name, + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); #endif /* USE_SOCKET_RECEIVE */ #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_FALLBACK) diff --git a/common/upf.c b/common/upf.c index 4988c81f2..22fd5531b 100644 --- a/common/upf.c +++ b/common/upf.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: upf.c,v 1.15 2000/01/25 01:17:01 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: upf.c,v 1.16 2000/03/06 19:39:54 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -132,6 +132,24 @@ void if_register_send (info) (info -> shared_network ? info -> shared_network -> name : "")); } + +void if_deregister_send (info) + struct interface_info *info; +{ +#ifndef USE_UPF_RECEIVE + close (info -> wfdesc); +#endif + info -> wfdesc = -1; + if (!quiet_interface_discovery) + log_info ("Disabling output on UPF/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], + info -> hw_address.hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} #endif /* USE_UPF_SEND */ #ifdef USE_UPF_RECEIVE @@ -198,6 +216,22 @@ void if_register_receive (info) (info -> shared_network ? info -> shared_network -> name : "")); } + +void if_deregister_receive (info) + struct interface_info *info; +{ + close (info -> rfdesc); + info -> rfdesc = -1; + if (!quiet_interface_discovery) + log_info ("Disabling input on UPF/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], + info -> hw_address.hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? + info -> shared_network -> name : "")); +} #endif /* USE_UPF_RECEIVE */ #ifdef USE_UPF_SEND