1*4a64e381SAndroid Build Coastguard WorkerFrom f7ab91f739b936305ca56743adfb4673e3f2f4ba Mon Sep 17 00:00:00 2001 2*4a64e381SAndroid Build Coastguard WorkerMessage-ID: <f7ab91f739b936305ca56743adfb4673e3f2f4ba.1687508149.git.stefan@agner.ch> 3*4a64e381SAndroid Build Coastguard WorkerIn-Reply-To: <e136dcdcdd93ef32ada981e89c195905eb809eea.1687508149.git.stefan@agner.ch> 4*4a64e381SAndroid Build Coastguard WorkerReferences: <e136dcdcdd93ef32ada981e89c195905eb809eea.1687508149.git.stefan@agner.ch> 5*4a64e381SAndroid Build Coastguard WorkerFrom: Nate Karstens <[email protected]> 6*4a64e381SAndroid Build Coastguard WorkerDate: Wed, 28 Jun 2017 17:30:00 -0500 7*4a64e381SAndroid Build Coastguard WorkerSubject: [PATCH] Create subroutine for tearing down an interface 8*4a64e381SAndroid Build Coastguard Worker 9*4a64e381SAndroid Build Coastguard WorkerCreates a subroutine for tearing down an interface. 10*4a64e381SAndroid Build Coastguard Worker 11*4a64e381SAndroid Build Coastguard WorkerUpstream-Status: Submitted [[email protected]] 12*4a64e381SAndroid Build Coastguard Worker 13*4a64e381SAndroid Build Coastguard WorkerSigned-off-by: Nate Karstens <[email protected]> 14*4a64e381SAndroid Build Coastguard WorkerSigned-off-by: Alex Kiernan <[email protected]> 15*4a64e381SAndroid Build Coastguard Worker--- 16*4a64e381SAndroid Build Coastguard Worker mDNSPosix/mDNSPosix.c | 22 ++++++++++++++++------ 17*4a64e381SAndroid Build Coastguard Worker 1 file changed, 16 insertions(+), 6 deletions(-) 18*4a64e381SAndroid Build Coastguard Worker 19*4a64e381SAndroid Build Coastguard Workerdiff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c 20*4a64e381SAndroid Build Coastguard Workerindex fe7242d..a32a880 100644 21*4a64e381SAndroid Build Coastguard Worker--- a/mDNSPosix/mDNSPosix.c 22*4a64e381SAndroid Build Coastguard Worker+++ b/mDNSPosix/mDNSPosix.c 23*4a64e381SAndroid Build Coastguard Worker@@ -1043,6 +1043,19 @@ mDNSlocal void FreePosixNetworkInterface(PosixNetworkInterface *intf) 24*4a64e381SAndroid Build Coastguard Worker gRecentInterfaces = intf; 25*4a64e381SAndroid Build Coastguard Worker } 26*4a64e381SAndroid Build Coastguard Worker 27*4a64e381SAndroid Build Coastguard Worker+mDNSlocal void TearDownInterface(mDNS *const m, PosixNetworkInterface *intf) 28*4a64e381SAndroid Build Coastguard Worker+{ 29*4a64e381SAndroid Build Coastguard Worker+ mDNS_DeregisterInterface(m, &intf->coreIntf, NormalActivation); 30*4a64e381SAndroid Build Coastguard Worker+ if (gMDNSPlatformPosixVerboseLevel > 0) fprintf(stderr, "Deregistered interface %s\n", intf->intfName); 31*4a64e381SAndroid Build Coastguard Worker+ FreePosixNetworkInterface(intf); 32*4a64e381SAndroid Build Coastguard Worker+ 33*4a64e381SAndroid Build Coastguard Worker+ num_registered_interfaces--; 34*4a64e381SAndroid Build Coastguard Worker+ if (num_registered_interfaces == 0) { 35*4a64e381SAndroid Build Coastguard Worker+ num_pkts_accepted = 0; 36*4a64e381SAndroid Build Coastguard Worker+ num_pkts_rejected = 0; 37*4a64e381SAndroid Build Coastguard Worker+ } 38*4a64e381SAndroid Build Coastguard Worker+} 39*4a64e381SAndroid Build Coastguard Worker+ 40*4a64e381SAndroid Build Coastguard Worker // Grab the first interface, deregister it, free it, and repeat until done. 41*4a64e381SAndroid Build Coastguard Worker mDNSlocal void ClearInterfaceList(mDNS *const m) 42*4a64e381SAndroid Build Coastguard Worker { 43*4a64e381SAndroid Build Coastguard Worker@@ -1051,13 +1064,10 @@ mDNSlocal void ClearInterfaceList(mDNS *const m) 44*4a64e381SAndroid Build Coastguard Worker while (m->HostInterfaces) 45*4a64e381SAndroid Build Coastguard Worker { 46*4a64e381SAndroid Build Coastguard Worker PosixNetworkInterface *intf = (PosixNetworkInterface*)(m->HostInterfaces); 47*4a64e381SAndroid Build Coastguard Worker- mDNS_DeregisterInterface(m, &intf->coreIntf, NormalActivation); 48*4a64e381SAndroid Build Coastguard Worker- if (gMDNSPlatformPosixVerboseLevel > 0) fprintf(stderr, "Deregistered interface %s\n", intf->intfName); 49*4a64e381SAndroid Build Coastguard Worker- FreePosixNetworkInterface(intf); 50*4a64e381SAndroid Build Coastguard Worker+ TearDownInterface(m, intf); 51*4a64e381SAndroid Build Coastguard Worker } 52*4a64e381SAndroid Build Coastguard Worker- num_registered_interfaces = 0; 53*4a64e381SAndroid Build Coastguard Worker- num_pkts_accepted = 0; 54*4a64e381SAndroid Build Coastguard Worker- num_pkts_rejected = 0; 55*4a64e381SAndroid Build Coastguard Worker+ 56*4a64e381SAndroid Build Coastguard Worker+ assert(num_registered_interfaces == 0); 57*4a64e381SAndroid Build Coastguard Worker } 58*4a64e381SAndroid Build Coastguard Worker 59*4a64e381SAndroid Build Coastguard Worker mDNSlocal int SetupIPv6Socket(int fd) 60*4a64e381SAndroid Build Coastguard Worker-- 61*4a64e381SAndroid Build Coastguard Worker2.41.0 62*4a64e381SAndroid Build Coastguard Worker 63