From 504c704ea00aed83857bf2683bfcef08a6b41fc8 Mon Sep 17 00:00:00 2001 From: matsumu-y <72908018+matsumu-y@users.noreply.github.com> Date: Fri, 1 Apr 2022 20:57:08 +0900 Subject: [PATCH] Enables AMF to accept not-perfect NGAP packets which have not 0 ASN.1 PER padding bit. (#2) * Enables AMF to accept not-perfect NGAP packets which have not 0 ASN.1 PER padding bit. * Use go build -tags skip_padding_check to switch padding check Default will check padding if value is 0 Co-authored-by: free5gc-org --- aper.go | 7 ++++++- padding_check.go | 5 +++++ skip_padding_check.go | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 padding_check.go create mode 100644 skip_padding_check.go diff --git a/aper.go b/aper.go index 272df8e..aafd72f 100644 --- a/aper.go +++ b/aper.go @@ -131,7 +131,12 @@ func (pd *perBitData) parseAlignBits() error { if val, err := pd.getBitsValue(alignBits); err != nil { return err } else if val != 0 { - return fmt.Errorf("Align Bit is not zero") + if skipPaddingCheck { + perTrace(2, "Align Bit is not zero") + perTrace(1, perBitLog(uint64(alignBits), pd.byteOffset, pd.bitsOffset, val)) + } else { + return fmt.Errorf("Align Bit is not zero") + } } } else if pd.bitsOffset != 0 { pd.bitCarry() diff --git a/padding_check.go b/padding_check.go new file mode 100644 index 0000000..322d488 --- /dev/null +++ b/padding_check.go @@ -0,0 +1,5 @@ +// +build !skip_padding_check + +package aper + +const skipPaddingCheck bool = false diff --git a/skip_padding_check.go b/skip_padding_check.go new file mode 100644 index 0000000..45cd9a9 --- /dev/null +++ b/skip_padding_check.go @@ -0,0 +1,5 @@ +// +build skip_padding_check + +package aper + +const skipPaddingCheck bool = true