Skip to content

Commit

Permalink
Add lspList
Browse files Browse the repository at this point in the history
  • Loading branch information
motok1 authored and Motok1 committed Apr 13, 2022
1 parent 9b6288b commit 4e5f55f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,23 +227,40 @@ func (s *Server) receivePcep(sessionAddr net.IP, pcepSvr *pcep.Server) {
fmt.Printf("[PCEP] Received PCRpt\n")
pcepSvr.ReadPcrpt(pcepSession.tcpConn, messageLength, report)
if report.LspObject.PlspId == 0 && !report.LspObject.SFlag {
//sync 終了
fmt.Printf(" Finish PCRpt State Synchronization\n")
pcepSession.isSynced = true
fmt.Printf(" %#v\n", pcepSession)
fmt.Printf("Session info: %#v\n", s.pcepSessionList)
} else if !report.LspObject.SFlag {
// report.LspObject.SFlag == 0 かつ report.LspObject.PlspId != 0 の場合、
} else if !report.LspObject.SFlag && report.SrpObject.SrpId != 0 {
// report.LspObject.SFlag == 0 かつ report.LspObject.PlspId != 0 かつ report.SrpObject.SrpId == initiate SRP-ID の場合、
// PCUpd/PCinitiate に対する応答用 report になる
fmt.Printf(" Finish Transaction SRP ID: %v)\n", report.SrpObject.SrpId)
// ToDo: report.SrpObject.SrpId != 0 => report.SrpObject.SrpId == initiate SRP-ID に変更する
fmt.Printf(" Finish Transaction SRP ID: %v\n", report.SrpObject.SrpId)
// 複数の pcep message が含まれている時?
lspData := lsp{
sessionAddr: pcepSession.pcepSessionAddr,
plspId: report.LspObject.PlspId,
name: report.LspObject.Name,
pcrptObject: *report,
}

s.lspList = removeLsp(s.lspList, lspData)
s.lspList = append(s.lspList, lspData)
} else if report.LspObject.SFlag {
fmt.Printf(" Synchronize LSP information for PLSP-ID: %v\n", report.LspObject.PlspId)
// 複数の pcep message が含まれている時?
lspData := lsp{
sessionAddr: pcepSession.pcepSessionAddr,
plspId: report.LspObject.PlspId,
name: report.LspObject.Name,
pcrptObject: *report,
}

s.lspList = removeLsp(s.lspList, lspData)
s.lspList = append(s.lspList, lspData)
} // TODO: elseでsync処理を追加
}
// TODO: elseでsync処理を追加
case pcep.MT_ERROR:
fmt.Printf("[PCEP] Received PCErr\n")
// TODO: エラー内容の表示
Expand Down Expand Up @@ -291,3 +308,15 @@ func removeSession(sessionList []pcepSession, e pcepSession) []pcepSession {
}
return result
}

func removeLsp(lspList []lsp, e lsp) []lsp {
// lspList から name, PLSP-ID, sessionAddr が一致するものを削除する
result := []lsp{}
for _, lsp := range lspList {
if lsp.name == e.name && lsp.plspId == e.plspId && lsp.sessionAddr.Equal(e.sessionAddr) {
continue
}
result = append(result, lsp)
}
return result
}
Empty file added pkg/server/session.go
Empty file.

0 comments on commit 4e5f55f

Please sign in to comment.