4 namespace eval excentis {
13 namespace eval ByteBlower {
18 set x.PPPoE.Schedules_Available [
expr [
llength [
info command ::Layer2_5.Pppoe.Client_Schedule.Add ] ] > 0 ]
20 set PPPoE_MultiSessionID 0
52 proc PPPoE.Setup { byteblowerPort pppoeServiceName authProtocol authProtocolCredentials networkProtocol { networkProtocolOptions {} } } {
53 if { [ llength $authProtocolCredentials ] != 2} {
54 error "PPPoE.Setup : missing required arguments for Auth Protocol Credentials"
58 set subLayers [ $byteblowerPort Layer2_5.PPPoE.Get ]
63 if { [ llength $subLayers ] > 0} {
64 error "PPPoE.Setup : Found existing PPPoE client"
66 set pppoe [ $byteblowerPort Layer2_5.PPPoE.Add ]
67 $pppoe ServiceName.Set ${pppoeServiceName}
68 set ppp [ $pppoe Ppp.Get ]
72 switch -- [
string tolower ${authProtocol} ] {
75 set auth [ $ppp AuthProtocol.[
string totitle ${authProtocol} ].Add ]
78 error "PPPoE.Setup : Unsupported PPP auth protocol: '${authProtocol}'"
82 switch -- [
string tolower ${authProtocol} ] {
84 $auth PeerID.Set [
lindex $authProtocolCredentials 0 ]
85 $auth Password.Set [
lindex $authProtocolCredentials 1 ]
88 $auth Secret.Set [
lindex $authProtocolCredentials 0 ]
91 error "PPPoE.Setup : Unsupported PPP auth protocol: '${authProtocol}'"
96 switch -- [
string tolower ${networkProtocol} ] {
99 set ncp [ $ppp Ncp.[
string totitle ${networkProtocol} ].Add ]
102 error "PPPoE.Setup : Unsupported PPP Network Control Protocol (NCP): '${networkProtocol}'"
106 if { [ $ncp Info -implements Layer2.Ppp.NetworkControl.Ipcp ]} {
107 set l3 [ $byteblowerPort Layer3.IPv4.Set ]
108 }
elseif { [ $ncp Info -implements Layer2.Ppp.NetworkControl.Ipv6cp ]} {
109 set l3 [ $byteblowerPort Layer3.IPv6.Set ]
111 error "Unknown Layer3 for NCP $ncp (${networkProtocol})"
113 x.Print.Debug "PPPoE.Setup : Added Layer3 : ${byteblowerPort} -> ${l3}"
117 return [ list $pppoe $ppp $auth $ncp ]
129 proc PPPoE.Start { pppoeSetupInformation } {
130 if { [ llength ${pppoeSetupInformation} ] != 4} {
131 error "PPPoE.Start : Please Provide the information returned from the 'PPPoE.Setup' procedure."
133 set pppoe [
lindex $pppoeSetupInformation 0 ]
136 return [ $pppoe Start ]
146 proc PPPoE.Start.Async { pppoeSetupInformation } {
147 if { [ llength ${pppoeSetupInformation} ] != 4} {
148 error "PPPoE.Start.Async : Please Provide the information returned from the 'PPPoE.Setup' procedure."
150 set pppoe [
lindex $pppoeSetupInformation 0 ]
165 proc PPPoE.SessionId.Get { pppoeSetupInformation } {
166 if { [ llength ${pppoeSetupInformation} ] != 4} {
167 error "PPPoE.Start : Please Provide the information returned from the 'PPPoE.Setup' procedure."
169 set pppoe [
lindex $pppoeSetupInformation 0 ]
172 return [ $pppoe SessionId.Get ]
175 if { ${x.PPPoE.Schedules_Available}} {
188 proc PPPoE.Schedule.Start.Setup { pppoeSetupInformation initialTimeToWait } {
189 if { [ llength ${pppoeSetupInformation} ] != 4} {
190 error "PPPoE.Schedule.Start.Setup : Please Provide the information returned from the 'PPPoE.Setup' procedure."
192 set pppoe [
lindex $pppoeSetupInformation 0 ]
195 set pppoeScheduleStart [ $pppoe Schedule.Add Start ]
196 $pppoeScheduleStart InitialTimeToWait.Set $initialTimeToWait
198 $pppoeScheduleStart ServiceName.Set [ $pppoe ServiceName.Get ]
200 return $pppoeScheduleStart
214 proc PPPoE.Schedule.Terminate.Setup { pppoeSetupInformation initialTimeToWait } {
215 if { [ llength ${pppoeSetupInformation} ] != 4} {
216 error "PPPoE.Schedule.Terminate.Setup : Please Provide the information returned from the 'PPPoE.Setup' procedure."
218 set pppoe [
lindex $pppoeSetupInformation 0 ]
221 set pppoeScheduleTerminate [ $pppoe Schedule.Add Terminate ]
222 $pppoeScheduleTerminate InitialTimeToWait.Set $initialTimeToWait
225 return $pppoeScheduleTerminate
239 proc PPPoE.Status.Get { pppoeSetupInformation } {
240 if { [ llength ${pppoeSetupInformation} ] != 4} {
241 error "PPPoE.Status.Get : Please Provide the information returned from the 'PPPoE.Setup' procedure."
243 set pppoe [
lindex $pppoeSetupInformation 0 ]
245 if { [ catch { $pppoe Status.Get } pppoeStatus ]} {
246 puts stderr "caught error: ${pppoeStatus}"
247 catch { puts stderr "caught error: [ ${pppoeStatus} Trace.Get ]" } dummy
248 set pppoeStatus "<ERROR>"
260 proc PPPoE.Terminate { pppoeSetupInformation } {
261 if { [ llength ${pppoeSetupInformation} ] != 4} {
262 error "PPPoE.Terminate : Please Provide the information returned from the 'PPPoE.Setup' procedure."
264 set pppoe [
lindex $pppoeSetupInformation 0 ]
284 proc PPPoE.NCP.Results.Get { pppoeSetupInformation } {
285 if { [ llength ${pppoeSetupInformation} ] != 4} {
286 error "PPPoE.NCP.Results.Get : Please Provide the information returned from the 'PPPoE.Setup' procedure."
288 set ncp [
lindex $pppoeSetupInformation 3 ]
290 if { [ $ncp Info -implements Layer2.Ppp.NetworkControl.Ipcp ]} {
291 set ipcpIpv4Address [ $ncp IpAddress.Get ]
292 set ipcpRemoteIpv4Address [ $ncp IpAddress.Remote.Get ]
293 set resultList [ list $ipcpIpv4Address $ipcpRemoteIpv4Address ]
294 }
elseif { [ $ncp Info -implements Layer2.Ppp.NetworkControl.Ipv6cp ]} {
295 set ipv6cpIpv6InterfaceIdentifier [ $ncp InterfaceIdentifier.Get ]
296 set ipv6cpRemoteIpv6InterfaceIdentifier [ $ncp InterfaceIdentifier.Remote.Get ]
297 set resultList [ list $ipv6cpIpv6InterfaceIdentifier $ipv6cpRemoteIpv6InterfaceIdentifier ]
338 proc PPPoE.MultiPPPoESessions.Setup { bbServer NrOfSessions basePortMacAddress papUserNameList papPasswordList { interSessionGap 0 } { networkProtocol "ipcp" } } {
340 puts "PPPoE.MultiPPPoESessions.Setup : Setting up $NrOfSessions PPPoE Sessions using Network Control Protocol \`${networkProtocol}'"
342 set papUserNameListLength [
llength $papUserNameList ]
343 set papPasswordListLength [
llength $papPasswordList ]
344 if { $papUserNameListLength != 1 &&\
345 $papUserNameListLength < $NrOfSessions &&\
346 $papPasswordListLength != 1 &&\
347 $papPasswordListLength < $NrOfSessions} {
348 error "PPPoE.MultiPPPoESessions.Setup : Invalid number of User names and / or passwords\
349 \n\tRequired one shared user name or at least one username per PPPoE session\
350 \n\tand one share password or at least one password per PPPoE session"
353 incr ::excentis::ByteBlower::PPPoE_MultiSessionID
354 set ::BB(PPPoE,Multisession,$::excentis::ByteBlower::PPPoE_MultiSessionID) [ list ]
356 set portMacAddress $basePortMacAddress
357 for {
set i 0} { $i < $NrOfSessions} {
incr i} {
359 set portNr [
expr $i + 1 ]
367 set numberOfTrunkPorts 2
368 set bbPort [ $bbServer Port.Create "trunk-1-[
expr ( ${portNr} % ${numberOfTrunkPorts} ) + 1 ]" ]
371 set l2 [ $bbPort Layer2.EthII.Set ]
372 $l2 Mac.Set $portMacAddress
375 if { $papUserNameListLength == 1} {
376 set papUserName [
lindex $papUserNameList 0 ]
378 set papUserName [
lindex $papUserNameList $i ]
380 if { $papPasswordListLength == 1} {
381 set papPassword [
lindex $papPasswordList 0 ]
383 set papPassword [
lindex $papPasswordList $i ]
388 set pppoeObj [
PPPoE.Setup $bbPort "ByteBlower-testing" \
389 "pap" [ list $papUserName $papPassword ] \
390 "${networkProtocol}" \
394 set ::BB(PPPoE,BBPort,$bbPort) $pppoeObj
395 lappend ::BB(PPPoE,Multisession,$::excentis::ByteBlower::PPPoE_MultiSessionID) $bbPort
403 if { $portNr % 64 == 0} {
404 puts " ${portNr}"
flush stdout
409 return $::excentis::ByteBlower::PPPoE_MultiSessionID
425 proc PPPoE.MultiPPPoESessions.Start { multiSessionID { interSessionGap 0 } } {
427 puts "PPPoE.MultiPPPoESessions.Start : Starting PPPoE Sessions for MultiSession $multiSessionID"
429 if { ! [
info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
430 error "PPPoE.StopMultiPPPoESessions : Invalid multiSessionID"
434 set systemSupportsColoring [
string equal $::tcl_platform(platform) unix ]
437 foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
441 if { $interSessionGap > 0 && $i > 1} {
443 after $interSessionGap "set waiter 1"
448 if { [ catch { PPPoE.Start.Async $::BB(PPPoE,BBPort,$bbPort) } startResult ]} {
449 if { $systemSupportsColoring} {
451 puts stderr "\n\t--> Session $i : Failed to start : \033\[0;31m[ $startResult Message.Get ]\033\[0;m"
454 puts stderr "\n\t--> Session $i : Failed to start : [ $startResult Message.Get ]"
460 puts " ${i}"
flush stdout
466 puts "PPPoE.MultiPPPoESessions.Start : Wait until PPPoE Sessions for MultiSession $multiSessionID started"
468 foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
472 if { [ catch { PPPoE.Start $::BB(PPPoE,BBPort,$bbPort) } startResult ]} {
473 if { $systemSupportsColoring} {
475 puts stderr "\n\t--> Session $i : Failed to start : \033\[0;31m[ $startResult Message.Get ]\033\[0;m"
478 puts stderr "\n\t--> Session $i : Failed to start : [ $startResult Message.Get ]"
484 puts " ${i}"
flush stdout
494 if { ${x.PPPoE.Schedules_Available}} {
496 proc PPPoE.MultiPPPoESessions.Schedule.Setup { multiSessionID { interSessionGap 1000 } { terminateAfterStartTime -1 } { interTerminateGap 1000 } } {
507 puts "PPPoE.MultiPPPoESessions.Schedule.Setup : Scheduling Start of PPPoE Sessions for MultiSession $multiSessionID"
509 if { ! [
info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
510 error "PPPoE.MultiPPPoESessions.Schedule.Setup : Invalid multiSessionID"
514 set systemSupportsColoring [
string equal $::tcl_platform(platform) unix ]
517 set startInitialTimeToWait 0
518 set terminateInitialTimeToWait $terminateAfterStartTime
519 foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
524 $::BB(PPPoE,ScheduledStart,$bbPort) Destructor
525 unset ::BB(PPPoE,ScheduledStart,$bbPort)
528 $::BB(PPPoE,ScheduledTerminate,$bbPort) Destructor
529 unset ::BB(PPPoE,ScheduledTerminate,$bbPort)
531 if { [ catch { PPPoE.Schedule.Start.Setup $::BB(PPPoE,BBPort,$bbPort) "${startInitialTimeToWait}ms" } scheduleResult ]} {
532 if { $systemSupportsColoring} {
534 puts stderr "\n\t--> Session $i : Failed to schedule Start : \033\[0;31m[ $scheduleResult Message.Get ]\033\[0;m"
537 puts stderr "\n\t--> Session $i : Failed to schedule Start : [ $scheduleResult Message.Get ]"
543 puts " ${i}"
flush stdout
545 set ::BB(PPPoE,ScheduledStart,$bbPort) $scheduleResult
548 incr startInitialTimeToWait $interSessionGap
550 if { $terminateAfterStartTime > 0} {
553 if { [ catch { PPPoE.Schedule.Terminate.Setup $::BB(PPPoE,BBPort,$bbPort) "[ expr $terminateInitialTimeToWait ]ms" } scheduleResult ]} {
554 if { $systemSupportsColoring} {
556 puts stderr "\n\t--> Session $i : Failed to schedule Terminate : \033\[0;31m[ $scheduleResult Message.Get ]\033\[0;m"
559 puts stderr "\n\t--> Session $i : Failed to schedule Terminate : [ $scheduleResult Message.Get ]"
563 set ::BB(PPPoE,ScheduledTerminate,$bbPort) $scheduleResult
566 incr terminateInitialTimeToWait $interTerminateGap
575 proc PPPoE.MultiPPPoESessions.Schedule.Start { multiSessionID } {
584 puts "PPPoE.MultiPPPoESessions.Schedule.Start : Starting scheduled Starts of PPPoE Sessions for MultiSession $multiSessionID"
586 if { ! [
info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
587 error "PPPoE.MultiPPPoESessions.Schedule.Start : Invalid multiSessionID"
591 set systemSupportsColoring [
string equal $::tcl_platform(platform) unix ]
594 set pppoeSchedules [ list ]
595 foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
599 if { [ info exists ::BB(PPPoE,ScheduledStart,$bbPort) ]} {
600 lappend pppoeSchedules $::BB(PPPoE,ScheduledStart,$bbPort)
605 if { [ info exists ::BB(PPPoE,ScheduledTerminate,$bbPort) ]} {
606 lappend pppoeSchedules $::BB(PPPoE,ScheduledTerminate,$bbPort)
612 puts " ${i}"
flush stdout
617 puts "PPPoE.MultiPPPoESessions.Schedule.Start : Starting ${i} Schedules"
618 eval ByteBlower Schedules.Start $pppoeSchedules
619 puts "PPPoE.MultiPPPoESessions.Schedule.Start : Schedules Started"
638 proc PPPoE.MultiPPPoESessions.Terminate { multiSessionID { interSessionGap 0 } } {
639 puts "PPPoE.MultiPPPoESessions.Terminate : Terminating PPPoESessions for MultiSession $multiSessionID"
641 if { ! [
info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
642 error "PPPoE.MultiPPPoESessions.Terminate : Invalid multiSessionID"
646 set systemSupportsColoring [
string equal $::tcl_platform(platform) unix ]
649 foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
652 if { $interSessionGap > 0 && $i > 1} {
654 after $interSessionGap "set waiter 1"
659 set sessionId [ [ lindex $::BB(PPPoE,BBPort,$bbPort) 0 ] SessionId.Get ]
660 if { [ catch { PPPoE.Terminate $::BB(PPPoE,BBPort,$bbPort) } terminateResult ]} {
661 if { $systemSupportsColoring} {
663 puts stderr "\n\t--> Session $i with Session ID $sessionId : Failed to Terminate : \033\[0;31m[ $terminateResult Message.Get ]\033\[0;m"
665 puts stderr "\n\t--> Session $i with Session ID $sessionId : Failed to Terminate : [ $terminateResult Message.Get ]"
671 puts " ${i}"
flush stdout
688 proc PPPoE.MultiPPPoESessions.CleanUp { multiSessionID } {
690 puts "PPPoE.MultiPPPoESessions.CleanUp : Cleaning up ByteBlower Ports for MultiSession $multiSessionID"
692 if { ! [
info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
693 error "PPPoE.MultiPPPoESessions.CleanUp : Invalid multiSessionID"
697 set systemSupportsColoring [
string equal $::tcl_platform(platform) unix ]
700 foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
704 if { [ catch { $bbPort Destructor } destructResult ]} {
705 if { $systemSupportsColoring} {
707 puts stderr "\n\t--> ByteBlower Port $i : Failed to cleanup : \033\[0;31m[ $destructResult Message.Get ]\033\[0;m"
709 puts stderr "\n\t--> ByteBlower Port $i : Failed to cleanup : [ $destructResult Message.Get ]"
712 unset ::BB(PPPoE,BBPort,$bbPort)
716 puts " ${i}"
flush stdout
721 unset ::BB(PPPoE,Multisession,$multiSessionID)