-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from enowars/gnb-hidden
Move gnb to hidden folder
- Loading branch information
Showing
13 changed files
with
364 additions
and
22 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Use https://gitignore.io/ to create a suitable .gitignore file for your project. | ||
data/ | ||
./gnb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
cd src | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ../../service/gnb cmd/gnb/main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module phreaking | ||
|
||
go 1.20 | ||
|
||
require github.com/gofrs/uuid v4.4.0+incompatible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= | ||
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
"net" | ||
"phreaking/pkg/nas" | ||
"phreaking/pkg/ngap" | ||
"phreaking/pkg/parser" | ||
) | ||
|
||
var EOF error = io.EOF | ||
|
||
func Send(conn net.Conn, msg []byte) (err error) { | ||
msgLen := uint16(len(msg)) | ||
buf := make([]byte, 2) | ||
buf[0] = uint8(msgLen >> 8) | ||
buf[1] = uint8(msgLen & 0xff) | ||
_, err = conn.Write(buf) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = conn.Write(msg) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func SendGmm(conn net.Conn, gmm nas.GmmHeader) (err error) { | ||
pkt, err := parser.EncodeMsg(&gmm) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return Send(conn, pkt) | ||
} | ||
|
||
func SendNgapMsg[T any](conn net.Conn, ngapType ngap.NgapMsgType, msgPtr *T) (err error) { | ||
ngapPdu, err := parser.EncodeMsg(&msgPtr) | ||
if err != nil { | ||
return err | ||
} | ||
ngapHeader := ngap.NgapHeader{MessageType: ngapType, NgapPdu: ngapPdu} | ||
pkt, err := parser.EncodeMsg(&ngapHeader) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return Send(conn, pkt) | ||
} | ||
|
||
func Recv(conn net.Conn) ([]byte, error) { | ||
buf := make([]byte, 2) | ||
|
||
_, err := conn.Read(buf) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
msgLen := uint16(buf[1]) | uint16(buf[0])<<8 | ||
if msgLen < 1 { | ||
return nil, errors.New("msg length of buffer is zero or negative") | ||
} | ||
buf = make([]byte, msgLen) | ||
_, err = conn.Read(buf) | ||
return buf, err | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
package nas | ||
|
||
import "github.com/gofrs/uuid" | ||
|
||
type NasMsgType int | ||
type AmfUeNgapIdType uuid.UUID | ||
|
||
const ( | ||
NASRegRequest NasMsgType = iota | ||
NASIdRequest | ||
NASIdResponse | ||
NASAuthRequest | ||
NASAuthResponse | ||
NASSecurityModeCommand | ||
NASSecurityModeComplete | ||
InitialContextSetupRequestRegAccept | ||
UECapInfoIndication | ||
InitialContextSetupResponse | ||
RegisterComplete | ||
PDUSessionEstRequest | ||
PDUSessionEstAccept | ||
PDUReq | ||
PDURes | ||
PDUSessionResourceReleaseCommand | ||
// Location | ||
LocationUpdate | ||
LocationReportRequest | ||
LocationReportResponse | ||
) | ||
|
||
type EaMask uint8 | ||
|
||
const ( | ||
EA0 EaMask = 1 << iota | ||
EA1 | ||
EA2 | ||
EA3 | ||
EA4 | ||
EA5 | ||
EA6 | ||
EA7 | ||
) | ||
|
||
var EaMaskMap = []EaMask{ | ||
EA0, | ||
EA1, | ||
EA2, | ||
EA3, | ||
EA4, | ||
EA5, | ||
EA6, | ||
EA7, | ||
} | ||
|
||
type IaMask uint8 | ||
|
||
const ( | ||
IA0 IaMask = 1 << iota | ||
IA1 | ||
IA2 | ||
IA3 | ||
IA4 | ||
IA5 | ||
IA6 | ||
IA7 | ||
) | ||
|
||
var IaMaskMap = []IaMask{ | ||
IA0, | ||
IA1, | ||
IA2, | ||
IA3, | ||
IA4, | ||
IA5, | ||
IA6, | ||
IA7, | ||
} | ||
|
||
type SecCapType struct { | ||
// 1 | 2 | .. | 8 | ||
// EA0 | EA1 | .. | EA7 | ||
EaCap EaMask | ||
// 1 | 2 | .. | 8 | ||
// IA0 | IA1 | .. | IA7 | ||
IaCap IaMask | ||
} | ||
|
||
type GmmHeader struct { | ||
// MobileId MobileIdType | ||
Security bool | ||
Mac [8]byte | ||
MessageType NasMsgType | ||
Message []byte | ||
} | ||
|
||
type MobileIdType struct { | ||
// SupiFormat uint8 | ||
// IdType | ||
Mcc uint8 | ||
Mnc uint8 | ||
// Routing indicator | ||
ProtecScheme uint8 | ||
HomeNetPki uint8 | ||
Msin uint | ||
} | ||
|
||
type NASRegRequestMsg struct { | ||
// Extended protocol discriminator | ||
SecHeader uint8 | ||
// 5GS registration type | ||
// ngKsi | ||
MobileId MobileIdType | ||
SecCap SecCapType | ||
} | ||
|
||
type NASAuthRequestMsg struct { | ||
SecHeader uint8 | ||
Rand []byte | ||
AuthRand []byte | ||
Auth []byte | ||
} | ||
|
||
type NASAuthResponseMsg struct { | ||
SecHeader uint8 | ||
Res []byte | ||
} | ||
|
||
type NASSecurityModeCommandMsg struct { | ||
SecHeader uint8 | ||
EaAlg uint8 | ||
IaAlg uint8 | ||
ReplaySecCap SecCapType | ||
} | ||
|
||
type PDUSessionEstRequestMsg struct { | ||
PduSesId uint8 | ||
PduSesType uint8 | ||
// add integrity protetion maximum data rate | ||
} | ||
|
||
type PDUSessionEstAcceptMsg struct { | ||
PduSesId uint8 | ||
// PduAddress []byte | ||
// SSC | ||
// QoS | ||
// AMBR | ||
} | ||
|
||
type LocationUpdateMsg struct { | ||
Location string | ||
} | ||
|
||
type LocationReportRequestMsg struct { | ||
AmfUeNgapId AmfUeNgapIdType | ||
RanUeNgapId uint32 | ||
} | ||
|
||
type LocationReportResponseMsg struct { | ||
AmfUeNgapId AmfUeNgapIdType | ||
RanUeNgapId uint32 | ||
Locations []string | ||
} | ||
|
||
type PDUReqMsg struct { | ||
PduSesId uint8 | ||
Request []byte | ||
} | ||
type PDUResMsg struct { | ||
PduSesId uint8 | ||
Response []byte | ||
} |
Oops, something went wrong.