File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,16 @@ export class ArpTable {
173173
174174 return { onEdit, onRegenerate, onDelete } ;
175175 }
176+
177+ refreshTable ( ) : void {
178+ const updatedEntries = this . props . viewgraph
179+ . getDataGraph ( )
180+ . getArpTable ( this . props . deviceId ) ;
181+
182+ const updatedRows = updatedEntries . map ( ( entry ) => [ entry . ip , entry . mac ] ) ;
183+
184+ this . updateRows ( updatedRows ) ;
185+ }
176186}
177187
178188function isValidMAC ( mac : string ) : boolean {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { ProgressBar } from "../basic_components/progress_bar";
1616import { LabeledProgressBar } from "../components/labeled_progress_bar" ;
1717import { ArpTable } from "./arp_table" ;
1818import { Layer } from "../../types/layer" ;
19+ import { DataNetworkDevice } from "../../types/data-devices" ;
1920
2021export class DeviceInfo extends BaseInfo {
2122 readonly device : ViewDevice ;
@@ -157,6 +158,18 @@ export class DeviceInfo extends BaseInfo {
157158 } ) ;
158159
159160 this . inputFields . push ( arpTable . toHTML ( ) ) ;
161+
162+ const dataDevice = viewgraph . getDataGraph ( ) . getDevice ( deviceId ) ;
163+
164+ if ( dataDevice instanceof DataNetworkDevice ) {
165+ // Suscribe to ARP table changes
166+ dataDevice . setArpTableChangeListener ( ( ) => {
167+ // update the ARP table in the UI
168+ arpTable . refreshTable ( ) ;
169+ } ) ;
170+ } else {
171+ console . warn ( `Device with ID ${ deviceId } is not a DataNetworkDevice.` ) ;
172+ }
160173 }
161174}
162175
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export abstract class DataNetworkDevice extends DataDevice {
77 ip : IpAddress ;
88 ipMask : IpAddress ;
99 arpTable : Map < string , string > ;
10+ private arpTableChangeListener : ( ( ) => void ) | null = null ;
1011
1112 constructor ( graphData : NetworkDataNode , datagraph : DataGraph ) {
1213 super ( graphData , datagraph ) ;
@@ -17,8 +18,21 @@ export abstract class DataNetworkDevice extends DataDevice {
1718
1819 abstract receiveDatagram ( datagram : IPv4Packet ) : void ;
1920
20- updateArpTable ( mac : MacAddress , ip : IpAddress ) {
21+ /**
22+ * Update the ARP table and notify the listener.
23+ */
24+ updateArpTable ( mac : MacAddress , ip : IpAddress ) : void {
2125 this . arpTable . set ( ip . toString ( ) , mac . toString ( ) ) ;
26+ if ( this . arpTableChangeListener ) {
27+ this . arpTableChangeListener ( ) ; // Notify the listener
28+ }
29+ }
30+
31+ /**
32+ * Set the listener for ARP table changes.
33+ */
34+ setArpTableChangeListener ( listener : ( ) => void ) : void {
35+ this . arpTableChangeListener = listener ;
2236 }
2337
2438 resolveAddress ( ip : IpAddress ) : MacAddress {
You can’t perform that action at this time.
0 commit comments