From 77a9a4ce9c760f19ea96b4b5ed57e01fec770f34 Mon Sep 17 00:00:00 2001 From: gab-arrobo Date: Wed, 2 Oct 2024 16:03:38 -0700 Subject: [PATCH] Replace `logrus` with `zap` logger (#51) * Replace `logrus` with `zap` logger Signed-off-by: Arrobo, Gabriel * Remove unused file Signed-off-by: Arrobo, Gabriel * Update `util` version Signed-off-by: Arrobo, Gabriel --------- Signed-off-by: Arrobo, Gabriel --- .fossa.yml | 20 ---- VERSION | 2 +- go.mod | 35 +----- go.sum | 100 +++--------------- logger/logger.go | 80 +++++++------- nasConvert/AmfId.go | 5 +- nasConvert/GPRSTimer2.go | 4 +- nasConvert/MobileIdentity5GS.go | 2 +- nasConvert/ProtocolConfigurationOptions.go | 57 +++++----- nasConvert/ServiceAreaList.go | 2 +- nasConvert/SessionAMBR.go | 3 +- nasConvert/Snssai.go | 4 +- nasConvert/TaiList.go | 4 +- nasConvert/UPUInfo.go | 8 +- nasMessage/NAS_AuthenticationFailure.go | 2 - nasMessage/NAS_AuthenticationFailure_test.go | 6 +- nasMessage/NAS_AuthenticationReject.go | 2 - nasMessage/NAS_AuthenticationReject_test.go | 3 +- nasMessage/NAS_AuthenticationRequest.go | 2 - nasMessage/NAS_AuthenticationRequest_test.go | 6 +- nasMessage/NAS_AuthenticationResponse.go | 2 - nasMessage/NAS_AuthenticationResponse_test.go | 1 - nasMessage/NAS_AuthenticationResult.go | 2 - nasMessage/NAS_ConfigurationUpdateCommand.go | 2 - nasMessage/NAS_ConfigurationUpdateComplete.go | 2 - nasMessage/NAS_DLNASTransport.go | 27 ----- ...rationAcceptUEOriginatingDeregistration.go | 2 - ...trationAcceptUETerminatedDeregistration.go | 2 - ...ationRequestUEOriginatingDeregistration.go | 2 - ...rationRequestUETerminatedDeregistration.go | 2 - nasMessage/NAS_IdentityRequest.go | 2 - nasMessage/NAS_IdentityRequest_test.go | 1 - nasMessage/NAS_IdentityResponse.go | 2 - nasMessage/NAS_IdentityResponse_test.go | 1 - nasMessage/NAS_Notification.go | 2 - nasMessage/NAS_NotificationResponse.go | 2 - nasMessage/NAS_Notification_test.go | 1 - .../NAS_PDUSessionAuthenticationCommand.go | 2 - .../NAS_PDUSessionAuthenticationComplete.go | 2 - .../NAS_PDUSessionAuthenticationResult.go | 2 - .../NAS_PDUSessionEstablishmentAccept.go | 2 - .../NAS_PDUSessionEstablishmentReject.go | 2 - .../NAS_PDUSessionEstablishmentRequest.go | 2 - .../NAS_PDUSessionModificationCommand.go | 2 - ...NAS_PDUSessionModificationCommandReject.go | 2 - .../NAS_PDUSessionModificationComplete.go | 2 - .../NAS_PDUSessionModificationReject.go | 2 - .../NAS_PDUSessionModificationRequest.go | 2 - nasMessage/NAS_PDUSessionReleaseCommand.go | 2 - .../NAS_PDUSessionReleaseCommand_test.go | 2 - nasMessage/NAS_PDUSessionReleaseComplete.go | 2 - .../NAS_PDUSessionReleaseComplete_test.go | 4 - nasMessage/NAS_PDUSessionReleaseReject.go | 2 - nasMessage/NAS_PDUSessionReleaseRequest.go | 2 - nasMessage/NAS_RegistrationAccept.go | 2 - nasMessage/NAS_RegistrationComplete.go | 2 - nasMessage/NAS_RegistrationReject.go | 2 - nasMessage/NAS_RegistrationRequest.go | 2 - nasMessage/NAS_RegistrationRequest_test.go | 4 - nasMessage/NAS_SecurityModeCommand.go | 2 - nasMessage/NAS_SecurityModeComplete.go | 2 - nasMessage/NAS_SecurityModeReject.go | 2 - .../NAS_SecurityProtected5GSNASMessage.go | 2 - nasMessage/NAS_ServiceAccept.go | 2 - nasMessage/NAS_ServiceAccept_test.go | 5 +- nasMessage/NAS_ServiceReject.go | 2 - nasMessage/NAS_ServiceRequest.go | 2 - nasMessage/NAS_Status5GMM.go | 2 - nasMessage/NAS_Status5GSM.go | 2 - nasMessage/NAS_ULNASTransport.go | 2 - nasTestpacket/NasPdu.go | 57 +++++----- nasType/comm_util.go | 2 - security/security.go | 16 +-- 73 files changed, 143 insertions(+), 407 deletions(-) delete mode 100644 .fossa.yml diff --git a/.fossa.yml b/.fossa.yml deleted file mode 100644 index 65ea49a..0000000 --- a/.fossa.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2020-present Open Networking Foundation -# -# SPDX-License-Identifier: Apache-2.0 -# -# Generated by FOSSA CLI (https://github.com/fossas/fossa-cli) -# Visit https://fossa.com to learn more -# -# Usage: FOSSA_API_KEY=<> fossa analyze -# -T is not supported at this moment from fossa side. -version: 2 -cli: - server: https://app.fossa.com - fetcher: custom - project: nas -analyze: - modules: - - name: nas - type: raw - target: ../nas - path: ../nas diff --git a/VERSION b/VERSION index 625610e..88c5fb8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.1-dev +1.4.0 diff --git a/go.mod b/go.mod index d599152..98f096c 100644 --- a/go.mod +++ b/go.mod @@ -4,47 +4,22 @@ go 1.21 require ( github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1 - github.com/antonfisher/nested-logrus-formatter v1.3.1 - github.com/omec-project/openapi v1.2.0 - github.com/omec-project/util v1.1.0 - github.com/sirupsen/logrus v1.9.3 + github.com/omec-project/openapi v1.3.1 + github.com/omec-project/util v1.2.1 github.com/smartystreets/goconvey v1.8.1 github.com/stretchr/testify v1.9.0 + go.uber.org/zap v1.27.0 ) require ( - github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect - github.com/bytedance/sonic v1.9.1 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.9.1 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.0 // indirect - github.com/goccy/go-json v0.10.2 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect + github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/gopherjs/gopherjs v1.17.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kr/pretty v0.3.1 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/smarty/assertions v1.15.0 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect - golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + go.uber.org/multierr v1.10.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ef33be4..acda1c6 100644 --- a/go.sum +++ b/go.sum @@ -1,49 +1,14 @@ github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1 h1:+JkXLHME8vLJafGhOH4aoV2Iu8bR55nU6iKMVfYVLjY= github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1/go.mod h1:nuudZmJhzWtx2212z+pkuy7B6nkBqa+xwNXZHL1j8cg= -github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= -github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -51,70 +16,29 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/omec-project/openapi v1.2.0 h1:7Wvi0HLvhvxMyQtqGcqtMCPC/0QCGAFP5htrXCfWxRc= -github.com/omec-project/openapi v1.2.0/go.mod h1:hjU13MB1m9MHTko87JfsUNCdeD6/m6VkNZDD8Vq5U9M= -github.com/omec-project/util v1.1.0 h1:TUuLmzqTLChIEXQlK9g5Ihgmw4FUm/UJnjfu0wT8Gz0= -github.com/omec-project/util v1.1.0/go.mod h1:BEv8nCokB4j0fgAQ6VVkKuQ2PSP3DJMEmz25pFMw5X8= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/omec-project/openapi v1.3.1 h1:NCteMRdMtWnMhf1CXYduuLgeu8fEhc/7XO1CiE7fN3Y= +github.com/omec-project/openapi v1.3.1/go.mod h1:cR6Iharp2TLOzEmskQ/EdCVFZnpKh0zTvUSSuyXAYLE= +github.com/omec-project/util v1.2.1 h1:+o5kbnZzKBmbqT4oprVGPgL0jH5b8BvRMfLye5srGQ4= +github.com/omec-project/util v1.2.1/go.mod h1:kUF2LXhmtw+m7Bk5IGOMFLj7CA8VKtilLI/9QBJcfxE= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY= github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec= github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY= github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/logger/logger.go b/logger/logger.go index c7204ee..87b43ac 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -1,62 +1,62 @@ // Copyright 2019 free5GC.org +// SPDX-FileCopyrightText: 2024 Intel Corporation // // SPDX-License-Identifier: Apache-2.0 -// package logger import ( - "os" - "time" - - formatter "github.com/antonfisher/nested-logrus-formatter" - "github.com/omec-project/util/logger" - "github.com/omec-project/util/logger_conf" - "github.com/sirupsen/logrus" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) var ( - log *logrus.Logger - NasLog *logrus.Entry - NasMsgLog *logrus.Entry - ConvertLog *logrus.Entry - SecurityLog *logrus.Entry + log *zap.Logger + NasLog *zap.SugaredLogger + NasMsgLog *zap.SugaredLogger + ConvertLog *zap.SugaredLogger + SecurityLog *zap.SugaredLogger + atomicLevel zap.AtomicLevel ) func init() { - log = logrus.New() - log.SetReportCaller(false) - - log.Formatter = &formatter.Formatter{ - TimestampFormat: time.RFC3339, - TrimMessages: true, - NoFieldsSpace: true, - HideKeys: true, - FieldsOrder: []string{"component", "category"}, - } - - free5gcLogHook, err := logger.NewFileHook(logger_conf.Free5gcLogFile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(free5gcLogHook) + atomicLevel = zap.NewAtomicLevelAt(zap.InfoLevel) + config := zap.Config{ + Level: atomicLevel, + Development: false, + Encoding: "console", + EncoderConfig: zap.NewProductionEncoderConfig(), + OutputPaths: []string{"stdout"}, + ErrorOutputPaths: []string{"stderr"}, } - selfLogHook, err := logger.NewFileHook(logger_conf.LibLogDir+"nas.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(selfLogHook) + config.EncoderConfig.TimeKey = "timestamp" + config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder + config.EncoderConfig.LevelKey = "level" + config.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder + config.EncoderConfig.CallerKey = "caller" + config.EncoderConfig.EncodeCaller = zapcore.ShortCallerEncoder + config.EncoderConfig.MessageKey = "message" + config.EncoderConfig.StacktraceKey = "" + + var err error + log, err = config.Build() + if err != nil { + panic(err) } - NasLog = log.WithFields(logrus.Fields{"component": "LIB", "category": "NAS"}) - NasMsgLog = log.WithFields(logrus.Fields{"component": "NAS", "category": "Message"}) - ConvertLog = log.WithFields(logrus.Fields{"component": "NAS", "category": "Convert"}) - SecurityLog = log.WithFields(logrus.Fields{"component": "NAS", "category": "Security"}) + NasLog = log.Sugar().With("component", "LIB", "category", "NAS") + NasMsgLog = log.Sugar().With("component", "NAS", "category", "Message") + ConvertLog = log.Sugar().With("component", "NAS", "category", "Convert") + SecurityLog = log.Sugar().With("component", "NAS", "category", "Security") } -func SetLogLevel(level logrus.Level) { - NasLog.Infoln("set log level :", level) - log.SetLevel(level) +func GetLogger() *zap.Logger { + return log } -func SetReportCaller(set bool) { - NasLog.Infoln("set report call :", set) - log.SetReportCaller(set) +// SetLogLevel: set the log level (panic|fatal|error|warn|info|debug) +func SetLogLevel(level zapcore.Level) { + NasLog.Infoln("set log level:", level) + atomicLevel.SetLevel(level) } diff --git a/nasConvert/AmfId.go b/nasConvert/AmfId.go index 21bcc8e..cf00252 100644 --- a/nasConvert/AmfId.go +++ b/nasConvert/AmfId.go @@ -7,13 +7,14 @@ package nasConvert import ( "encoding/hex" - "log" + + "github.com/omec-project/nas/logger" ) func AmfIdToNas(amfId string) (amfRegionId uint8, amfSetId uint16, amfPointer uint8) { amfIdBytes, err := hex.DecodeString(amfId) if err != nil { - log.Printf("amfId decode failed: %+v", err) + logger.ConvertLog.Errorf("amfId decode failed: %+v", err) } amfRegionId = uint8(amfIdBytes[0]) diff --git a/nasConvert/GPRSTimer2.go b/nasConvert/GPRSTimer2.go index 844bff6..adfd816 100644 --- a/nasConvert/GPRSTimer2.go +++ b/nasConvert/GPRSTimer2.go @@ -16,7 +16,7 @@ func GPRSTimer2ToNas(timerValue int) (timerValueNas uint8) { if timerValue <= 64 { if timerValue%2 != 0 { - logger.ConvertLog.Error("timer Value is not multiples of 2 seconds") + logger.ConvertLog.Errorln("timer Value is not multiples of 2 seconds") return } timerValueNas = uint8(timerValue / 2) @@ -26,7 +26,7 @@ func GPRSTimer2ToNas(timerValue int) (timerValueNas uint8) { timerValueNas = (timerValueNas | 0x20) + t } else { if t%6 != 0 { - logger.ConvertLog.Error("timer Value is not multiples of decihours") + logger.ConvertLog.Errorln("timer Value is not multiples of decihours") return } t = t / 6 diff --git a/nasConvert/MobileIdentity5GS.go b/nasConvert/MobileIdentity5GS.go index 58882e6..ddcf68b 100644 --- a/nasConvert/MobileIdentity5GS.go +++ b/nasConvert/MobileIdentity5GS.go @@ -174,7 +174,7 @@ func GutiToNas(guti string) nasType.GUTI5G { gutiNas.SetAMFSetID(amfSetId) gutiNas.SetAMFPointer(amfPointer) if tmsiBytes, err := hex.DecodeString(tmsi); err != nil { - logger.ConvertLog.Warnf("Decode TMSI failed: %+v", err) + logger.ConvertLog.Warnf("decode TMSI failed: %+v", err) } else { copy(gutiNas.Octet[7:11], tmsiBytes[:]) } diff --git a/nasConvert/ProtocolConfigurationOptions.go b/nasConvert/ProtocolConfigurationOptions.go index 9ab5db9..6ecc86f 100644 --- a/nasConvert/ProtocolConfigurationOptions.go +++ b/nasConvert/ProtocolConfigurationOptions.go @@ -10,7 +10,6 @@ import ( "encoding/binary" "fmt" "net" - "strconv" "github.com/omec-project/nas/logger" "github.com/omec-project/nas/nasMessage" @@ -60,18 +59,18 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) Marshal() []by metaInfo = (extension << 7) | (spare << 6) | (configurationProtocol) if err := binary.Write(buffer, binary.BigEndian, &metaInfo); err != nil { - logger.ConvertLog.Warnf("Write metaInfo failed: %+v", err) + logger.ConvertLog.Warnf("write metaInfo failed: %+v", err) } for _, containerUnit := range protocolConfigurationOptions.ProtocolOrContainerList { if err := binary.Write(buffer, binary.BigEndian, &containerUnit.ProtocolOrContainerID); err != nil { - logger.ConvertLog.Warnf("Write protocolOrContainerID failed: %+v", err) + logger.ConvertLog.Warnf("write protocolOrContainerID failed: %+v", err) } if err := binary.Write(buffer, binary.BigEndian, &containerUnit.LengthOfContents); err != nil { - logger.ConvertLog.Warnf("Write length of contents failed: %+v", err) + logger.ConvertLog.Warnf("write length of contents failed: %+v", err) } if err := binary.Write(buffer, binary.BigEndian, &containerUnit.Contents); err != nil { - logger.ConvertLog.Warnf("Write contents failed: %+v", err) + logger.ConvertLog.Warnf("write contents failed: %+v", err) } } @@ -79,7 +78,7 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) Marshal() []by } func (protocolConfigurationOptions *ProtocolConfigurationOptions) UnMarshal(data []byte) error { - logger.ConvertLog.Traceln("In ProtocolConfigurationOptions UnMarshal") + logger.ConvertLog.Debugln("in ProtocolConfigurationOptions UnMarshal") var Buf uint8 numOfBytes := len(data) @@ -99,20 +98,20 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) UnMarshal(data if err := binary.Read(byteReader, binary.BigEndian, &curContainer.ProtocolOrContainerID); err != nil { return err } - logger.ConvertLog.Traceln("Reading ID: ", strconv.Itoa(int(curContainer.ProtocolOrContainerID))) + logger.ConvertLog.Debugln("reading ID:", curContainer.ProtocolOrContainerID) readingState = ReadingLength numOfBytes = numOfBytes - 2 case ReadingLength: if err := binary.Read(byteReader, binary.BigEndian, &curContainer.LengthOfContents); err != nil { return err } - logger.ConvertLog.Traceln("Reading Length: ", strconv.Itoa(int(curContainer.LengthOfContents))) + logger.ConvertLog.Debugln("reading Length:", curContainer.LengthOfContents) readingState = ReadingContent numOfBytes = numOfBytes - 1 if curContainer.LengthOfContents == 0 { protocolConfigurationOptions.ProtocolOrContainerList = append( protocolConfigurationOptions.ProtocolOrContainerList, curContainer) - logger.ConvertLog.Traceln("For loop ProtocolOrContainerList: ", + logger.ConvertLog.Debugln("for loop ProtocolOrContainerList:", protocolConfigurationOptions.ProtocolOrContainerList) } case ReadingContent: @@ -123,7 +122,7 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) UnMarshal(data } protocolConfigurationOptions.ProtocolOrContainerList = append( protocolConfigurationOptions.ProtocolOrContainerList, curContainer) - logger.ConvertLog.Traceln("For loop ProtocolOrContainerList: ", + logger.ConvertLog.Debugln("for loop ProtocolOrContainerList:", protocolConfigurationOptions.ProtocolOrContainerList) } numOfBytes = numOfBytes - int(curContainer.LengthOfContents) @@ -131,7 +130,7 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) UnMarshal(data } } - logger.ConvertLog.Infoln("ProtocolOrContainerList: ", protocolConfigurationOptions.ProtocolOrContainerList) + logger.ConvertLog.Infoln("protocolOrContainerList:", protocolConfigurationOptions.ProtocolOrContainerList) return nil } @@ -167,24 +166,22 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) AddIPAddressAl func (protocolConfigurationOptions *ProtocolConfigurationOptions) AddDNSServerIPv4Address(dnsIP net.IP) (err error) { if dnsIP.To4() == nil { - err = fmt.Errorf("the DNS IP should be IPv4 in AddDNSServerIPv4Address") - return + return fmt.Errorf("the DNS IP should be IPv4 in AddDNSServerIPv4Address") } dnsIP = dnsIP.To4() if len(dnsIP) != net.IPv4len { - err = fmt.Errorf("the length of DNS IPv4 is wrong") - return + return fmt.Errorf("the length of DNS IPv4 is wrong") } - logger.ConvertLog.Traceln("In AddDNSServerIPv4Address") + logger.ConvertLog.Debugln("in AddDNSServerIPv4Address") protocolOrContainerUnit := NewProtocolOrContainerUnit() protocolOrContainerUnit.ProtocolOrContainerID = nasMessage.DNSServerIPv4AddressDL protocolOrContainerUnit.LengthOfContents = uint8(net.IPv4len) - logger.ConvertLog.Traceln("LengthOfContents: ", protocolOrContainerUnit.LengthOfContents) + logger.ConvertLog.Debugln("lengthOfContents:", protocolOrContainerUnit.LengthOfContents) protocolOrContainerUnit.Contents = append(protocolOrContainerUnit.Contents, dnsIP.To4()...) - logger.ConvertLog.Traceln("Contents: ", protocolOrContainerUnit.Contents) + logger.ConvertLog.Debugln("contents:", protocolOrContainerUnit.Contents) protocolConfigurationOptions.ProtocolOrContainerList = append(protocolConfigurationOptions.ProtocolOrContainerList, protocolOrContainerUnit) @@ -193,23 +190,21 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) AddDNSServerIP func (protocolConfigurationOptions *ProtocolConfigurationOptions) AddPCSCFIPv4Address(pcscfIP net.IP) (err error) { if pcscfIP.To4() == nil { - err = fmt.Errorf("the P-CSCF IP should be IPv4") - return + return fmt.Errorf("the P-CSCF IP should be IPv4") } pcscfIP = pcscfIP.To4() if len(pcscfIP) != net.IPv4len { - err = fmt.Errorf("the length of P-CSCF IP IPv4 is wrong") - return + return fmt.Errorf("the length of P-CSCF IP IPv4 is wrong") } - logger.ConvertLog.Traceln("In AddDNSServerIPv4Address") + logger.ConvertLog.Debugln("in AddDNSServerIPv4Address") protocolOrContainerUnit := NewProtocolOrContainerUnit() protocolOrContainerUnit.ProtocolOrContainerID = nasMessage.PCSCFIPv4AddressDL protocolOrContainerUnit.LengthOfContents = uint8(net.IPv4len) - logger.ConvertLog.Traceln("LengthOfContents: ", protocolOrContainerUnit.LengthOfContents) + logger.ConvertLog.Debugln("lengthOfContents:", protocolOrContainerUnit.LengthOfContents) protocolOrContainerUnit.Contents = append(protocolOrContainerUnit.Contents, pcscfIP.To4()...) - logger.ConvertLog.Traceln("Contents: ", protocolOrContainerUnit.Contents) + logger.ConvertLog.Debugln("contents:", protocolOrContainerUnit.Contents) protocolConfigurationOptions.ProtocolOrContainerList = append(protocolConfigurationOptions.ProtocolOrContainerList, protocolOrContainerUnit) @@ -218,13 +213,11 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) AddPCSCFIPv4Ad func (protocolConfigurationOptions *ProtocolConfigurationOptions) AddDNSServerIPv6Address(dnsIP net.IP) (err error) { if dnsIP.To16() == nil { - err = fmt.Errorf("the DNS IP should be IPv6 in AddDNSServerIPv6Address") - return + return fmt.Errorf("the DNS IP should be IPv6 in AddDNSServerIPv6Address") } if len(dnsIP) != net.IPv6len { - err = fmt.Errorf("the length of DNS IPv6 is wrong") - return + return fmt.Errorf("the length of DNS IPv6 is wrong") } protocolOrContainerUnit := NewProtocolOrContainerUnit() @@ -239,14 +232,14 @@ func (protocolConfigurationOptions *ProtocolConfigurationOptions) AddDNSServerIP } func (protocolConfigurationOptions *ProtocolConfigurationOptions) AddIPv4LinkMTU(mtu uint16) (err error) { - logger.ConvertLog.Traceln("In AddIPv4LinkMTU") + logger.ConvertLog.Debugln("in AddIPv4LinkMTU") protocolOrContainerUnit := NewProtocolOrContainerUnit() protocolOrContainerUnit.ProtocolOrContainerID = nasMessage.IPv4LinkMTUDL protocolOrContainerUnit.LengthOfContents = 2 - logger.ConvertLog.Traceln("LengthOfContents: ", protocolOrContainerUnit.LengthOfContents) + logger.ConvertLog.Debugln("lengthOfContents:", protocolOrContainerUnit.LengthOfContents) protocolOrContainerUnit.Contents = append(protocolOrContainerUnit.Contents, []byte{uint8(mtu >> 8), uint8(mtu & 0xff)}...) - logger.ConvertLog.Traceln("Contents: ", protocolOrContainerUnit.Contents) + logger.ConvertLog.Debugln("contents:", protocolOrContainerUnit.Contents) protocolConfigurationOptions.ProtocolOrContainerList = append(protocolConfigurationOptions.ProtocolOrContainerList, protocolOrContainerUnit) return diff --git a/nasConvert/ServiceAreaList.go b/nasConvert/ServiceAreaList.go index 939fac6..ae51159 100644 --- a/nasConvert/ServiceAreaList.go +++ b/nasConvert/ServiceAreaList.go @@ -35,7 +35,7 @@ func PartialServiceAreaListToNas(plmnID models.PlmnId, serviceAreaRestriction mo for _, area := range serviceAreaRestriction.Areas { for _, tac := range area.Tacs { if tacBytes, err := hex.DecodeString(tac); err != nil { - logger.ConvertLog.Warnf("Decode tac failed: %+v", err) + logger.ConvertLog.Warnf("decode tac failed: %+v", err) } else { partialServiceAreaList = append(partialServiceAreaList, tacBytes...) } diff --git a/nasConvert/SessionAMBR.go b/nasConvert/SessionAMBR.go index fa71e81..38fbe77 100644 --- a/nasConvert/SessionAMBR.go +++ b/nasConvert/SessionAMBR.go @@ -7,7 +7,6 @@ package nasConvert import ( "encoding/binary" - "fmt" "strconv" "strings" @@ -18,7 +17,7 @@ import ( ) func ModelsToSessionAMBR(ambr *models.Ambr) (sessAmbr nasType.SessionAMBR) { - fmt.Println(ambr) + logger.ConvertLog.Infof("%v", ambr) uplink := strings.Split(ambr.Uplink, " ") if bitRate, err := strconv.ParseUint(uplink[0], 10, 16); err != nil { diff --git a/nasConvert/Snssai.go b/nasConvert/Snssai.go index 90e708d..52e9a73 100644 --- a/nasConvert/Snssai.go +++ b/nasConvert/Snssai.go @@ -30,7 +30,7 @@ func SnssaiToNas(snssai models.Snssai) []uint8 { buf = append(buf, 0x04) buf = append(buf, uint8(snssai.Sst)) if byteArray, err := hex.DecodeString(snssai.Sd); err != nil { - logger.ConvertLog.Warnf("Decode snssai.sd failed: %+v", err) + logger.ConvertLog.Warnf("decode snssai.sd failed: %+v", err) } else { buf = append(buf, byteArray...) } @@ -48,7 +48,7 @@ func RejectedSnssaiToNas(snssai models.Snssai, rejectCause uint8) []uint8 { rejectedSnssai = append(rejectedSnssai, (0x04<<4)+rejectCause) rejectedSnssai = append(rejectedSnssai, uint8(snssai.Sst)) if sDBytes, err := hex.DecodeString(snssai.Sd); err != nil { - logger.ConvertLog.Warnf("Decode snssai.sd failed: %+v", err) + logger.ConvertLog.Warnf("decode snssai.sd failed: %+v", err) } else { rejectedSnssai = append(rejectedSnssai, sDBytes...) } diff --git a/nasConvert/TaiList.go b/nasConvert/TaiList.go index f69bfeb..bbfa9ad 100644 --- a/nasConvert/TaiList.go +++ b/nasConvert/TaiList.go @@ -36,7 +36,7 @@ func TaiListToNas(taiList []models.Tai) []uint8 { for _, tai := range taiList { if tacBytes, err := hex.DecodeString(tai.Tac); err != nil { - logger.ConvertLog.Warnf("Decode tac failed: %+v", err) + logger.ConvertLog.Warnf("decode tac failed: %+v", err) } else { taiListNas = append(taiListNas, tacBytes...) } @@ -45,7 +45,7 @@ func TaiListToNas(taiList []models.Tai) []uint8 { for _, tai := range taiList { plmnNas := PlmnIDToNas(*tai.PlmnId) if tacBytes, err := hex.DecodeString(tai.Tac); err != nil { - logger.ConvertLog.Warnf("Decode tac failed: %+v", err) + logger.ConvertLog.Warnf("decode tac failed: %+v", err) } else { taiListNas = append(taiListNas, plmnNas...) taiListNas = append(taiListNas, tacBytes...) diff --git a/nasConvert/UPUInfo.go b/nasConvert/UPUInfo.go index 556314b..eacfec4 100644 --- a/nasConvert/UPUInfo.go +++ b/nasConvert/UPUInfo.go @@ -21,12 +21,12 @@ func UpuInfoToNas(upuInfo models.UpuInfo) []uint8 { buf = append(buf, upuInfoGetHeader(upuInfo.UpuRegInd, upuInfo.UpuAckInd)) // Set UPU-MAC-IAUSF if byteArray, err := hex.DecodeString(upuInfo.UpuMacIausf); err != nil { - logger.ConvertLog.Warnf("Decode upuInfo.UpuMacIausf failed: %+v", err) + logger.ConvertLog.Warnf("decode upuInfo.UpuMacIausf failed: %+v", err) } else { buf = append(buf, byteArray...) // Set Counter UPU - if computerUpuByteArray, errUpu := hex.DecodeString(upuInfo.CounterUpu); err != nil { - logger.ConvertLog.Warnf("Decode upuInfo.CounterUpu failed: %+v", errUpu) + if computerUpuByteArray, errUpu := hex.DecodeString(upuInfo.CounterUpu); errUpu != nil { + logger.ConvertLog.Warnf("decode upuInfo.CounterUpu failed: %+v", errUpu) } else { buf = append(buf, computerUpuByteArray...) } @@ -37,7 +37,7 @@ func UpuInfoToNas(upuInfo models.UpuInfo) []uint8 { if data.SecPacket != "" { buf = append(buf, 0x01) if byteArrayTmp, err := hex.DecodeString(data.SecPacket); err != nil { - logger.ConvertLog.Warnf("Decode data.SecPacket failed: %+v", err) + logger.ConvertLog.Warnf("decode data.SecPacket failed: %+v", err) } else { byteArray = byteArrayTmp } diff --git a/nasMessage/NAS_AuthenticationFailure.go b/nasMessage/NAS_AuthenticationFailure.go index 675b3a4..29f0aed 100644 --- a/nasMessage/NAS_AuthenticationFailure.go +++ b/nasMessage/NAS_AuthenticationFailure.go @@ -51,13 +51,11 @@ func (a *AuthenticationFailure) DecodeAuthenticationFailure(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case AuthenticationFailureAuthenticationFailureParameterType: a.AuthenticationFailureParameter = nasType.NewAuthenticationFailureParameter(ieiN) diff --git a/nasMessage/NAS_AuthenticationFailure_test.go b/nasMessage/NAS_AuthenticationFailure_test.go index 50f7c52..dcfb8ce 100644 --- a/nasMessage/NAS_AuthenticationFailure_test.go +++ b/nasMessage/NAS_AuthenticationFailure_test.go @@ -70,13 +70,13 @@ func TestNasTypeNewAuthenticationFailureMessage(t *testing.T) { buff := new(bytes.Buffer) a.EncodeAuthenticationFailure(buff) - logger.NasMsgLog.Debugln("Encode: ", a) + logger.NasMsgLog.Debugln("encode:", a) data := make([]byte, buff.Len()) buff.Read(data) - logger.NasMsgLog.Debugln("data: ", data) + logger.NasMsgLog.Debugln("data:", data) b.DecodeAuthenticationFailure(&data) - logger.NasMsgLog.Debugln("Decode: ", b) + logger.NasMsgLog.Debugln("decode:", b) if reflect.DeepEqual(a, b) != true { t.Errorf("Not correct") diff --git a/nasMessage/NAS_AuthenticationReject.go b/nasMessage/NAS_AuthenticationReject.go index cf3ff9b..58c1789 100644 --- a/nasMessage/NAS_AuthenticationReject.go +++ b/nasMessage/NAS_AuthenticationReject.go @@ -48,13 +48,11 @@ func (a *AuthenticationReject) DecodeAuthenticationReject(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case AuthenticationRejectEAPMessageType: a.EAPMessage = nasType.NewEAPMessage(ieiN) diff --git a/nasMessage/NAS_AuthenticationReject_test.go b/nasMessage/NAS_AuthenticationReject_test.go index 55f04a7..057b655 100644 --- a/nasMessage/NAS_AuthenticationReject_test.go +++ b/nasMessage/NAS_AuthenticationReject_test.go @@ -60,13 +60,12 @@ func TestNasTypeNewAuthenticationRejectMessage(t *testing.T) { buff := new(bytes.Buffer) a.EncodeAuthenticationReject(buff) - //fmt.Println("Encode: ", buff) logger.NasMsgLog.Debugln(a) data := make([]byte, buff.Len()) buff.Read(data) b.DecodeAuthenticationReject(&data) - logger.NasMsgLog.Debugln("Decode: ", data) + logger.NasMsgLog.Debugln("decode:", data) logger.NasMsgLog.Infoln(b) if reflect.DeepEqual(a, b) != true { diff --git a/nasMessage/NAS_AuthenticationRequest.go b/nasMessage/NAS_AuthenticationRequest.go index cc0bd15..ba058e4 100644 --- a/nasMessage/NAS_AuthenticationRequest.go +++ b/nasMessage/NAS_AuthenticationRequest.go @@ -70,13 +70,11 @@ func (a *AuthenticationRequest) DecodeAuthenticationRequest(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case AuthenticationRequestAuthenticationParameterRANDType: a.AuthenticationParameterRAND = nasType.NewAuthenticationParameterRAND(ieiN) diff --git a/nasMessage/NAS_AuthenticationRequest_test.go b/nasMessage/NAS_AuthenticationRequest_test.go index 6655887..061a5b3 100644 --- a/nasMessage/NAS_AuthenticationRequest_test.go +++ b/nasMessage/NAS_AuthenticationRequest_test.go @@ -80,14 +80,12 @@ func TestNasTypeNewAuthenticationRequestMessage(t *testing.T) { buff := new(bytes.Buffer) a.EncodeAuthenticationRequest(buff) - //fmt.Printf("Encode: %x\n", buff) - logger.NasMsgLog.Debugln("Encode: ", a) + logger.NasMsgLog.Debugln("encode:", a) data := make([]byte, buff.Len()) buff.Read(data) b.DecodeAuthenticationRequest(&data) - //fmt.Printf("Decode: %x\n", data) - logger.NasMsgLog.Debugln("Decode: ", b) + logger.NasMsgLog.Debugln("decode:", b) if reflect.DeepEqual(a, b) != true { t.Errorf("Not correct") diff --git a/nasMessage/NAS_AuthenticationResponse.go b/nasMessage/NAS_AuthenticationResponse.go index 7573650..102465a 100644 --- a/nasMessage/NAS_AuthenticationResponse.go +++ b/nasMessage/NAS_AuthenticationResponse.go @@ -55,13 +55,11 @@ func (a *AuthenticationResponse) DecodeAuthenticationResponse(byteArray *[]byte) var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case AuthenticationResponseAuthenticationResponseParameterType: a.AuthenticationResponseParameter = nasType.NewAuthenticationResponseParameter(ieiN) diff --git a/nasMessage/NAS_AuthenticationResponse_test.go b/nasMessage/NAS_AuthenticationResponse_test.go index b9fd495..d9f1133 100644 --- a/nasMessage/NAS_AuthenticationResponse_test.go +++ b/nasMessage/NAS_AuthenticationResponse_test.go @@ -10,7 +10,6 @@ import ( "github.com/omec-project/nas/logger" - //"fmt" "testing" "github.com/omec-project/nas/nasMessage" diff --git a/nasMessage/NAS_AuthenticationResult.go b/nasMessage/NAS_AuthenticationResult.go index 573e00e..435b31f 100644 --- a/nasMessage/NAS_AuthenticationResult.go +++ b/nasMessage/NAS_AuthenticationResult.go @@ -57,13 +57,11 @@ func (a *AuthenticationResult) DecodeAuthenticationResult(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case AuthenticationResultABBAType: a.ABBA = nasType.NewABBA(ieiN) diff --git a/nasMessage/NAS_ConfigurationUpdateCommand.go b/nasMessage/NAS_ConfigurationUpdateCommand.go index 8902489..5f9212d 100644 --- a/nasMessage/NAS_ConfigurationUpdateCommand.go +++ b/nasMessage/NAS_ConfigurationUpdateCommand.go @@ -150,13 +150,11 @@ func (a *ConfigurationUpdateCommand) DecodeConfigurationUpdateCommand(byteArray var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case ConfigurationUpdateCommandConfigurationUpdateIndicationType: a.ConfigurationUpdateIndication = nasType.NewConfigurationUpdateIndication(ieiN) diff --git a/nasMessage/NAS_ConfigurationUpdateComplete.go b/nasMessage/NAS_ConfigurationUpdateComplete.go index 555ac27..219a711 100644 --- a/nasMessage/NAS_ConfigurationUpdateComplete.go +++ b/nasMessage/NAS_ConfigurationUpdateComplete.go @@ -38,13 +38,11 @@ func (a *ConfigurationUpdateComplete) DecodeConfigurationUpdateComplete(byteArra var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_DLNASTransport.go b/nasMessage/NAS_DLNASTransport.go index b7c0d97..e3b3354 100644 --- a/nasMessage/NAS_DLNASTransport.go +++ b/nasMessage/NAS_DLNASTransport.go @@ -8,7 +8,6 @@ package nasMessage import ( "bytes" "encoding/binary" - "fmt" "github.com/omec-project/nas/nasType" "net" ) @@ -67,7 +66,6 @@ func (a *DLNASTransport) EncodeDLNASTransport(buffer *bytes.Buffer) { func (a *DLNASTransport) DecodeDLNASTransport(byteArray *[]byte) { buffer := bytes.NewBuffer(*byteArray) - //fmt.Println("a before ", a) binary.Read(buffer, binary.BigEndian, &a.ExtendedProtocolDiscriminator.Octet) binary.Read(buffer, binary.BigEndian, &a.SpareHalfOctetAndSecurityHeaderType.Octet) binary.Read(buffer, binary.BigEndian, &a.DLNASTRANSPORTMessageIdentity.Octet) @@ -75,62 +73,39 @@ func (a *DLNASTransport) DecodeDLNASTransport(byteArray *[]byte) { binary.Read(buffer, binary.BigEndian, &a.PayloadContainer.Len) a.PayloadContainer.SetLen(a.PayloadContainer.GetLen()) binary.Read(buffer, binary.BigEndian, &a.PayloadContainer.Buffer) - //fmt.Println("Protocol Des ", a.ExtendedProtocolDiscriminator) - //fmt.Println("Message identity ", a.DLNASTRANSPORTMessageIdentity) - //fmt.Println("payload container type ", a.SpareHalfOctetAndPayloadContainerType) - //fmt.Println("payload container len ", a.PayloadContainer.Len) if a.SpareHalfOctetAndPayloadContainerType.Octet == uint8(1) { - //fmt.Println("*****") - //fmt.Println("buf ", a.PayloadContainer.Buffer) esmMsg := bytes.NewBuffer(a.PayloadContainer.Buffer) - //fmt.Println("\n") var pd uint8 binary.Read(esmMsg, binary.BigEndian, &pd) - //fmt.Println("Protocol Des ", pd) binary.Read(esmMsg, binary.BigEndian, &pd) - //fmt.Println("PDU Session Id ", pd) binary.Read(esmMsg, binary.BigEndian, &pd) - //fmt.Println("PTI ", pd) binary.Read(esmMsg, binary.BigEndian, &pd) - //fmt.Println("msg type ", pd) binary.Read(esmMsg, binary.BigEndian, &pd) - //fmt.Println("session type , ssc mode ", pd) var len uint16 binary.Read(esmMsg, binary.BigEndian, &len) - //fmt.Println("qos len ", len) var qos [9]uint8 binary.Read(esmMsg, binary.BigEndian, &qos) - //fmt.Println("qos ", qos) var ambr_len uint8 binary.Read(esmMsg, binary.BigEndian, &ambr_len) - //fmt.Println("ambr len ", ambr_len) var ambr [6]uint8 binary.Read(esmMsg, binary.BigEndian, &ambr) - //fmt.Println("ambr ", ambr) - //fmt.Println("remaining bytes *****", esmMsg.Len()) forLoop: for esmMsg.Len() > 0 { var ieiN uint8 binary.Read(esmMsg, binary.BigEndian, &ieiN) - // fmt.Println("type", tmpIeiN) switch ieiN { case 89: var cause uint8 binary.Read(esmMsg, binary.BigEndian, &cause) - //fmt.Println("59 - gsm cause = ", cause) case 41: var iplen uint8 binary.Read(esmMsg, binary.BigEndian, &iplen) - //fmt.Println("length of ip address = ", iplen) var iptype uint8 binary.Read(esmMsg, binary.BigEndian, &iptype) - //fmt.Println("type of address = ", iptype) var ipaddr [4]uint8 binary.Read(esmMsg, binary.BigEndian, &ipaddr) - //fmt.Println("ip address = ", ipaddr) ip := net.IPv4(ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]) a.Ipaddr = ip.String() - fmt.Println("ip address", a.Ipaddr) break forLoop // we just need ip address nothing more default: } @@ -142,13 +117,11 @@ func (a *DLNASTransport) DecodeDLNASTransport(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case DLNASTransportPduSessionID2ValueType: a.PduSessionID2Value = nasType.NewPduSessionID2Value(ieiN) diff --git a/nasMessage/NAS_DeregistrationAcceptUEOriginatingDeregistration.go b/nasMessage/NAS_DeregistrationAcceptUEOriginatingDeregistration.go index 242d7a6..0c85202 100644 --- a/nasMessage/NAS_DeregistrationAcceptUEOriginatingDeregistration.go +++ b/nasMessage/NAS_DeregistrationAcceptUEOriginatingDeregistration.go @@ -38,13 +38,11 @@ func (a *DeregistrationAcceptUEOriginatingDeregistration) DecodeDeregistrationAc var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_DeregistrationAcceptUETerminatedDeregistration.go b/nasMessage/NAS_DeregistrationAcceptUETerminatedDeregistration.go index 0802f99..27ac078 100644 --- a/nasMessage/NAS_DeregistrationAcceptUETerminatedDeregistration.go +++ b/nasMessage/NAS_DeregistrationAcceptUETerminatedDeregistration.go @@ -38,13 +38,11 @@ func (a *DeregistrationAcceptUETerminatedDeregistration) DecodeDeregistrationAcc var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_DeregistrationRequestUEOriginatingDeregistration.go b/nasMessage/NAS_DeregistrationRequestUEOriginatingDeregistration.go index b528a7a..5350dff 100644 --- a/nasMessage/NAS_DeregistrationRequestUEOriginatingDeregistration.go +++ b/nasMessage/NAS_DeregistrationRequestUEOriginatingDeregistration.go @@ -47,13 +47,11 @@ func (a *DeregistrationRequestUEOriginatingDeregistration) DecodeDeregistrationR var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_DeregistrationRequestUETerminatedDeregistration.go b/nasMessage/NAS_DeregistrationRequestUETerminatedDeregistration.go index 94c694b..6c066a8 100644 --- a/nasMessage/NAS_DeregistrationRequestUETerminatedDeregistration.go +++ b/nasMessage/NAS_DeregistrationRequestUETerminatedDeregistration.go @@ -57,13 +57,11 @@ func (a *DeregistrationRequestUETerminatedDeregistration) DecodeDeregistrationRe var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case DeregistrationRequestUETerminatedDeregistrationCause5GMMType: a.Cause5GMM = nasType.NewCause5GMM(ieiN) diff --git a/nasMessage/NAS_IdentityRequest.go b/nasMessage/NAS_IdentityRequest.go index fc8571e..0687e9e 100644 --- a/nasMessage/NAS_IdentityRequest.go +++ b/nasMessage/NAS_IdentityRequest.go @@ -41,13 +41,11 @@ func (a *IdentityRequest) DecodeIdentityRequest(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_IdentityRequest_test.go b/nasMessage/NAS_IdentityRequest_test.go index deb465f..4d6fc4b 100644 --- a/nasMessage/NAS_IdentityRequest_test.go +++ b/nasMessage/NAS_IdentityRequest_test.go @@ -10,7 +10,6 @@ import ( "github.com/omec-project/nas/logger" - //"fmt" "testing" "github.com/omec-project/nas" diff --git a/nasMessage/NAS_IdentityResponse.go b/nasMessage/NAS_IdentityResponse.go index b70e098..64f95b2 100644 --- a/nasMessage/NAS_IdentityResponse.go +++ b/nasMessage/NAS_IdentityResponse.go @@ -44,13 +44,11 @@ func (a *IdentityResponse) DecodeIdentityResponse(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_IdentityResponse_test.go b/nasMessage/NAS_IdentityResponse_test.go index 05e6062..dc6a076 100644 --- a/nasMessage/NAS_IdentityResponse_test.go +++ b/nasMessage/NAS_IdentityResponse_test.go @@ -10,7 +10,6 @@ import ( "github.com/omec-project/nas/logger" - //"fmt" "testing" "github.com/omec-project/nas" diff --git a/nasMessage/NAS_Notification.go b/nasMessage/NAS_Notification.go index 9e94a05..cc09ec6 100644 --- a/nasMessage/NAS_Notification.go +++ b/nasMessage/NAS_Notification.go @@ -41,13 +41,11 @@ func (a *Notification) DecodeNotification(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_NotificationResponse.go b/nasMessage/NAS_NotificationResponse.go index 891ca39..432d62c 100644 --- a/nasMessage/NAS_NotificationResponse.go +++ b/nasMessage/NAS_NotificationResponse.go @@ -48,13 +48,11 @@ func (a *NotificationResponse) DecodeNotificationResponse(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case NotificationResponsePDUSessionStatusType: a.PDUSessionStatus = nasType.NewPDUSessionStatus(ieiN) diff --git a/nasMessage/NAS_Notification_test.go b/nasMessage/NAS_Notification_test.go index f392a91..4447182 100644 --- a/nasMessage/NAS_Notification_test.go +++ b/nasMessage/NAS_Notification_test.go @@ -10,7 +10,6 @@ import ( "github.com/omec-project/nas/logger" - //"fmt" "testing" "github.com/omec-project/nas" diff --git a/nasMessage/NAS_PDUSessionAuthenticationCommand.go b/nasMessage/NAS_PDUSessionAuthenticationCommand.go index b323181..9136c31 100644 --- a/nasMessage/NAS_PDUSessionAuthenticationCommand.go +++ b/nasMessage/NAS_PDUSessionAuthenticationCommand.go @@ -57,13 +57,11 @@ func (a *PDUSessionAuthenticationCommand) DecodePDUSessionAuthenticationCommand( var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionAuthenticationCommandExtendedProtocolConfigurationOptionsType: a.ExtendedProtocolConfigurationOptions = nasType.NewExtendedProtocolConfigurationOptions(ieiN) diff --git a/nasMessage/NAS_PDUSessionAuthenticationComplete.go b/nasMessage/NAS_PDUSessionAuthenticationComplete.go index 9a4fc84..feaa0f6 100644 --- a/nasMessage/NAS_PDUSessionAuthenticationComplete.go +++ b/nasMessage/NAS_PDUSessionAuthenticationComplete.go @@ -57,13 +57,11 @@ func (a *PDUSessionAuthenticationComplete) DecodePDUSessionAuthenticationComplet var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionAuthenticationCompleteExtendedProtocolConfigurationOptionsType: a.ExtendedProtocolConfigurationOptions = nasType.NewExtendedProtocolConfigurationOptions(ieiN) diff --git a/nasMessage/NAS_PDUSessionAuthenticationResult.go b/nasMessage/NAS_PDUSessionAuthenticationResult.go index 348363a..122a6e9 100644 --- a/nasMessage/NAS_PDUSessionAuthenticationResult.go +++ b/nasMessage/NAS_PDUSessionAuthenticationResult.go @@ -58,13 +58,11 @@ func (a *PDUSessionAuthenticationResult) DecodePDUSessionAuthenticationResult(by var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionAuthenticationResultEAPMessageType: a.EAPMessage = nasType.NewEAPMessage(ieiN) diff --git a/nasMessage/NAS_PDUSessionEstablishmentAccept.go b/nasMessage/NAS_PDUSessionEstablishmentAccept.go index 8640e3e..b1f5d4c 100644 --- a/nasMessage/NAS_PDUSessionEstablishmentAccept.go +++ b/nasMessage/NAS_PDUSessionEstablishmentAccept.go @@ -125,13 +125,11 @@ func (a *PDUSessionEstablishmentAccept) DecodePDUSessionEstablishmentAccept(byte var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionEstablishmentAcceptCause5GSMType: a.Cause5GSM = nasType.NewCause5GSM(ieiN) diff --git a/nasMessage/NAS_PDUSessionEstablishmentReject.go b/nasMessage/NAS_PDUSessionEstablishmentReject.go index a8ca67f..a1b505d 100644 --- a/nasMessage/NAS_PDUSessionEstablishmentReject.go +++ b/nasMessage/NAS_PDUSessionEstablishmentReject.go @@ -73,13 +73,11 @@ func (a *PDUSessionEstablishmentReject) DecodePDUSessionEstablishmentReject(byte var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionEstablishmentRejectBackoffTimerValueType: a.BackoffTimerValue = nasType.NewBackoffTimerValue(ieiN) diff --git a/nasMessage/NAS_PDUSessionEstablishmentRequest.go b/nasMessage/NAS_PDUSessionEstablishmentRequest.go index cb2bfbb..5a8c110 100644 --- a/nasMessage/NAS_PDUSessionEstablishmentRequest.go +++ b/nasMessage/NAS_PDUSessionEstablishmentRequest.go @@ -91,13 +91,11 @@ func (a *PDUSessionEstablishmentRequest) DecodePDUSessionEstablishmentRequest(by var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionEstablishmentRequestPDUSessionTypeType: a.PDUSessionType = nasType.NewPDUSessionType(ieiN) diff --git a/nasMessage/NAS_PDUSessionModificationCommand.go b/nasMessage/NAS_PDUSessionModificationCommand.go index 661bded..1330026 100644 --- a/nasMessage/NAS_PDUSessionModificationCommand.go +++ b/nasMessage/NAS_PDUSessionModificationCommand.go @@ -96,13 +96,11 @@ func (a *PDUSessionModificationCommand) DecodePDUSessionModificationCommand(byte var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionModificationCommandCause5GSMType: a.Cause5GSM = nasType.NewCause5GSM(ieiN) diff --git a/nasMessage/NAS_PDUSessionModificationCommandReject.go b/nasMessage/NAS_PDUSessionModificationCommandReject.go index fd67a6f..9452009 100644 --- a/nasMessage/NAS_PDUSessionModificationCommandReject.go +++ b/nasMessage/NAS_PDUSessionModificationCommandReject.go @@ -54,13 +54,11 @@ func (a *PDUSessionModificationCommandReject) DecodePDUSessionModificationComman var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionModificationCommandRejectExtendedProtocolConfigurationOptionsType: a.ExtendedProtocolConfigurationOptions = nasType.NewExtendedProtocolConfigurationOptions(ieiN) diff --git a/nasMessage/NAS_PDUSessionModificationComplete.go b/nasMessage/NAS_PDUSessionModificationComplete.go index 786fbcc..d1b1823 100644 --- a/nasMessage/NAS_PDUSessionModificationComplete.go +++ b/nasMessage/NAS_PDUSessionModificationComplete.go @@ -51,13 +51,11 @@ func (a *PDUSessionModificationComplete) DecodePDUSessionModificationComplete(by var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionModificationCompleteExtendedProtocolConfigurationOptionsType: a.ExtendedProtocolConfigurationOptions = nasType.NewExtendedProtocolConfigurationOptions(ieiN) diff --git a/nasMessage/NAS_PDUSessionModificationReject.go b/nasMessage/NAS_PDUSessionModificationReject.go index c2afdd1..8850d82 100644 --- a/nasMessage/NAS_PDUSessionModificationReject.go +++ b/nasMessage/NAS_PDUSessionModificationReject.go @@ -61,13 +61,11 @@ func (a *PDUSessionModificationReject) DecodePDUSessionModificationReject(byteAr var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionModificationRejectBackoffTimerValueType: a.BackoffTimerValue = nasType.NewBackoffTimerValue(ieiN) diff --git a/nasMessage/NAS_PDUSessionModificationRequest.go b/nasMessage/NAS_PDUSessionModificationRequest.go index 5d7a7de..5e93d12 100644 --- a/nasMessage/NAS_PDUSessionModificationRequest.go +++ b/nasMessage/NAS_PDUSessionModificationRequest.go @@ -102,13 +102,11 @@ func (a *PDUSessionModificationRequest) DecodePDUSessionModificationRequest(byte var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionModificationRequestCapability5GSMType: a.Capability5GSM = nasType.NewCapability5GSM(ieiN) diff --git a/nasMessage/NAS_PDUSessionReleaseCommand.go b/nasMessage/NAS_PDUSessionReleaseCommand.go index fc563ea..84fa15c 100644 --- a/nasMessage/NAS_PDUSessionReleaseCommand.go +++ b/nasMessage/NAS_PDUSessionReleaseCommand.go @@ -68,13 +68,11 @@ func (a *PDUSessionReleaseCommand) DecodePDUSessionReleaseCommand(byteArray *[]b var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionReleaseCommandBackoffTimerValueType: a.BackoffTimerValue = nasType.NewBackoffTimerValue(ieiN) diff --git a/nasMessage/NAS_PDUSessionReleaseCommand_test.go b/nasMessage/NAS_PDUSessionReleaseCommand_test.go index 9a4ef82..a17cb4e 100644 --- a/nasMessage/NAS_PDUSessionReleaseCommand_test.go +++ b/nasMessage/NAS_PDUSessionReleaseCommand_test.go @@ -97,8 +97,6 @@ func TestNasTypeNewPDUSessionReleaseCommandMessage(t *testing.T) { logger.NasMsgLog.Debugln("Decode: ", b) //logger.NasMsgLog.Debugln(a.Cause5GSM) //logger.NasMsgLog.Debugln(b.Cause5GSM) - //fmt.Println(a.ExtendedProtocolConfigurationOptions) - //fmt.Println(b.ExtendedProtocolConfigurationOptions) if reflect.DeepEqual(a, b) != true { t.Errorf("Not correct") } diff --git a/nasMessage/NAS_PDUSessionReleaseComplete.go b/nasMessage/NAS_PDUSessionReleaseComplete.go index 9306d9f..b3e25bf 100644 --- a/nasMessage/NAS_PDUSessionReleaseComplete.go +++ b/nasMessage/NAS_PDUSessionReleaseComplete.go @@ -57,13 +57,11 @@ func (a *PDUSessionReleaseComplete) DecodePDUSessionReleaseComplete(byteArray *[ var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionReleaseCompleteCause5GSMType: a.Cause5GSM = nasType.NewCause5GSM(ieiN) diff --git a/nasMessage/NAS_PDUSessionReleaseComplete_test.go b/nasMessage/NAS_PDUSessionReleaseComplete_test.go index 1fb88b9..56d90ee 100644 --- a/nasMessage/NAS_PDUSessionReleaseComplete_test.go +++ b/nasMessage/NAS_PDUSessionReleaseComplete_test.go @@ -78,10 +78,6 @@ func TestNasTypeNewPDUSessionReleaseCompleteMessage(t *testing.T) { logger.NasMsgLog.Debugln(data) b.DecodePDUSessionReleaseComplete(&data) logger.NasMsgLog.Debugln("Decode: ", b) - //fmt.Println(a.Cause5GSM) - //fmt.Println(b.Cause5GSM) - //fmt.Println(a.ExtendedProtocolConfigurationOptions) - //fmt.Println(b.ExtendedProtocolConfigurationOptions) if reflect.DeepEqual(a, b) != true { t.Errorf("Not correct") } diff --git a/nasMessage/NAS_PDUSessionReleaseReject.go b/nasMessage/NAS_PDUSessionReleaseReject.go index d767e35..d3b2481 100644 --- a/nasMessage/NAS_PDUSessionReleaseReject.go +++ b/nasMessage/NAS_PDUSessionReleaseReject.go @@ -54,13 +54,11 @@ func (a *PDUSessionReleaseReject) DecodePDUSessionReleaseReject(byteArray *[]byt var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionReleaseRejectExtendedProtocolConfigurationOptionsType: a.ExtendedProtocolConfigurationOptions = nasType.NewExtendedProtocolConfigurationOptions(ieiN) diff --git a/nasMessage/NAS_PDUSessionReleaseRequest.go b/nasMessage/NAS_PDUSessionReleaseRequest.go index 2103a6e..ae1757f 100644 --- a/nasMessage/NAS_PDUSessionReleaseRequest.go +++ b/nasMessage/NAS_PDUSessionReleaseRequest.go @@ -57,13 +57,11 @@ func (a *PDUSessionReleaseRequest) DecodePDUSessionReleaseRequest(byteArray *[]b var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case PDUSessionReleaseRequestCause5GSMType: a.Cause5GSM = nasType.NewCause5GSM(ieiN) diff --git a/nasMessage/NAS_RegistrationAccept.go b/nasMessage/NAS_RegistrationAccept.go index 69e8767..de02851 100644 --- a/nasMessage/NAS_RegistrationAccept.go +++ b/nasMessage/NAS_RegistrationAccept.go @@ -209,13 +209,11 @@ func (a *RegistrationAccept) DecodeRegistrationAccept(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case RegistrationAcceptGUTI5GType: a.GUTI5G = nasType.NewGUTI5G(ieiN) diff --git a/nasMessage/NAS_RegistrationComplete.go b/nasMessage/NAS_RegistrationComplete.go index 4a0d2da..eec5884 100644 --- a/nasMessage/NAS_RegistrationComplete.go +++ b/nasMessage/NAS_RegistrationComplete.go @@ -48,13 +48,11 @@ func (a *RegistrationComplete) DecodeRegistrationComplete(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case RegistrationCompleteSORTransparentContainerType: a.SORTransparentContainer = nasType.NewSORTransparentContainer(ieiN) diff --git a/nasMessage/NAS_RegistrationReject.go b/nasMessage/NAS_RegistrationReject.go index 39bd600..abe9acd 100644 --- a/nasMessage/NAS_RegistrationReject.go +++ b/nasMessage/NAS_RegistrationReject.go @@ -65,13 +65,11 @@ func (a *RegistrationReject) DecodeRegistrationReject(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case RegistrationRejectT3346ValueType: a.T3346Value = nasType.NewT3346Value(ieiN) diff --git a/nasMessage/NAS_RegistrationRequest.go b/nasMessage/NAS_RegistrationRequest.go index 4daa93c..b4760c4 100644 --- a/nasMessage/NAS_RegistrationRequest.go +++ b/nasMessage/NAS_RegistrationRequest.go @@ -183,13 +183,11 @@ func (a *RegistrationRequest) DecodeRegistrationRequest(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case RegistrationRequestNoncurrentNativeNASKeySetIdentifierType: a.NoncurrentNativeNASKeySetIdentifier = nasType.NewNoncurrentNativeNASKeySetIdentifier(ieiN) diff --git a/nasMessage/NAS_RegistrationRequest_test.go b/nasMessage/NAS_RegistrationRequest_test.go index 5da5152..e97529c 100644 --- a/nasMessage/NAS_RegistrationRequest_test.go +++ b/nasMessage/NAS_RegistrationRequest_test.go @@ -7,7 +7,6 @@ package nasMessage_test import ( "bytes" - "fmt" "reflect" "testing" @@ -240,13 +239,10 @@ func TestNasTypeNewRegistrationRequestMessage(t *testing.T) { buff := new(bytes.Buffer) a.EncodeRegistrationRequest(buff) - fmt.Println("Encode: ", a) data := make([]byte, buff.Len()) buff.Read(data) - //fmt.Println(data) b.DecodeRegistrationRequest(&data) - fmt.Println("Decode: ", b) if reflect.DeepEqual(a, b) != true { t.Errorf("Not correct") diff --git a/nasMessage/NAS_SecurityModeCommand.go b/nasMessage/NAS_SecurityModeCommand.go index 517e4a7..8625b0a 100644 --- a/nasMessage/NAS_SecurityModeCommand.go +++ b/nasMessage/NAS_SecurityModeCommand.go @@ -92,13 +92,11 @@ func (a *SecurityModeCommand) DecodeSecurityModeCommand(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case SecurityModeCommandIMEISVRequestType: a.IMEISVRequest = nasType.NewIMEISVRequest(ieiN) diff --git a/nasMessage/NAS_SecurityModeComplete.go b/nasMessage/NAS_SecurityModeComplete.go index 7568d88..dd92d91 100644 --- a/nasMessage/NAS_SecurityModeComplete.go +++ b/nasMessage/NAS_SecurityModeComplete.go @@ -55,13 +55,11 @@ func (a *SecurityModeComplete) DecodeSecurityModeComplete(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case SecurityModeCompleteIMEISVType: a.IMEISV = nasType.NewIMEISV(ieiN) diff --git a/nasMessage/NAS_SecurityModeReject.go b/nasMessage/NAS_SecurityModeReject.go index 8978760..8a9b950 100644 --- a/nasMessage/NAS_SecurityModeReject.go +++ b/nasMessage/NAS_SecurityModeReject.go @@ -41,13 +41,11 @@ func (a *SecurityModeReject) DecodeSecurityModeReject(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_SecurityProtected5GSNASMessage.go b/nasMessage/NAS_SecurityProtected5GSNASMessage.go index 621771e..fd9106e 100644 --- a/nasMessage/NAS_SecurityProtected5GSNASMessage.go +++ b/nasMessage/NAS_SecurityProtected5GSNASMessage.go @@ -44,13 +44,11 @@ func (a *SecurityProtected5GSNASMessage) DecodeSecurityProtected5GSNASMessage(by var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_ServiceAccept.go b/nasMessage/NAS_ServiceAccept.go index b71b3c2..1e0dd84 100644 --- a/nasMessage/NAS_ServiceAccept.go +++ b/nasMessage/NAS_ServiceAccept.go @@ -69,13 +69,11 @@ func (a *ServiceAccept) DecodeServiceAccept(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case ServiceAcceptPDUSessionStatusType: a.PDUSessionStatus = nasType.NewPDUSessionStatus(ieiN) diff --git a/nasMessage/NAS_ServiceAccept_test.go b/nasMessage/NAS_ServiceAccept_test.go index 785b55d..e93a794 100644 --- a/nasMessage/NAS_ServiceAccept_test.go +++ b/nasMessage/NAS_ServiceAccept_test.go @@ -91,13 +91,12 @@ func TestNasTypeNewServiceAcceptMessage(t *testing.T) { buff := new(bytes.Buffer) a.EncodeServiceAccept(buff) - logger.NasMsgLog.Debugln("Encode: ", a) + logger.NasMsgLog.Debugln("encode:", a) data := make([]byte, buff.Len()) buff.Read(data) - logger.NasMsgLog.Debugln(data) b.DecodeServiceAccept(&data) - logger.NasMsgLog.Debugln("Dncode: ", b) + logger.NasMsgLog.Debugln("decode:", b) if reflect.DeepEqual(a, b) != true { t.Errorf("Not correct") diff --git a/nasMessage/NAS_ServiceReject.go b/nasMessage/NAS_ServiceReject.go index 9fce869..c5f668f 100644 --- a/nasMessage/NAS_ServiceReject.go +++ b/nasMessage/NAS_ServiceReject.go @@ -65,13 +65,11 @@ func (a *ServiceReject) DecodeServiceReject(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case ServiceRejectPDUSessionStatusType: a.PDUSessionStatus = nasType.NewPDUSessionStatus(ieiN) diff --git a/nasMessage/NAS_ServiceRequest.go b/nasMessage/NAS_ServiceRequest.go index 373eed6..ed03538 100644 --- a/nasMessage/NAS_ServiceRequest.go +++ b/nasMessage/NAS_ServiceRequest.go @@ -78,13 +78,11 @@ func (a *ServiceRequest) DecodeServiceRequest(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case ServiceRequestUplinkDataStatusType: a.UplinkDataStatus = nasType.NewUplinkDataStatus(ieiN) diff --git a/nasMessage/NAS_Status5GMM.go b/nasMessage/NAS_Status5GMM.go index 43620b2..2ca3277 100644 --- a/nasMessage/NAS_Status5GMM.go +++ b/nasMessage/NAS_Status5GMM.go @@ -41,13 +41,11 @@ func (a *Status5GMM) DecodeStatus5GMM(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_Status5GSM.go b/nasMessage/NAS_Status5GSM.go index 820fe53..adbd914 100644 --- a/nasMessage/NAS_Status5GSM.go +++ b/nasMessage/NAS_Status5GSM.go @@ -44,13 +44,11 @@ func (a *Status5GSM) DecodeStatus5GSM(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { default: } diff --git a/nasMessage/NAS_ULNASTransport.go b/nasMessage/NAS_ULNASTransport.go index 78ad370..91956cb 100644 --- a/nasMessage/NAS_ULNASTransport.go +++ b/nasMessage/NAS_ULNASTransport.go @@ -88,13 +88,11 @@ func (a *ULNASTransport) DecodeULNASTransport(byteArray *[]byte) { var ieiN uint8 var tmpIeiN uint8 binary.Read(buffer, binary.BigEndian, &ieiN) - // fmt.Println(ieiN) if ieiN >= 0x80 { tmpIeiN = (ieiN & 0xf0) >> 4 } else { tmpIeiN = ieiN } - // fmt.Println("type", tmpIeiN) switch tmpIeiN { case ULNASTransportPduSessionID2ValueType: a.PduSessionID2Value = nasType.NewPduSessionID2Value(ieiN) diff --git a/nasTestpacket/NasPdu.go b/nasTestpacket/NasPdu.go index 8f714f9..7f5589d 100644 --- a/nasTestpacket/NasPdu.go +++ b/nasTestpacket/NasPdu.go @@ -9,7 +9,6 @@ import ( "bytes" "encoding/base64" "encoding/hex" - "fmt" "github.com/omec-project/nas" "github.com/omec-project/nas/logger" @@ -70,7 +69,7 @@ func GetRegistrationRequest( data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -112,7 +111,7 @@ func GetPduSessionEstablishmentRequest(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -167,7 +166,7 @@ func GetUlNasTransport_PduSessionEstablishmentRequest(pduSessionId uint8, reques data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -222,7 +221,7 @@ func GetUlNasTransport_PduSessionModificationRequest(pduSessionId uint8, request data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -250,7 +249,7 @@ func GetPduSessionModificationRequest(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -273,7 +272,7 @@ func GetPduSessionModificationComplete(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -296,7 +295,7 @@ func GetPduSessionModificationCommandReject(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -319,7 +318,7 @@ func GetPduSessionReleaseRequest(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -342,7 +341,7 @@ func GetPduSessionReleaseComplete(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -365,7 +364,7 @@ func GetPduSessionReleaseReject(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -390,7 +389,7 @@ func GetPduSessionAuthenticationComplete(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -437,7 +436,7 @@ func GetUlNasTransport_PduSessionCommonData(pduSessionId uint8, types string) [] data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -461,7 +460,7 @@ func GetIdentityResponse(mobileIdentity nasType.MobileIdentity) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -486,7 +485,7 @@ func GetNotificationResponse(pDUSessionStatus []uint8) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -508,7 +507,7 @@ func GetConfigurationUpdateComplete() []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -548,7 +547,7 @@ func GetServiceRequest(serviceType uint8) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -586,7 +585,7 @@ func GetAuthenticationResponse(authenticationResponseParam []uint8, eapMsg strin data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -617,7 +616,7 @@ func GetAuthenticationFailure(cause5GMM uint8, authenticationFailureParam []uint data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -647,7 +646,7 @@ func GetRegistrationComplete(sorTransparentContainer []uint8) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -687,7 +686,7 @@ func GetSecurityModeComplete(nasMessageContainer []uint8) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -712,7 +711,7 @@ func GetSecurityModeReject(cause5GMM uint8) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -746,7 +745,7 @@ func GetDeregistrationRequest(accessType uint8, switchOff uint8, ngKsi uint8, data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -770,7 +769,7 @@ func GetDeregistrationAccept() []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -793,7 +792,7 @@ func GetStatus5GMM(cause uint8) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -816,7 +815,7 @@ func GetStatus5GSM(pduSessionId uint8, cause uint8) []byte { data := new(bytes.Buffer) err := m.GsmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -847,7 +846,7 @@ func GetUlNasTransport_Status5GSM(pduSessionId uint8, cause uint8) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -878,7 +877,7 @@ func GetUlNasTransport_PduSessionReleaseRequest(pduSessionId uint8) []byte { data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() @@ -933,7 +932,7 @@ func GetUlNasTransport_PduSessionReleaseComplete(pduSessionId uint8, requestType data := new(bytes.Buffer) err := m.GmmMessageEncode(data) if err != nil { - fmt.Println(err.Error()) + logger.NasMsgLog.Errorln(err.Error()) } return data.Bytes() diff --git a/nasType/comm_util.go b/nasType/comm_util.go index 8aca8e8..b43268b 100644 --- a/nasType/comm_util.go +++ b/nasType/comm_util.go @@ -10,8 +10,6 @@ package nasType // < up // TODO exception check func GetBitMask(ub uint8, lb uint8) (bitMask uint8) { - // fmt.Println("%x", number) - // fmt.Println("%x", 1<