Commit fb30a1c0 authored by 吴洲洋's avatar 吴洲洋

Cancel dynamic acquisition of base station IP

parent af151111
set interface state @gtpu_entry@ up
set interface ip address @gtpu_entry@ @gtpu_entry_ip@/24
create gtpu tunnel src @gtpu_entry_ip@ dst @gnb_gtpu_ip@ teid 1 encap-vrf-id 0 decap-next node ip4-lookup
ip route add 192.169.0.0/24 via gtpu_tunnel0
set interface state @gtpu_export@ up
set interface ip address @gtpu_export@ @gtpu_export_ip@/24
......
......@@ -4,6 +4,7 @@ vpp:
gtpu_export: GigabitEthernet2/5/0
gtpu_entry_ip: 192.168.30.10
gtpu_export_ip: 192.168.50.10
gnb_gtpu_ip: 192.168.10.100
ip_link:
ueip: 192.169.0.0
ueIPPrefix: 24
......
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GOROOT" path="/usr/local/go" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/replace.iml" filepath="$PROJECT_DIR$/.idea/replace.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -39,9 +39,11 @@ type vpp struct {
}
type system struct {
GtpuEntry string `yaml:"gtpu_entry"`
GtpuExport string `yaml:"gtpu_export"`
GtpuGnb string `yaml:"gnb_gtpu_ip"`
GtpuEntry string `yaml:"gtpu_entry"`
GtpuExport string `yaml:"gtpu_export"`
GtpuEntryIP string `yaml:"gtpu_entry_ip"`
GtpuExportIP string `yaml:"gtpu_export_ip"`
GtpuGnb string `yaml:"gnb_gtpu_ip"`
}
type ipLink struct {
......@@ -91,53 +93,6 @@ func main() {
c.readYaml(*in)
//support-system
//support_system, err := ioutil.ReadFile(*in + "/support-system.template")
//if err != nil {
// fmt.Println("读取 support-system 模板文件失败")
//} else {
// configureTemplate := string(support_system)
// newConfigure := strings.Replace(configureTemplate, "@GNBUSERNAME@", conf.GNB.Username, 1)
// newConfigure = strings.Replace(newConfigure, "@GNBPASSWORD@", conf.GNB.Password, 1)
// newConfigure = strings.Replace(newConfigure, "@GNBREMOTEHOST@", conf.GNB.RemoteHost, 1)
// newConfigure = strings.Replace(newConfigure, "@GNBGTPU@", conf.VppConfigure.System.GtpuGnb, 1)
// newConfigure = strings.Replace(newConfigure, "@OAIUSERNAME@", conf.OAI.Username, 3)
// newConfigure = strings.Replace(newConfigure, "@OAIPASSWORD@", conf.OAI.Password, 3)
// newConfigure = strings.Replace(newConfigure, "@OAIREMOTEHOST@", conf.OAI.RemoteHost, 3)
// newConfigure = strings.Replace(newConfigure, "@GTPUENTRY@", conf.VppConfigure.System.GtpuEntry, 1)
// newConfigure = strings.Replace(newConfigure, "@GTPUEXPORT@", conf.VppConfigure.System.GtpuExport, 1)
// newConfigure = strings.Replace(newConfigure, "@GATEWAY@", conf.VppConfigure.Link.VppHost, 1)
// confScript := *out + "/upf.yaml"
// f, err := os.Create(confScript)
// defer f.Close()
// if err != nil {
// fmt.Println(err.Error())
// } else {
// _, err = f.Write([]byte(newConfigure))
// }
//}
//arp
//arp, err := ioutil.ReadFile(*in + "/arp_run.template")
//if err != nil {
// fmt.Println("读取 arp 模板文件失败")
//} else {
// arpTemplate := string(arp)
// newArp := strings.Replace(arpTemplate, "@UEIP@", conf.VppConfigure.Link.Ueip, 1)
// newArp = strings.Replace(newArp, "@PREFIX@", conf.VppConfigure.Link.UeIPPrefix, 1)
// newArp = strings.Replace(newArp, "@INTER@", conf.VppConfigure.Link.VppHost, 1)
// newArp = strings.Replace(newArp, "@MAC@", getMacAddress(conf.VppConfigure.Link.VppHost), 1)
// arpScript := *out + "/arp_run.sh"
// f, err := os.Create(arpScript)
// defer f.Close()
// if err != nil {
// fmt.Println(err.Error())
// } else {
// _, err = f.Write([]byte(newArp))
// }
// err = os.Chmod(arpScript, os.ModePerm)
//}
//system
system, err := ioutil.ReadFile("/opt/5gc/template/config_system.template")
if err != nil {
......@@ -146,6 +101,8 @@ func main() {
systemTemplate := string(system)
newSystem := strings.Replace(systemTemplate, "@gtpu_entry@", c.VppConfigure.System.GtpuEntry, 2)
newSystem = strings.Replace(newSystem, "@gtpu_export@", c.VppConfigure.System.GtpuExport, 3)
newSystem = strings.Replace(newSystem, "@gtpu_entry_ip@", c.VppConfigure.System.GtpuEntryIP, 2)
newSystem = strings.Replace(newSystem, "@gtpu_export_ip@", c.VppConfigure.System.GtpuExportIP, 1)
newSystem = strings.Replace(newSystem, " @gnb_gtpu_ip@", c.VppConfigure.System.GtpuGnb, 1)
systemScript := *out + "/config_system.sh"
f, err := os.Create(systemScript)
......@@ -158,37 +115,13 @@ func main() {
err = os.Chmod(systemScript, os.ModePerm)
}
//ip_link
//ipLink, err := ioutil.ReadFile(*in + "/ip_link.template")
//if err != nil {
// fmt.Println("读取 ip_link 模板文件失败")
//} else {
// linkTemplate := string(ipLink)
// newLink := strings.Replace(linkTemplate, "@UE_IP@", c.VppConfigure.Link.Ueip, 1)
// newLink = strings.Replace(newLink, "@UE_IP_PREFIX@", c.VppConfigure.Link.UeIPPrefix, 1)
// newLink = strings.Replace(newLink, "@SNAT_INTER@", c.VppConfigure.Link.SnatInter, 1)
// newLink = strings.Replace(newLink, "@SNAT_IP@", c.VppConfigure.Link.SnatIP, 1)
// newLink = strings.Replace(newLink, "@VPPHOST@", c.VppConfigure.Link.VppHost, 1)
// newLink = strings.Replace(newLink, "@DPDK_ENTRY@", c.VppConfigure.Link.GtpuEntry, 1)
// newLink = strings.Replace(newLink, "@DPDK_EXPORT@", c.VppConfigure.Link.GtpuExport, 1)
// linkScript := *out + "/ip_link.sh"
// f, err := os.Create(linkScript)
// defer f.Close()
// if err != nil {
// fmt.Println(err.Error())
// } else {
// _, err = f.Write([]byte(newLink))
// }
// err = os.Chmod(linkScript, os.ModePerm)
//}
//n4
n4, err := ioutil.ReadFile("/opt/5gc/template/n4.template")
if err != nil {
fmt.Println("读取 n4 模板文件失败")
} else {
n4Template := string(n4)
newN4 := strings.Replace(n4Template, "@gnb@", c.N4Configure.Gnb, 1)
newN4 := strings.Replace(n4Template, "@gnb@", c.VppConfigure.System.GtpuEntryIP, 1)
newN4 = strings.Replace(newN4, "@smf@", c.N4Configure.Smf, 1)
newN4 = strings.Replace(newN4, "@upf@", c.VppConfigure.Link.SnatIP, 1)
newN4 = strings.Replace(newN4, "@logSize@", c.N4Configure.LogSize, 1)
......@@ -221,28 +154,6 @@ func main() {
}
}
//unbind, err := ioutil.ReadFile(*in + "/unbind.template")
//if err != nil {
// fmt.Println("读取 unbind 模板文件失败")
//} else {
// unbindTemplate := string(unbind)
// newStartup := strings.Replace(unbindTemplate, "@PCI_ADDR_ID_ENTRY@", "0000:"+c.VppConfigure.Startup.PciAddrIdEntry, 1)
// newStartup = strings.Replace(newStartup, "@PCI_ADDR_ID_EXPORT@", "0000:"+c.VppConfigure.Startup.PciAddrIdExport, 1)
// newStartup = strings.Replace(newStartup, "@PCI_A@", c.VppConfigure.Startup.PciAddrIdEntry, 1)
// newStartup = strings.Replace(newStartup, "@PCI_B@", c.VppConfigure.Startup.PciAddrIdExport, 1)
// newStartup = strings.Replace(newStartup, "@DRIVER_TYPE@", c.VppConfigure.Startup.DriveType, 2)
// newStartup = strings.Replace(newStartup, "@DPDK_ENTRY@", c.VppConfigure.Link.GtpuEntry, 1)
// newStartup = strings.Replace(newStartup, "@DPDK_EXPORT@", c.VppConfigure.Link.GtpuExport, 1)
// unbindScript := *out + "/unbind.sh"
// f, err := os.Create(unbindScript)
// defer f.Close()
// if err != nil {
// fmt.Println(err.Error())
// } else {
// _, err = f.Write([]byte(newStartup))
// }
// err = os.Chmod(unbindScript, os.ModePerm)
//}
}
func (c *configure) readYaml(inPath string) *configure {
......
......@@ -300,19 +300,6 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
pdrid_2 := ie.NewPacketDetectionRuleID(2)
createdPDR := ie.NewCreatedPDR(pdrid_2)
if gNBIPIndex[gnbIP] == 0 {
gnbTeid += 1
gNBIPIndex[gnbIP] = gnbTeid
tunnelName := util.ExecShell("--create_tunnel", gnbIP, strconv.Itoa(gnbTeid))
gNBIPTunnel[gnbIP] = tunnelName
log.Info("create gtpu tunnel: %s", tunnelName)
}
if gNBIPTunnel[gnbIP] != "" {
util.ExecShell("--ip_route", ueIP, gNBIPTunnel[gnbIP])
log.Info("%s bind gtpu tunnel %s", ueIP, gNBIPTunnel[gnbIP])
}
req := &upf.UpfSsmCreateReq{
CpSeid: msg.SEID(),
Teid: outerHeaderCreation.TEID,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment