Skip to content

Commit

Permalink
Update json-api
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Dec 4, 2024
1 parent 5458a2f commit 1563ff0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/gin-gonic/gin v1.10.0
github.com/gofrs/uuid v4.4.0+incompatible
github.com/nextmn/go-pfcp-networking v0.0.38
github.com/nextmn/json-api v0.0.13
github.com/nextmn/json-api v0.0.14
github.com/nextmn/logrus-formatter v0.0.1
github.com/nextmn/rfc9433 v0.0.2
github.com/sirupsen/logrus v1.9.3
Expand All @@ -17,16 +17,16 @@ require (
)

require (
github.com/bytedance/sonic v1.12.4 // indirect
github.com/bytedance/sonic v1.12.5 // indirect
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
github.com/gin-contrib/sse v0.1.0 // 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.22.1 // indirect
github.com/go-playground/validator/v10 v10.23.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
Expand Down
18 changes: 8 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78=
github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
github.com/bytedance/sonic v1.12.4 h1:9Csb3c9ZJhfUWeMtpCDCq6BUoH5ogfDFLUgQ/jG+R0k=
github.com/bytedance/sonic v1.12.4/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk=
github.com/bytedance/sonic v1.12.5 h1:hoZxY8uW+mT+OpkcUWw4k0fDINtOcVavEsGfzwzFU/w=
github.com/bytedance/sonic v1.12.5/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.2.1 h1:1GgorWTqf12TA8mma4DDSbaQigE2wOgQo7iCjjJv3+E=
github.com/bytedance/sonic/loader v0.2.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
Expand All @@ -14,8 +14,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
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.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
github.com/gabriel-vasile/mimetype v1.4.7 h1:SKFKl7kD0RiPdbht0s7hFtjl489WcQ1VyPW8ZzUMYCA=
github.com/gabriel-vasile/mimetype v1.4.7/go.mod h1:GDlAgAyIRT27BhFl53XNAFtfjzOkLaF35JdEG0P7LtU=
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.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
Expand All @@ -26,8 +26,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
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.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o=
github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
Expand All @@ -52,10 +52,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/nextmn/go-pfcp-networking v0.0.38 h1:C7HgLh6UUbqfoTHl/uvUcYNZUBPSur68rOHdLUnpx9Q=
github.com/nextmn/go-pfcp-networking v0.0.38/go.mod h1:KYoKLiltDmHL2YMU5mz2k/E1xMoz4TpmzTz6Nr5u5gA=
github.com/nextmn/json-api v0.0.12 h1:QIg+wmCBhti5hzvh2mtQ6sJ3XayFrOusvsnuHOd9fdU=
github.com/nextmn/json-api v0.0.12/go.mod h1:CQXeNPj9MDGsEExtnqJFIGjLgZAKsmOoO2fy+mep7Ak=
github.com/nextmn/json-api v0.0.13 h1:k8Z0Oo9et5PvdCa4wUmJE9TAHJp1zTkoAmvy1LQcoyQ=
github.com/nextmn/json-api v0.0.13/go.mod h1:CQXeNPj9MDGsEExtnqJFIGjLgZAKsmOoO2fy+mep7Ak=
github.com/nextmn/json-api v0.0.14 h1:m4uHOVcXsxkXoxbrhqemLTRG4T86eYkejjirew1nDUU=
github.com/nextmn/json-api v0.0.14/go.mod h1:CQXeNPj9MDGsEExtnqJFIGjLgZAKsmOoO2fy+mep7Ak=
github.com/nextmn/logrus-formatter v0.0.1 h1:Bsf78jjiEESc+rV8xE6IyKj4frDPGMwXFNrLQzm6A1E=
github.com/nextmn/logrus-formatter v0.0.1/go.mod h1:vdSZ+sIcSna8vjbXkSFxsnsKHqRwaUEed4JCPcXoGyM=
github.com/nextmn/rfc9433 v0.0.2 h1:6FjMY+Qy8MNXQ0PPxezUsyXDxJiCbTp5j3OcXQgIQh8=
Expand Down
8 changes: 4 additions & 4 deletions internal/app/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

pfcp_networking "github.com/nextmn/go-pfcp-networking/pfcp"
"github.com/nextmn/json-api/healthcheck"
"github.com/nextmn/json-api/jsonapi"
"github.com/nextmn/json-api/jsonapi/n4tosrv6"

"github.com/gin-gonic/gin"
"github.com/gofrs/uuid"
Expand All @@ -28,13 +28,13 @@ type HttpServerEntity struct {

type RouterRegistry struct {
sync.RWMutex
routers jsonapi.RouterMap
routers n4tosrv6.RouterMap
pfcpSrv *pfcp_networking.PFCPEntityUP
}

func NewHttpServerEntity(httpAddr string, pfcp *pfcp_networking.PFCPEntityUP) *HttpServerEntity {
rr := RouterRegistry{
routers: make(jsonapi.RouterMap),
routers: make(n4tosrv6.RouterMap),
pfcpSrv: pfcp,
}
// TODO: gin.SetMode(gin.DebugMode) / gin.SetMode(gin.ReleaseMode) depending on log level
Expand Down Expand Up @@ -110,7 +110,7 @@ func (r *RouterRegistry) GetRouter(c *gin.Context) {

// post a router infos
func (r *RouterRegistry) PostRouter(c *gin.Context) {
var router jsonapi.Router
var router n4tosrv6.Router
if err := c.BindJSON(&router); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"message": "could not deserialize", "error": fmt.Sprintf("%v", err)})
return
Expand Down
24 changes: 12 additions & 12 deletions internal/app/rules-pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
pfcp_networking "github.com/nextmn/go-pfcp-networking/pfcp"
pfcpapi "github.com/nextmn/go-pfcp-networking/pfcp/api"
"github.com/nextmn/go-pfcp-networking/pfcputil"
"github.com/nextmn/json-api/jsonapi"
"github.com/nextmn/json-api/jsonapi/n4tosrv6"
"github.com/nextmn/rfc9433/encoding"
"github.com/nextmn/srv6-ctrl/internal/config"
)
Expand Down Expand Up @@ -105,27 +105,27 @@ func (pusher *RulesPusher) pushRTRRule(ue_ip string) error {

for _, r := range pusher.uplink {
//TODO: add ArgMobSession
srh, err := jsonapi.NewSRH(r.SegmentsList)
srh, err := n4tosrv6.NewSRH(r.SegmentsList)
if err != nil {
logrus.WithFields(logrus.Fields{
"segments-list": r.SegmentsList,
}).WithError(err).Error("Creation of SRH uplink failed")
return err
}
rule := jsonapi.Rule{
rule := n4tosrv6.Rule{
Enabled: r.Enabled,
Type: "uplink",
Match: jsonapi.Match{
Header: &jsonapi.GtpHeader{
Match: n4tosrv6.Match{
Header: &n4tosrv6.GtpHeader{
OuterIpSrc: gnb_addr,
Teid: infos.UplinkTeid,
InnerIpSrc: &ue_addr,
},
Payload: &jsonapi.Payload{
Payload: &n4tosrv6.Payload{
Dst: service_addr,
},
},
Action: jsonapi.Action{
Action: n4tosrv6.Action{
SRH: *srh,
},
}
Expand Down Expand Up @@ -164,22 +164,22 @@ func (pusher *RulesPusher) pushRTRRule(ue_ip string) error {
}
segList[0] = dstIp.String()

srh, err := jsonapi.NewSRH(segList)
srh, err := n4tosrv6.NewSRH(segList)
if err != nil {
logrus.WithFields(logrus.Fields{
"segments-list": r.SegmentsList,
}).WithError(err).Error("Creation of SRH downlink failed")
return err
}
rule := jsonapi.Rule{
rule := n4tosrv6.Rule{
Enabled: true,
Type: "downlink",
Match: jsonapi.Match{
Payload: &jsonapi.Payload{
Match: n4tosrv6.Match{
Payload: &n4tosrv6.Payload{
Dst: ue_addr,
},
},
Action: jsonapi.Action{
Action: n4tosrv6.Action{
SRH: *srh,
},
}
Expand Down

0 comments on commit 1563ff0

Please sign in to comment.