Skip to content

Commit

Permalink
Add Header Enrichment (#4738)
Browse files Browse the repository at this point in the history
Signed-off-by: HannaFar <hannafarag159@gmail.com>
  • Loading branch information
HannaFar committed Feb 12, 2021
1 parent 753a40b commit c79b9cb
Show file tree
Hide file tree
Showing 9 changed files with 586 additions and 128 deletions.
60 changes: 60 additions & 0 deletions nms/app/packages/magmalte/app/components/GatewayUtils.js
Expand Up @@ -187,3 +187,63 @@ export const DynamicServices = Object.freeze({
EVENTD: 'eventd',
TD_AGENT_BIT: 'td-agent-bit',
});

export const DEFAULT_GATEWAY_CONFIG = {
apn_resources: {},
cellular: {
epc: {
ip_block: '192.168.128.0/24',
nat_enabled: true,
dns_primary: '',
dns_secondary: '',
sgi_management_iface_gw: '',
sgi_management_iface_static_ip: '',
sgi_management_iface_vlan: '',
},
ran: {
pci: 260,
transmit_enabled: true,
},
},
connected_enodeb_serials: [],
description: '',
device: {
hardware_id: '',
key: {
key: '',
key_type: 'SOFTWARE_ECDSA_SHA256',
},
},
id: '',
magmad: {
autoupgrade_enabled: true,
autoupgrade_poll_interval: 60,
checkin_interval: 60,
checkin_timeout: 30,
dynamic_services: [DynamicServices.EVENTD, DynamicServices.TD_AGENT_BIT],
},
name: '',
status: {
platform_info: {
packages: [
{
version: '',
},
],
},
},
tier: 'default',
};
export const DEFAULT_DNS_CONFIG = {
enable_caching: false,
local_ttl: 0,
records: [],
};
export const DEFAULT_HE_CONFIG = {
enable_encryption: false,
encryption_key: '',
enable_header_enrichment: false,
he_encoding_type: 'BASE64',
he_encryption_algorithm: 'RC4',
he_hash_function: 'MD5',
};
16 changes: 14 additions & 2 deletions nms/app/packages/magmalte/app/state/lte/EquipmentState.js
Expand Up @@ -17,6 +17,7 @@ import type {EnodebInfo} from '../../components/lte/EnodebUtils';
import type {EnodebState} from '../../components/context/EnodebContext';
import type {
enodeb_serials,
gateway_cellular_configs,
gateway_dns_configs,
gateway_epc_configs,
gateway_id,
Expand Down Expand Up @@ -130,11 +131,11 @@ export async function FetchEnodebs(props: FetchProps) {
enodebSerial: id,
},
);
const newEnb = {[id]: {enb_state: newEnbSt || {}, enb: enb}};
const newEnb = {[id]: {enb_state: newEnbSt, enb: enb}};
return newEnb;
}
} catch (e) {
return {[id]: {enb_state: {} || {}, enb: enb}};
return {[id]: {enb_state: {}, enb: enb}};
}
} else {
enb = await MagmaV1API.getLteByNetworkIdEnodebs({networkId});
Expand Down Expand Up @@ -318,6 +319,7 @@ export type UpdateGatewayProps = {
epcConfigs?: gateway_epc_configs,
ranConfigs?: gateway_ran_configs,
dnsConfig?: gateway_dns_configs,
cellularConfigs?: gateway_cellular_configs,
enbs?: enodeb_serials,
networkId: network_id,
setLteGateways: ({[string]: lte_gateway}) => void,
Expand Down Expand Up @@ -380,6 +382,16 @@ export async function UpdateGateway(props: UpdateGatewayProps) {
}),
);
}

if (props.cellularConfigs) {
requests.push(
MagmaV1API.putLteByNetworkIdGatewaysByGatewayIdCellular({
networkId,
gatewayId: gatewayId,
config: props.cellularConfigs,
}),
);
}
await Promise.all(requests);
const gateways = await MagmaV1API.getLteByNetworkIdGateways({
networkId,
Expand Down
Expand Up @@ -47,7 +47,7 @@ import EnodeConfigEditTdd from './EnodebDetailConfigTdd';
import {AltFormField} from '../../components/FormField';
import {colors, typography} from '../../theme/default';
import {makeStyles} from '@material-ui/styles';
import {useContext, useState} from 'react';
import {useContext, useEffect, useState} from 'react';
import {useEnqueueSnackbar} from '@fbcnms/ui/hooks/useSnackbar';
import {useRouter} from '@fbcnms/ui/hooks';

Expand Down Expand Up @@ -160,10 +160,14 @@ function EnodeEditDialog(props: DialogProps) {

const onClose = () => {
// clear existing state
setEnb({});
props.onClose();
};

useEffect(() => {
setTabPos(editProps ? EditTableType[editProps.editTable] : 0);
setEnb({});
}, [editProps, open]);

return (
<Dialog data-testid="editDialog" open={open} fullWidth={true} maxWidth="sm">
<DialogTitle
Expand Down
Expand Up @@ -170,6 +170,13 @@ export default function GatewayConfig() {
/>
<GatewayRAN gwInfo={gwInfo} />
</Grid>
<Grid item xs={12}>
<CardTitleRow
label="Header Enrichment"
filter={() => editFilter({editTable: 'headerEnrichment'})}
/>
<GatewayHE gwInfo={gwInfo} />
</Grid>
</Grid>
</Grid>
</Grid>
Expand Down Expand Up @@ -405,3 +412,49 @@ function ApnResourcesTable({gwInfo}: {gwInfo: lte_gateway}) {
/>
);
}

function GatewayHE({gwInfo}: {gwInfo: lte_gateway}) {
const heEnabled =
gwInfo.cellular.he_config?.enable_header_enrichment ?? false;
const encryptionEnabled =
gwInfo.cellular.he_config?.enable_encryption ?? false;
const EncryptionDetail = () => {
const encryptionConfig: DataRows[] = [
[
{
category: 'Encryption Key',
value: gwInfo.cellular.he_config?.encryption_key || '',
obscure: true,
},
{
category: 'Encoding Type',
value: gwInfo.cellular.he_config?.he_encoding_type || '',
},
],
[
{
category: 'Encryption Algorithm',
value: gwInfo.cellular.he_config?.he_encryption_algorithm || '',
},
{
category: 'Hash Function',
value: gwInfo.cellular.he_config?.he_hash_function || '',
},
],
];
return <DataGrid data={encryptionConfig} />;
};

const heConfig: DataRows[] = [
[
{
statusCircle: true,
status: heEnabled,
category: 'Header Enrichment',
value: heEnabled ? 'Enabled' : 'Disabled',
collapse: encryptionEnabled ? <EncryptionDetail /> : <></>,
},
],
];
return <DataGrid data={heConfig} />;
}

0 comments on commit c79b9cb

Please sign in to comment.