Add IPv4 / IPv6 selectors definition

This commit is contained in:
Pierre HUBERT 2024-01-04 13:11:43 +01:00
parent 719ab3b265
commit c40ee037da

View File

@ -13,6 +13,7 @@ import {
import { import {
NWFSArp, NWFSArp,
NWFSArpOrRARP, NWFSArpOrRARP,
NWFSIPBase,
NWFSMac, NWFSMac,
NWFSelector, NWFSelector,
NWFilterRule, NWFilterRule,
@ -246,6 +247,14 @@ function NWFSelectorEdit(p: {
<NWFSelectorArp {...p} selector={p.selector} /> <NWFSelectorArp {...p} selector={p.selector} />
)} )}
{p.selector.type === "ipv4" && (
<NWFSelectorIP {...p} selector={p.selector} version={4} />
)}
{p.selector.type === "ipv6" && (
<NWFSelectorIP {...p} selector={p.selector} version={6} />
)}
<TextInput <TextInput
editable={p.editable} editable={p.editable}
label="Comment" label="Comment"
@ -278,6 +287,11 @@ interface SpecificSelectorEditor<E> {
onChange?: () => void; onChange?: () => void;
} }
interface SpecificSelectorEditorWithIPVersion<E>
extends SpecificSelectorEditor<E> {
version: 4 | 6;
}
function NWFSelectorMac( function NWFSelectorMac(
p: SpecificSelectorEditor<NWFSMac> p: SpecificSelectorEditor<NWFSMac>
): React.ReactElement { ): React.ReactElement {
@ -391,3 +405,72 @@ function NWFSelectorArp(
</> </>
); );
} }
function NWFSelectorIP(
p: SpecificSelectorEditorWithIPVersion<NWFSIPBase>
): React.ReactElement {
return (
<>
<MACInput
{...p}
label="Src mac address"
value={p.selector.srcmacaddr}
onValueChange={(v) => {
p.selector.srcmacaddr = v;
p.onChange?.();
}}
/>
<MACInput
{...p}
label="Src mac mask"
value={p.selector.srcmacaddr}
onValueChange={(v) => {
p.selector.srcmacaddr = v;
p.onChange?.();
}}
/>
<MACInput
{...p}
label="Dst mac address"
value={p.selector.dstmacaddr}
onValueChange={(v) => {
p.selector.dstmacaddr = v;
p.onChange?.();
}}
/>
<MACInput
{...p}
label="Dst mac mask"
value={p.selector.dstmacaddr}
onValueChange={(v) => {
p.selector.dstmacaddr = v;
p.onChange?.();
}}
/>
<IPInputWithMask
{...p}
label="Source IP address / mask"
ip={p.selector.srcipaddr}
mask={p.selector.srcipmask}
version={p.version}
onValueChange={(ip, mask) => {
p.selector.srcipaddr = ip;
p.selector.srcipmask = mask;
p.onChange?.();
}}
/>
<IPInputWithMask
{...p}
label="Destination IP address / mask"
ip={p.selector.dstipaddr}
mask={p.selector.dstipmask}
version={p.version}
onValueChange={(ip, mask) => {
p.selector.dstipaddr = ip;
p.selector.dstipmask = mask;
p.onChange?.();
}}
/>
</>
);
}