Skip to content

Commit b499dee

Browse files
Copilotfduminy
andauthored
Break circular dependency in network subsystem (4 plugins → 0) (#24)
* Initial plan * Break bluetooth ↔ net cycle by moving mapper to bluetooth plugin Co-authored-by: fduminy <143904+fduminy@users.noreply.github.com> * Break cycle further by introducing ARPService interface and moving IPv4Address Co-authored-by: fduminy <143904+fduminy@users.noreply.github.com> * Complete cycle break by moving test suite to correct package Co-authored-by: fduminy <143904+fduminy@users.noreply.github.com> * Fix compilation errors: add missing imports and NetworkException to ARPService Co-authored-by: fduminy <143904+fduminy@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fduminy <143904+fduminy@users.noreply.github.com>
1 parent fa4a58d commit b499dee

47 files changed

Lines changed: 134 additions & 91 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SOURCE_LEVEL_CYCLES_REPORT.md

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,7 @@ ANALYSE DES DÉPENDANCES CIRCULAIRES AU NIVEAU DU CODE SOURCE
44

55
Nombre total de plugins analysés: 229
66
Nombre de plugins avec des fichiers Java: 185
7-
Nombre total de cycles détectés: 2
8-
9-
10-
================================================================================
11-
DIFFICULTÉ: MEDIUM
12-
================================================================================
13-
14-
Cycle #34: org.jnode.driver.net.usb.bluetooth ↔ org.jnode.net ↔ org.jnode.net.arp ↔ org.jnode.net.ipv4.core
15-
--------------------------------------------------------------------------------
16-
Difficulté: MEDIUM
17-
Raisonnement: Cycle involves 4 plugins across multiple subsystems - requires extracting common interfaces.
18-
19-
Plugins impliqués:
20-
- org.jnode.driver.net.usb.bluetooth
21-
Fichier: net/descriptors/org.jnode.driver.net.usb.bluetooth.xml
22-
Sous-projet: net
23-
Fichiers Java: 2
24-
- org.jnode.net
25-
Fichier: net/descriptors/org.jnode.net.xml
26-
Sous-projet: net
27-
Fichiers Java: 43
28-
- org.jnode.net.arp
29-
Fichier: net/descriptors/org.jnode.net.arp.xml
30-
Sous-projet: net
31-
Fichiers Java: 8
32-
- org.jnode.net.ipv4.core
33-
Fichier: net/descriptors/org.jnode.net.ipv4.core.xml
34-
Sous-projet: net
35-
Fichiers Java: 14
36-
37-
Dépendances circulaires (au niveau du code source):
38-
org.jnode.driver.net.usb.bluetooth → org.jnode.net
39-
org.jnode.net → org.jnode.driver.net.usb.bluetooth
40-
org.jnode.net → org.jnode.net.arp
41-
org.jnode.net.arp → org.jnode.net
42-
org.jnode.net.arp → org.jnode.net.ipv4.core
43-
org.jnode.net.ipv4.core → org.jnode.net
7+
Nombre total de cycles détectés: 1
448

459

4610
================================================================================
@@ -144,6 +108,5 @@ Dépendances circulaires (au niveau du code source):
144108
STATISTIQUES
145109
================================================================================
146110

147-
Total de cycles: 2
148-
MEDIUM: 1 cycle(s)
111+
Total de cycles: 1
149112
VERY_HARD: 1 cycle(s)

all/lib/ftp.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
classlib.url=http://jnode.ro//classlib/20160111104759
2-
classlib.md5=b925435dbeccfbf1827a5f7948ae6857
1+
classlib.url=https://github.com/fduminy/classlib6/releases/download/v0.1
2+
classlib.md5=9c56053205e084a266bb2b004b83b99c
33
classlib-src.md5=719fadffc373949a89a0332fb553e518

cli/src/commands/org/jnode/command/net/IfconfigCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.jnode.driver.net.NetworkException;
3232
import org.jnode.naming.InitialNaming;
3333
import org.jnode.net.ethernet.EthernetConstants;
34-
import org.jnode.net.ipv4.IPv4Address;
34+
import org.jnode.net.IPv4Address;
3535
import org.jnode.net.ipv4.config.IPv4ConfigurationService;
3636
import org.jnode.net.syntax.IPv4AddressArgument;
3737
import org.jnode.shell.AbstractCommand;

cli/src/commands/org/jnode/command/net/PingCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
import org.jnode.net.SocketBuffer;
3232
import org.jnode.net.ethernet.EthernetConstants;
33-
import org.jnode.net.ipv4.IPv4Address;
33+
import org.jnode.net.IPv4Address;
3434
import org.jnode.net.ipv4.IPv4Constants;
3535
import org.jnode.net.ipv4.IPv4Header;
3636
import org.jnode.net.ipv4.icmp.ICMPEchoHeader;

cli/src/commands/org/jnode/command/net/ResolverCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.Collection;
2525

2626
import org.jnode.driver.net.NetworkException;
27-
import org.jnode.net.ipv4.IPv4Address;
27+
import org.jnode.net.IPv4Address;
2828
import org.jnode.net.ipv4.util.ResolverImpl;
2929
import org.jnode.net.syntax.IPv4AddressArgument;
3030
import org.jnode.shell.AbstractCommand;

cli/src/commands/org/jnode/command/net/RouteCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.jnode.driver.net.NetworkException;
3131
import org.jnode.naming.InitialNaming;
3232
import org.jnode.net.NoSuchProtocolException;
33-
import org.jnode.net.ipv4.IPv4Address;
33+
import org.jnode.net.IPv4Address;
3434
import org.jnode.net.ipv4.config.IPv4ConfigurationService;
3535
import org.jnode.net.ipv4.layer.IPv4NetworkLayer;
3636
import org.jnode.net.syntax.IPv4AddressArgument;

net/descriptors/org.jnode.driver.net.usb.bluetooth.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
<requires>
3030
<import plugin="org.jnode.driver.bus.usb"/>
31+
<import plugin="org.jnode.net"/>
3132
</requires>
3233

3334
<runtime>

net/descriptors/org.jnode.net.arp.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
<requires>
3030
<import plugin="org.jnode.net"/>
31-
<import plugin="org.jnode.net.ipv4.core"/>
3231
</requires>
3332

3433
<runtime>

net/src/driver/org/jnode/driver/net/usb/UsbNetDeviceToDriverMapper.java renamed to net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDeviceToDriverMapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1919
*/
2020

21-
package org.jnode.driver.net.usb;
21+
package org.jnode.driver.net.usb.bluetooth;
2222

2323
import org.apache.log4j.Logger;
2424
import org.jnode.driver.Device;
@@ -28,16 +28,16 @@
2828
import org.jnode.driver.bus.usb.USBConfiguration;
2929
import org.jnode.driver.bus.usb.USBDevice;
3030
import org.jnode.driver.bus.usb.USBInterface;
31-
import org.jnode.driver.net.usb.bluetooth.UsbBluetoothDriver;
31+
import org.jnode.driver.net.usb.UsbNetConstant;
3232

3333
/**
3434
* This class define driver finder for USB Wireless device.
3535
*
3636
* @author fabien L.
3737
*/
38-
public class UsbNetDeviceToDriverMapper implements DeviceToDriverMapper, UsbNetConstant {
38+
public class UsbBluetoothDeviceToDriverMapper implements DeviceToDriverMapper, UsbNetConstant {
3939

40-
private static final Logger log = Logger.getLogger(UsbNetDeviceToDriverMapper.class);
40+
private static final Logger log = Logger.getLogger(UsbBluetoothDeviceToDriverMapper.class);
4141

4242
public Driver findDriver(Device device) {
4343

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* $Id$
3+
*
4+
* Copyright (C) 2003-2015 JNode.org
5+
*
6+
* This library is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published
8+
* by the Free Software Foundation; either version 2.1 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14+
* License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this library; If not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*/
20+
21+
package org.jnode.net;
22+
23+
import org.jnode.driver.Device;
24+
import org.jnode.util.TimeoutException;
25+
26+
/**
27+
* Interface for ARP services that can resolve protocol addresses to hardware addresses.
28+
* This interface allows IPv4 and other protocols to use ARP without depending on the
29+
* ARP implementation package.
30+
*
31+
* @author epr
32+
*/
33+
public interface ARPService {
34+
35+
/**
36+
* Gets the hardware address for a given protocol address.
37+
*
38+
* @param address The protocol address to resolve
39+
* @param myAddress My protocol address
40+
* @param device The device to use for the ARP request
41+
* @param timeout Timeout in milliseconds
42+
* @return The hardware address
43+
* @throws TimeoutException If the address could not be resolved within the timeout
44+
* @throws org.jnode.driver.net.NetworkException If a network error occurs
45+
*/
46+
HardwareAddress getHardwareAddress(ProtocolAddress address, ProtocolAddress myAddress,
47+
Device device, long timeout) throws TimeoutException, org.jnode.driver.net.NetworkException;
48+
49+
/**
50+
* Sets an entry in the ARP cache.
51+
*
52+
* @param hardwareAddress The hardware address
53+
* @param protocolAddress The protocol address
54+
* @param permanent If true, the entry is permanent and won't expire
55+
*/
56+
void setCacheEntry(HardwareAddress hardwareAddress, ProtocolAddress protocolAddress, boolean permanent);
57+
}

0 commit comments

Comments
 (0)