All Classes Namespaces Files Functions Pages
pppoe.tcl
1 ##
2 # @brief Basic namespace for all Excentis Tcl extensions
3 #
4 namespace eval excentis {
5 
6 ##
7 # @brief This namespace holds all ByteBlower-related Tcl extensions, including the ByteBlower higher-layer Tcl API.
8 #
9 # These procedures are developed for higher-level usage of the ByteBlower API.
10 # They are mainly used to simplify running specific Test Scenarios similar to
11 # scenarios you know from the ByteBlower GUI.
12 #
13 namespace eval ByteBlower {
14 
15 # This files includes helper functions to perform PPPoE Setup.
16 
17 # Is scheduling supported on the ByteBlower LL?
18 set x.PPPoE.Schedules_Available [ expr [ llength [ info command ::Layer2_5.Pppoe.Client_Schedule.Add ] ] > 0 ]
19 
20 set PPPoE_MultiSessionID 0
21 
22 ##
23 # Prepare the ByteBlower Port for performing PPPoE
24 #
25 # @param byteblowerPort
26 # The ByteBlowerPort on which we would like to configure PPPoE on.
27 #
28 # @param pppoeServiceName
29 # The Requested PPPoE ServiceName
30 #
31 # @param authProtocol
32 # The Auth Protocol used for PPP
33 #
34 # @param authProtocolCredentials
35 # The credentials for the auth Protocol
36 # - When @varitem{authProtocol} is @truetype{pap}, this requires a list of 2 elements:
37 # - Peer-ID
38 # - Password
39 # - When @varitem{authProtocol} is @truetype{chap}, this requires a list of 1 element:
40 # - Secret
41 #
42 # @param networkProtocol
43 # The Network Control Protocol user for PPP
44 # Currently @truetype{ipcp} and @truetype{ipv6cp} are supported.
45 #
46 # @param networkProtocolOptions
47 # @defaultvalue{ }: No special Network Protocol configuration (automatic configuration)
48 #
49 # @return
50 # List of information that will be used as argument for other PPPoE functions
51 #
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"
55  }
56 
57  # --- Setup PPPoE
58  set subLayers [ $byteblowerPort Layer2_5.PPPoE.Get ]
59  #set pppoe [ lindex $subLayers 0 ]
60  #if { [ string equal $pppoe "" ] } {
61  # set pppoe [ $byteblowerPort Layer2_5.PPPoE.Add ]
62  #}
63  if { [ llength $subLayers ] > 0} {
64  error "PPPoE.Setup : Found existing PPPoE client"
65  }
66  set pppoe [ $byteblowerPort Layer2_5.PPPoE.Add ]
67  $pppoe ServiceName.Set ${pppoeServiceName}
68  set ppp [ $pppoe Ppp.Get ]
69  #x.Print.Debug "PPPoE.Setup : Got Ppp : $byteblowerPort -> $ppp"
70 
71  # Initialize the Authentication Protocol
72  switch -- [ string tolower ${authProtocol} ] {
73  pap -
74  chap {
75  set auth [ $ppp AuthProtocol.[ string totitle ${authProtocol} ].Add ]
76  }
77  default {
78  error "PPPoE.Setup : Unsupported PPP auth protocol: '${authProtocol}'"
79  }
80  }
81  #x.Print.Debug "PPPoE.Setup : Got Auth : $byteblowerPort -> $auth (${authProtocol})"
82  switch -- [ string tolower ${authProtocol} ] {
83  pap {
84  $auth PeerID.Set [ lindex $authProtocolCredentials 0 ]
85  $auth Password.Set [ lindex $authProtocolCredentials 1 ]
86  }
87  chap {
88  $auth Secret.Set [ lindex $authProtocolCredentials 0 ]
89  }
90  default {
91  error "PPPoE.Setup : Unsupported PPP auth protocol: '${authProtocol}'"
92  }
93  }
94 
95  # Initialize the Network Control Protocol
96  switch -- [ string tolower ${networkProtocol} ] {
97  ipcp -
98  ipv6cp {
99  set ncp [ $ppp Ncp.[ string totitle ${networkProtocol} ].Add ]
100  }
101  default {
102  error "PPPoE.Setup : Unsupported PPP Network Control Protocol (NCP): '${networkProtocol}'"
103  }
104  }
105  #x.Print.Debug "PPPoE.Setup : Got Ncp : $byteblowerPort -> $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 ]
110  } else {
111  error "Unknown Layer3 for NCP $ncp (${networkProtocol})"
112  }
113  x.Print.Debug "PPPoE.Setup : Added Layer3 : ${byteblowerPort} -> ${l3}"
114  $ncp Open
115 
116  # --- Return the PPPoE Setup
117  return [ list $pppoe $ppp $auth $ncp ]
118 }
119 
120 ##
121 # Starts the PPPoE session
122 #
123 # @param pppoeSetupInformation
124 # The list of information returned from method 'PPPoE.Setup'
125 #
126 # @return
127 # PPPoE Session ID
128 #
129 proc PPPoE.Start { pppoeSetupInformation } {
130  if { [ llength ${pppoeSetupInformation} ] != 4} {
131  error "PPPoE.Start : Please Provide the information returned from the 'PPPoE.Setup' procedure."
132  }
133  set pppoe [ lindex $pppoeSetupInformation 0 ]
134 
135  # --- Return the PPPoE Session ID
136  return [ $pppoe Start ]
137 }
138 
139 ##
140 # Starts the PPPoE session.
141 # Returns immediately. Please use PPPoE.Start to obtain the actual results and session ID.
142 #
143 # @param pppoeSetupInformation
144 # The list of information returned from method 'PPPoE.Setup'
145 #
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."
149  }
150  set pppoe [ lindex $pppoeSetupInformation 0 ]
151 
152  # --- Returns nothing
153  $pppoe Start.Async
154 }
155 
156 ##
157 # Get the Session ID from the given PPPoE session
158 #
159 # @param pppoeSetupInformation
160 # The list of information returned from method 'PPPoE.Setup'
161 #
162 # @return
163 # PPPoE Session ID
164 #
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."
168  }
169  set pppoe [ lindex $pppoeSetupInformation 0 ]
170 
171  # --- Return the PPPoE Session ID
172  return [ $pppoe SessionId.Get ]
173 }
174 
175 if { ${x.PPPoE.Schedules_Available}} {
176 
177 ##
178 # Starts the PPPoE session
179 #
180 # @param pppoeSetupInformation
181 # The list of information returned from method 'PPPoE.Setup'
182 #
183 # @param initialTimeToWait
184 #
185 # @return
186 # PPPoE Session ID
187 #
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."
191  }
192  set pppoe [ lindex $pppoeSetupInformation 0 ]
193 
194  # --- Return the PPPoE Session ID
195  set pppoeScheduleStart [ $pppoe Schedule.Add Start ]
196  $pppoeScheduleStart InitialTimeToWait.Set $initialTimeToWait
197  #x.Print.Debug "PPPoE.Schedule.Start.Setup : InitialTimeToWait is set to '[ $pppoeScheduleStart InitialTimeToWait.Get ]'"
198  $pppoeScheduleStart ServiceName.Set [ $pppoe ServiceName.Get ]
199 
200  return $pppoeScheduleStart
201 }
202 
203 ##
204 # Starts the PPPoE session
205 #
206 # @param pppoeSetupInformation
207 # The list of information returned from method 'PPPoE.Setup'
208 #
209 # @param initialTimeToWait
210 #
211 # @return
212 # PPPoE Session ID
213 #
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."
217  }
218  set pppoe [ lindex $pppoeSetupInformation 0 ]
219 
220  # --- Return the PPPoE Session ID
221  set pppoeScheduleTerminate [ $pppoe Schedule.Add Terminate ]
222  $pppoeScheduleTerminate InitialTimeToWait.Set $initialTimeToWait
223  #x.Print.Debug "PPPoE.Schedule.Terminate.Setup : InitialTimeToWait is set to '[ $pppoeScheduleTerminate InitialTimeToWait.Get ]'"
224 
225  return $pppoeScheduleTerminate
226 }
227 
228 } ;# x.PPPoE.Schedules_Available
229 
230 ##
231 # Gets the status of the PPPoE session
232 #
233 # @param pppoeSetupInformation
234 # The list of information returned from method 'PPPoE.Setup'
235 #
236 # @return
237 # PPPoE Status string
238 #
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."
242  }
243  set pppoe [ lindex $pppoeSetupInformation 0 ]
244 
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>"
249  }
250 
251  return $pppoeStatus
252 }
253 
254 ##
255 # Terminates the PPPoE session
256 #
257 # @param pppoeSetupInformation
258 # The list of information returned from method 'PPPoE.Setup'
259 #
260 proc PPPoE.Terminate { pppoeSetupInformation } {
261  if { [ llength ${pppoeSetupInformation} ] != 4} {
262  error "PPPoE.Terminate : Please Provide the information returned from the 'PPPoE.Setup' procedure."
263  }
264  set pppoe [ lindex $pppoeSetupInformation 0 ]
265 
266  # --- Terminate the PPPoE Session
267  $pppoe Terminate
268 
269  return
270 }
271 
272 ##
273 # Get the PPPoE/PPP Network Control Protocol results
274 #
275 # @param pppoeSetupInformation
276 # The list of information returned from method 'PPPoE.Setup'
277 #
278 # @return
279 # Network Control Protocol Information:
280 # * for IPCP this is a list of:
281 # - Client IPv4 Address
282 # - BRAS IPv4 Address
283 #
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."
287  }
288  set ncp [ lindex $pppoeSetupInformation 3 ]
289  x.Print.Debug "NCP: [ $ncp Info -implements ]"
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 ]
298  }
299 
300  # --- Return the PPPoE Connection results
301  return $resultList
302 }
303 
304 ##
305 # Sets up Multiple PPPoE Sessions
306 #
307 # @param bbServer
308 # ByteBlower Server
309 #
310 # @param NrOfSessions
311 # Number of Sessions
312 #
313 # @param basePortMacAddress
314 # Mac Address of the first ByteBlower Port,
315 # Next ports will increment Mac address with 1.
316 #
317 # @param papUserNameList
318 # list of Username(s) for PAP authentication.
319 # Please provide one shared user name or
320 # at least one username per PPPoE session.
321 #
322 # @param papPasswordList
323 # list of Password(s) for PAP authentication.
324 # Please provide one share password or
325 # at least one password per PPPoE session.
326 #
327 # @param interSessionGap
328 # Time between finish of the start of a PPPoE Session
329 # and the start of the following PPPoE Session [ms]
330 #
331 # @param networkProtocol
332 # The Network Control Protocol user for PPP
333 # Currently ipcp and ipv6cp are supported.
334 #
335 # @return
336 # Identifier for the multiple PPPoE Sessions
337 #
338 proc PPPoE.MultiPPPoESessions.Setup { bbServer NrOfSessions basePortMacAddress papUserNameList papPasswordList { interSessionGap 0 } { networkProtocol "ipcp" } } {
339 
340  puts "PPPoE.MultiPPPoESessions.Setup : Setting up $NrOfSessions PPPoE Sessions using Network Control Protocol \`${networkProtocol}'"
341 
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"
351  }
352 
353  incr ::excentis::ByteBlower::PPPoE_MultiSessionID
354  set ::BB(PPPoE,Multisession,$::excentis::ByteBlower::PPPoE_MultiSessionID) [ list ]
355 
356  set portMacAddress $basePortMacAddress
357  for { set i 0} { $i < $NrOfSessions} { incr i} {
358  # --- Port number (1 - $NrOfSessions)
359  set portNr [ expr $i + 1 ]
360 
361  # --- Create BBPort
362  #set bbPort [ $bbServer Port.Create "trunk-1-${portNr}" ]
363  # --- Excentis internal (nontrunk-only test)
364  #set bbPort [ $bbServer Port.Create "nontrunk-[ expr ( ${portNr} % 2 ) + 1 ]" ]
365  #set bbPort [ $bbServer Port.Create "nontrunk-1" ]
366  # --- Excentis internal (trunk-only test)
367  set numberOfTrunkPorts 2
368  set bbPort [ $bbServer Port.Create "trunk-1-[ expr ( ${portNr} % ${numberOfTrunkPorts} ) + 1 ]" ]
369 
370  # --- Configure the Layer2
371  set l2 [ $bbPort Layer2.EthII.Set ]
372  $l2 Mac.Set $portMacAddress
373 
374  # --- PAP Settings for this PPPoE Session
375  if { $papUserNameListLength == 1} {
376  set papUserName [ lindex $papUserNameList 0 ]
377  } else {
378  set papUserName [ lindex $papUserNameList $i ]
379  }
380  if { $papPasswordListLength == 1} {
381  set papPassword [ lindex $papPasswordList 0 ]
382  } else {
383  set papPassword [ lindex $papPasswordList $i ]
384  }
385 
386  # --- Configure the PPPoE Session
387  # --- Excentis internal testing
388  set pppoeObj [ PPPoE.Setup $bbPort "ByteBlower-testing" \
389  "pap" [ list $papUserName $papPassword ] \
390  "${networkProtocol}" \
391  ]
392 
393  # --- Save Port to List
394  set ::BB(PPPoE,BBPort,$bbPort) $pppoeObj
395  lappend ::BB(PPPoE,Multisession,$::excentis::ByteBlower::PPPoE_MultiSessionID) $bbPort
396 
397  # --- Update Mac Address for next Port
398  set portMacAddress [ ::excentis::basic::Mac.Increment $portMacAddress ]
399 
400  # --- Starting the PPPoE session
401  #puts "\t--> Session $portNr : setup done"
402  puts -nonewline "."
403  if { $portNr % 64 == 0} {
404  puts " ${portNr}"; flush stdout
405  }
406  }
407  puts ""
408 
409  return $::excentis::ByteBlower::PPPoE_MultiSessionID
410 }
411 
412 ##
413 # Starts Multiple PPPoE Sessions, set up using 'PPPoE.MultiPPPoESessions.Setup'
414 #
415 # @param multiSessionID
416 # Returnvalue from 'PPPoE.MultiPPPoESessions.Start'
417 #
418 # @param interSessionGap
419 # Time between finish of the start of a PPPoE Session
420 # and the start of the following PPPoE Session [ms]
421 #
422 # @return
423 # Identifier for the multiple PPPoE Sessions
424 #
425 proc PPPoE.MultiPPPoESessions.Start { multiSessionID { interSessionGap 0 } } {
426 
427  puts "PPPoE.MultiPPPoESessions.Start : Starting PPPoE Sessions for MultiSession $multiSessionID"
428 
429  if { ! [ info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
430  error "PPPoE.StopMultiPPPoESessions : Invalid multiSessionID"
431  }
432 
433  # --- Does your system support console coloring?
434  set systemSupportsColoring [ string equal $::tcl_platform(platform) unix ]
435 
436  set i 0
437  foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
438  incr i 1
439 
440  # --- Wait before starting second port
441  if { $interSessionGap > 0 && $i > 1} {
442  set waiter 0
443  after $interSessionGap "set waiter 1"
444  vwait waiter
445  }
446 
447  # --- Starting the PPPoE session (async)
448  if { [ catch { PPPoE.Start.Async $::BB(PPPoE,BBPort,$bbPort) } startResult ]} {
449  if { $systemSupportsColoring} {
450  # --- Support for coloring
451  puts stderr "\n\t--> Session $i : Failed to start : \033\[0;31m[ $startResult Message.Get ]\033\[0;m"
452  } else {
453  # --- No support for coloring
454  puts stderr "\n\t--> Session $i : Failed to start : [ $startResult Message.Get ]"
455  }
456  } else {
457  #puts "\t--> Session $i : up and running"
458  puts -nonewline "."
459  if { $i % 64 == 0} {
460  puts " ${i}"; flush stdout
461  }
462  }
463  }
464  puts ""
465 
466  puts "PPPoE.MultiPPPoESessions.Start : Wait until PPPoE Sessions for MultiSession $multiSessionID started"
467  set i 0
468  foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
469  incr i 1
470 
471  # --- Starting the PPPoE session
472  if { [ catch { PPPoE.Start $::BB(PPPoE,BBPort,$bbPort) } startResult ]} {
473  if { $systemSupportsColoring} {
474  # --- Support for coloring
475  puts stderr "\n\t--> Session $i : Failed to start : \033\[0;31m[ $startResult Message.Get ]\033\[0;m"
476  } else {
477  # --- No support for coloring
478  puts stderr "\n\t--> Session $i : Failed to start : [ $startResult Message.Get ]"
479  }
480  } else {
481  #puts "\t--> Session $i : up and running"
482  puts -nonewline "."
483  if { $i % 64 == 0} {
484  puts " ${i}"; flush stdout
485  }
486  }
487  }
488  puts ""
489 
490  # --- all done
491  return
492 }
493 
494 if { ${x.PPPoE.Schedules_Available}} {
495 
496 proc PPPoE.MultiPPPoESessions.Schedule.Setup { multiSessionID { interSessionGap 1000 } { terminateAfterStartTime -1 } { interTerminateGap 1000 } } {
497 #
498 # Schedules the start of Multiple PPPoE Sessions, set up using 'PPPoE.MultiPPPoESessions.Setup'
499 #
500 # @param multiSessionID : Returnvalue from 'PPPoE.MultiPPPoESessions.Start'
501 # @param interSessionGap : Time between finish of the start of a PPPoE Session
502 # and the start of the following PPPoE Session [ms]
503 #
504 # @return void
505 #
506 
507  puts "PPPoE.MultiPPPoESessions.Schedule.Setup : Scheduling Start of PPPoE Sessions for MultiSession $multiSessionID"
508 
509  if { ! [ info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
510  error "PPPoE.MultiPPPoESessions.Schedule.Setup : Invalid multiSessionID"
511  }
512 
513  # --- Does your system support console coloring?
514  set systemSupportsColoring [ string equal $::tcl_platform(platform) unix ]
515 
516  set i 0
517  set startInitialTimeToWait 0
518  set terminateInitialTimeToWait $terminateAfterStartTime
519  foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
520  incr i 1
521 
522  # --- Starting the PPPoE session
523  catch {
524  $::BB(PPPoE,ScheduledStart,$bbPort) Destructor
525  unset ::BB(PPPoE,ScheduledStart,$bbPort)
526  } dummy
527  catch {
528  $::BB(PPPoE,ScheduledTerminate,$bbPort) Destructor
529  unset ::BB(PPPoE,ScheduledTerminate,$bbPort)
530  } dummy
531  if { [ catch { PPPoE.Schedule.Start.Setup $::BB(PPPoE,BBPort,$bbPort) "${startInitialTimeToWait}ms" } scheduleResult ]} {
532  if { $systemSupportsColoring} {
533  # --- Support for coloring
534  puts stderr "\n\t--> Session $i : Failed to schedule Start : \033\[0;31m[ $scheduleResult Message.Get ]\033\[0;m"
535  } else {
536  # --- No support for coloring
537  puts stderr "\n\t--> Session $i : Failed to schedule Start : [ $scheduleResult Message.Get ]"
538  }
539  } else {
540  #puts "\t--> Session $i : scheduled Start"
541  puts -nonewline "."
542  if { $i % 64 == 0} {
543  puts " ${i}"; flush stdout
544  }
545  set ::BB(PPPoE,ScheduledStart,$bbPort) $scheduleResult
546  }
547 
548  incr startInitialTimeToWait $interSessionGap
549 
550  if { $terminateAfterStartTime > 0} {
551  # (does destruct L1Session sometimes)
552  #if { [ catch { PPPoE.Schedule.Terminate.Setup $::BB(PPPoE,BBPort,$bbPort) "[ expr $interTerminateGap + $startInitialTimeToWait ]ms" } scheduleResult ] } {}
553  if { [ catch { PPPoE.Schedule.Terminate.Setup $::BB(PPPoE,BBPort,$bbPort) "[ expr $terminateInitialTimeToWait ]ms" } scheduleResult ]} {
554  if { $systemSupportsColoring} {
555  # --- Support for coloring
556  puts stderr "\n\t--> Session $i : Failed to schedule Terminate : \033\[0;31m[ $scheduleResult Message.Get ]\033\[0;m"
557  } else {
558  # --- No support for coloring
559  puts stderr "\n\t--> Session $i : Failed to schedule Terminate : [ $scheduleResult Message.Get ]"
560  }
561  } else {
562  #puts "\t--> Session $i : scheduled Terminate"
563  set ::BB(PPPoE,ScheduledTerminate,$bbPort) $scheduleResult
564  }
565 
566  incr terminateInitialTimeToWait $interTerminateGap
567  }
568  }
569  puts ""
570 
571  # --- all done
572  return
573 }
574 
575 proc PPPoE.MultiPPPoESessions.Schedule.Start { multiSessionID } {
576 #
577 # Starts the scheduled start of Multiple PPPoE Sessions, set up using 'PPPoE.MultiPPPoESessions.Setup'
578 #
579 # @param multiSessionID : Returnvalue from 'PPPoE.MultiPPPoESessions.Start'
580 #
581 # @return none
582 #
583 
584  puts "PPPoE.MultiPPPoESessions.Schedule.Start : Starting scheduled Starts of PPPoE Sessions for MultiSession $multiSessionID"
585 
586  if { ! [ info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
587  error "PPPoE.MultiPPPoESessions.Schedule.Start : Invalid multiSessionID"
588  }
589 
590  # --- Does your system support console coloring?
591  set systemSupportsColoring [ string equal $::tcl_platform(platform) unix ]
592 
593  set i 0
594  set pppoeSchedules [ list ]
595  foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
596  incr i 1
597 
598  # --- Starting the PPPoE session
599  if { [ info exists ::BB(PPPoE,ScheduledStart,$bbPort) ]} {
600  lappend pppoeSchedules $::BB(PPPoE,ScheduledStart,$bbPort)
601  #puts "\t--> Session $i : Start schedule will be started"
602  }
603 
604  # --- Starting the PPPoE session
605  if { [ info exists ::BB(PPPoE,ScheduledTerminate,$bbPort) ]} {
606  lappend pppoeSchedules $::BB(PPPoE,ScheduledTerminate,$bbPort)
607  #puts "\t--> Session $i : Terminate schedule will be started"
608  }
609 
610  puts -nonewline "."
611  if { $i % 64 == 0} {
612  puts " ${i}"; flush stdout
613  }
614  }
615  puts ""
616 
617  puts "PPPoE.MultiPPPoESessions.Schedule.Start : Starting ${i} Schedules"
618  eval ByteBlower Schedules.Start $pppoeSchedules
619  puts "PPPoE.MultiPPPoESessions.Schedule.Start : Schedules Started"
620 
621  # --- all done
622  return
623 }
624 
625 } ;# x.PPPoE.Schedules_Available
626 
627 ##
628 # Terminates Multiple PPPoE Sessions, setup using 'PPPoE.MultiPPPoESessions.Setup'
629 # and started using 'PPPoE.MultiPPPoESessions.Start'
630 #
631 # @param multiSessionID
632 # Returnvalue from 'PPPoE.MultiPPPoESessions.Start'
633 #
634 # @param interSessionGap
635 # Time between finish of the start of a PPPoE Session
636 # and the start of the following PPPoE Session [ms]
637 #
638 proc PPPoE.MultiPPPoESessions.Terminate { multiSessionID { interSessionGap 0 } } {
639  puts "PPPoE.MultiPPPoESessions.Terminate : Terminating PPPoESessions for MultiSession $multiSessionID"
640 
641  if { ! [ info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
642  error "PPPoE.MultiPPPoESessions.Terminate : Invalid multiSessionID"
643  }
644 
645  # --- Does your system support console coloring?
646  set systemSupportsColoring [ string equal $::tcl_platform(platform) unix ]
647 
648  set i 0
649  foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
650  incr i 1
651 
652  if { $interSessionGap > 0 && $i > 1} {
653  set waiter 0
654  after $interSessionGap "set waiter 1"
655  vwait waiter
656  }
657 
658  # --- Terminate the Session
659  set sessionId [ [ lindex $::BB(PPPoE,BBPort,$bbPort) 0 ] SessionId.Get ]
660  if { [ catch { PPPoE.Terminate $::BB(PPPoE,BBPort,$bbPort) } terminateResult ]} {
661  if { $systemSupportsColoring} {
662  # --- Support for coloring
663  puts stderr "\n\t--> Session $i with Session ID $sessionId : Failed to Terminate : \033\[0;31m[ $terminateResult Message.Get ]\033\[0;m"
664  } else {
665  puts stderr "\n\t--> Session $i with Session ID $sessionId : Failed to Terminate : [ $terminateResult Message.Get ]"
666  }
667  } else {
668  #puts "\t--> Session $i with Session ID $sessionId : down"
669  puts -nonewline "."
670  if { $i % 64 == 0} {
671  puts " ${i}"; flush stdout
672  }
673  }
674  }
675  puts ""
676 
677  # --- all done
678  return
679 }
680 
681 ##
682 # Terminates Multiple PPPoE Sessions, setup using 'PPPoE.MultiPPPoESessions.Setup'
683 # and started using 'PPPoE.MultiPPPoESessions.Start'
684 #
685 # @param multiSessionID
686 # Returnvalue from 'PPPoE.MultiPPPoESessions.Start'
687 #
688 proc PPPoE.MultiPPPoESessions.CleanUp { multiSessionID } {
689 
690  puts "PPPoE.MultiPPPoESessions.CleanUp : Cleaning up ByteBlower Ports for MultiSession $multiSessionID"
691 
692  if { ! [ info exists ::BB(PPPoE,Multisession,$multiSessionID) ]} {
693  error "PPPoE.MultiPPPoESessions.CleanUp : Invalid multiSessionID"
694  }
695 
696  # --- Does your system support console coloring?
697  set systemSupportsColoring [ string equal $::tcl_platform(platform) unix ]
698 
699  set i 0
700  foreach bbPort $::BB(PPPoE,Multisession,$multiSessionID) {
701  incr i 1
702 
703  # --- Destruct the ByteBlower Port
704  if { [ catch { $bbPort Destructor } destructResult ]} {
705  if { $systemSupportsColoring} {
706  # --- Support for coloring
707  puts stderr "\n\t--> ByteBlower Port $i : Failed to cleanup : \033\[0;31m[ $destructResult Message.Get ]\033\[0;m"
708  } else {
709  puts stderr "\n\t--> ByteBlower Port $i : Failed to cleanup : [ $destructResult Message.Get ]"
710  }
711  } else {
712  unset ::BB(PPPoE,BBPort,$bbPort)
713  #puts "\t--> ByteBlower Port $i : Cleaned up"
714  puts -nonewline "."
715  if { $i % 64 == 0} {
716  puts " ${i}"; flush stdout
717  }
718  }
719  }
720  puts ""
721  unset ::BB(PPPoE,Multisession,$multiSessionID)
722 
723  # --- all done
724  return
725 }
726 
727 
728 }
729 
730 }