mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-10-04 19:42:02 +08:00
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
// Package lsa
|
|
// @Author: Wang Feng
|
|
// @Description:
|
|
// @Version: 0.1.0
|
|
// @Date: 2022/4/7 12:57
|
|
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
|
//
|
|
|
|
package lsa
|
|
|
|
import (
|
|
"fmt"
|
|
"minlib/component"
|
|
"testing"
|
|
)
|
|
|
|
func getILsa(lsa ILsa) {
|
|
fmt.Println(lsa.GetType())
|
|
fmt.Println(lsa.GetOriginRouter().ToUri())
|
|
fmt.Println(lsa.GetSeqNo())
|
|
fmt.Println(lsa.GetExpirationTime())
|
|
lsa.SetSeqNo(1122)
|
|
fmt.Println("修改后:",lsa.GetSeqNo())
|
|
}
|
|
|
|
func TestILsa_GetType(t *testing.T) {
|
|
// 直接使用struct{} 来初始化strut时,返回的是一个struct类型的值,而不是指针两者是不一样的
|
|
//nameLsa := NameLsa{
|
|
// SelfEncodingBase: encoding.SelfEncodingBase{},
|
|
// LsaBase: LsaBase{},
|
|
// NameLsaNamePrefixList: NameLsaNamePrefixList{},
|
|
//}
|
|
//getILsa(&nameLsa)
|
|
|
|
// 这是一个用来分配内存的内置函数,它的第一个参数是一个类型,不是一个值,
|
|
// 它的返回值是一个指向新分配的 t 类型的零值的指针
|
|
// func new(t Type) *Type
|
|
base := new(NameLsa)
|
|
base.SetLsaExpirationTime(2000)
|
|
base.SetLsaSequenceNumber(1234)
|
|
base.LsaOriginRouterIdentifier,_ = component.CreateIdentifierByString("/min/pku")
|
|
ident,_ := component.CreateIdentifierByString("/pku/routerfucker")
|
|
base.Insert(ident,"/bind")
|
|
base.Insert(ident,"/wechat")
|
|
ident,_ = component.CreateIdentifierByString("/pku/router")
|
|
base.Insert(ident,"/qq")
|
|
fmt.Println(base.ToString())
|
|
// 测试通过接口进行调用
|
|
getILsa(base)
|
|
}
|