mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-06 10:05:22 +03:00
Wire gns3-server to uBridge's real-time marker controls (contract
../ubridge/doc/gns3server-integration.md §3.2), in three layers:
A. enabled reaches uBridge — _markers_for_node no longer drops disabled
markers controller-side; it carries `enabled` in the NIO spec. apply
installs every marker then issues `enable_packet_filter … off` for the
disabled ones (base_node bridge / iou iol_bridge; old-ubridge errors
downgrade to a warning so a toggle can't break link create).
B. instant per-filter toggle — apply records name→bridge so a new
`_ubridge_set_marker_filter_state` can flip a running filter with
`enable_packet_filter on|off` (iou overrides for iol_bridge + bay/unit).
Each marker-capable node type gains PUT /markers/{name}; update_marker
short-circuits to it when only `enabled` changes (no NIO rebuild, no pcap
flush), falling back to reset+reapply if the route is unavailable.
C. global pause/resume — `_ubridge_marker_pause/resume` send `marker pause`
/ `marker resume` direct to the hypervisor (pause stops signal+pcap,
resume instant, sink retained). Six node-type routes add POST
/markers/pause|resume; project.pause_all/resume_all_markers fan out to
each capture node (deduped, best-effort); REST exposes
POST /projects/{id}/markers/pause|resume.
Toggling enabled and pause/resume are now both instant — only marker create
or a bpf change still go through reset+reapply.
78 lines
2.1 KiB
Python
78 lines
2.1 KiB
Python
#
|
|
# Copyright (C) 2020 GNS3 Technologies Inc.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from enum import Enum
|
|
|
|
|
|
class UDPNIOType(str, Enum):
|
|
|
|
udp = "nio_udp"
|
|
|
|
|
|
class UDPNIO(BaseModel):
|
|
"""
|
|
UDP Network Input/Output properties.
|
|
"""
|
|
|
|
type: UDPNIOType
|
|
lport: int = Field(..., gt=0, le=65535, description="Local port")
|
|
rhost: str = Field(..., description="Remote host")
|
|
rport: int = Field(..., gt=0, le=65535, description="Remote port")
|
|
suspend: Optional[bool] = Field(None, description="Suspend the NIO")
|
|
filters: Optional[dict] = Field(None, description="Packet filters")
|
|
markers: Optional[dict] = Field(None, description="Traffic-insight markers")
|
|
|
|
|
|
class EthernetNIOType(str, Enum):
|
|
|
|
ethernet = "nio_ethernet"
|
|
|
|
|
|
class EthernetNIO(BaseModel):
|
|
"""
|
|
Generic Ethernet Network Input/Output properties.
|
|
"""
|
|
|
|
type: EthernetNIOType
|
|
ethernet_device: str = Field(..., description="Ethernet device name e.g. eth0")
|
|
|
|
|
|
class TAPNIOType(str, Enum):
|
|
|
|
tap = "nio_tap"
|
|
|
|
|
|
class TAPNIO(BaseModel):
|
|
"""
|
|
TAP Network Input/Output properties.
|
|
"""
|
|
|
|
type: TAPNIOType
|
|
tap_device: str = Field(..., description="TAP device name e.g. tap0")
|
|
|
|
|
|
class MarkerToggle(BaseModel):
|
|
"""
|
|
Body for the per-marker enable/disable toggle endpoint: flips a running
|
|
uBridge marker filter with ``enable_packet_filter on|off`` (no NIO rebuild,
|
|
so the pcap identity and emitted counter are preserved).
|
|
"""
|
|
|
|
enabled: bool
|