aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs901
1 files changed, 901 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs
new file mode 100644
index 0000000..ac6c0b4
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServerCommands.cs
@@ -0,0 +1,901 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using NDesk.Options;
32using OpenSim.Framework;
33using OpenSim.Framework.Console;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Region.ClientStack.LindenUDP
37{
38 public class LLUDPServerCommands
39 {
40 private ICommandConsole m_console;
41 private LLUDPServer m_udpServer;
42
43 public LLUDPServerCommands(ICommandConsole console, LLUDPServer udpServer)
44 {
45 m_console = console;
46 m_udpServer = udpServer;
47 }
48
49 public void Register()
50 {
51 m_console.Commands.AddCommand(
52 "Comms", false, "show server throttles",
53 "show server throttles",
54 "Show information about server throttles",
55 HandleShowServerThrottlesCommand);
56
57 m_console.Commands.AddCommand(
58 "Debug", false, "debug lludp packet",
59 "debug lludp packet [--default | --all] <level> [<avatar-first-name> <avatar-last-name>]",
60 "Turn on packet debugging. This logs information when the client stack hands a processed packet off to downstream code or when upstream code first requests that a certain packet be sent.",
61 "If level > 255 then all incoming and outgoing packets are logged.\n"
62 + "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n"
63 + "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n"
64 + "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n"
65 + "If level <= 50 then outgoing ImprovedTerseObjectUpdate packets are not logged.\n"
66 + "If level <= 0 then no packets are logged.\n"
67 + "If --default is specified then the level becomes the default logging level for all subsequent agents.\n"
68 + "If --all is specified then the level becomes the default logging level for all current and subsequent agents.\n"
69 + "In these cases, you cannot also specify an avatar name.\n"
70 + "If an avatar name is given then only packets from that avatar are logged.",
71 HandlePacketCommand);
72
73 m_console.Commands.AddCommand(
74 "Debug", false, "debug lludp data out",
75 "debug lludp data out <level> <avatar-first-name> <avatar-last-name>\"",
76 "Turn on debugging for final outgoing data to the given user's client.",
77 "This operates at a much lower level than the packet command and prints out available details when the data is actually sent.\n"
78 + "If level > 0 then information about all outgoing UDP data for this avatar is logged.\n"
79 + "If level <= 0 then no information about outgoing UDP data for this avatar is logged.",
80 HandleDataCommand);
81
82 m_console.Commands.AddCommand(
83 "Debug", false, "debug lludp drop",
84 "debug lludp drop <in|out> <add|remove> <packet-name>",
85 "Drop all in or outbound packets that match the given name",
86 "For test purposes.",
87 HandleDropCommand);
88
89 m_console.Commands.AddCommand(
90 "Debug",
91 false,
92 "debug lludp start",
93 "debug lludp start <in|out|all>",
94 "Control LLUDP packet processing.",
95 "No effect if packet processing has already started.\n"
96 + "in - start inbound processing.\n"
97 + "out - start outbound processing.\n"
98 + "all - start in and outbound processing.\n",
99 HandleStartCommand);
100
101 m_console.Commands.AddCommand(
102 "Debug",
103 false,
104 "debug lludp stop",
105 "debug lludp stop <in|out|all>",
106 "Stop LLUDP packet processing.",
107 "No effect if packet processing has already stopped.\n"
108 + "in - stop inbound processing.\n"
109 + "out - stop outbound processing.\n"
110 + "all - stop in and outbound processing.\n",
111 HandleStopCommand);
112
113 m_console.Commands.AddCommand(
114 "Debug",
115 false,
116 "debug lludp pool",
117 "debug lludp pool <on|off>",
118 "Turn object pooling within the lludp component on or off.",
119 HandlePoolCommand);
120
121 m_console.Commands.AddCommand(
122 "Debug",
123 false,
124 "debug lludp status",
125 "debug lludp status",
126 "Return status of LLUDP packet processing.",
127 HandleStatusCommand);
128
129 m_console.Commands.AddCommand(
130 "Debug",
131 false,
132 "debug lludp throttles log",
133 "debug lludp throttles log <level> [<avatar-first-name> <avatar-last-name>]",
134 "Change debug logging level for throttles.",
135 "If level >= 0 then throttle debug logging is performed.\n"
136 + "If level <= 0 then no throttle debug logging is performed.",
137 HandleThrottleCommand);
138
139 m_console.Commands.AddCommand(
140 "Debug",
141 false,
142 "debug lludp throttles get",
143 "debug lludp throttles get [<avatar-first-name> <avatar-last-name>]",
144 "Return debug settings for throttles.",
145 "adaptive - true/false, controls adaptive throttle setting.\n"
146 + "request - request drip rate in kbps.\n"
147 + "max - the max kbps throttle allowed for the specified existing clients. Use 'debug lludp get new-client-throttle-max' to see the setting for new clients.\n",
148 HandleThrottleGetCommand);
149
150 m_console.Commands.AddCommand(
151 "Debug",
152 false,
153 "debug lludp throttles set",
154 "debug lludp throttles set <param> <value> [<avatar-first-name> <avatar-last-name>]",
155 "Set a throttle parameter for the given client.",
156 "adaptive - true/false, controls adaptive throttle setting.\n"
157 + "current - current drip rate in kbps.\n"
158 + "request - requested drip rate in kbps.\n"
159 + "max - the max kbps throttle allowed for the specified existing clients. Use 'debug lludp set new-client-throttle-max' to change the settings for new clients.\n",
160 HandleThrottleSetCommand);
161
162 m_console.Commands.AddCommand(
163 "Debug",
164 false,
165 "debug lludp get",
166 "debug lludp get",
167 "Get debug parameters for the server.",
168 "max-scene-throttle - the current max cumulative kbps provided for this scene to clients.\n"
169 + "max-new-client-throttle - the max kbps throttle allowed to new clients. Use 'debug lludp throttles get max' to see the settings for existing clients.",
170 HandleGetCommand);
171
172 m_console.Commands.AddCommand(
173 "Debug",
174 false,
175 "debug lludp set",
176 "debug lludp set <param> <value>",
177 "Set a parameter for the server.",
178 "max-scene-throttle - the current max cumulative kbps provided for this scene to clients.\n"
179 + "max-new-client-throttle - the max kbps throttle allowed to each new client. Use 'debug lludp throttles set max' to set for existing clients.",
180 HandleSetCommand);
181
182 m_console.Commands.AddCommand(
183 "Debug",
184 false,
185 "debug lludp toggle agentupdate",
186 "debug lludp toggle agentupdate",
187 "Toggle whether agentupdate packets are processed or simply discarded.",
188 HandleAgentUpdateCommand);
189
190 MainConsole.Instance.Commands.AddCommand(
191 "Debug",
192 false,
193 "debug lludp oqre",
194 "debug lludp oqre <start|stop|status>",
195 "Start, stop or get status of OutgoingQueueRefillEngine.",
196 "If stopped then refill requests are processed directly via the threadpool.",
197 HandleOqreCommand);
198
199 m_console.Commands.AddCommand(
200 "Debug",
201 false,
202 "debug lludp client get",
203 "debug lludp client get [<avatar-first-name> <avatar-last-name>]",
204 "Get debug parameters for the client. If no name is given then all client information is returned.",
205 "process-unacked-sends - Do we take action if a sent reliable packet has not been acked.",
206 HandleClientGetCommand);
207
208 m_console.Commands.AddCommand(
209 "Debug",
210 false,
211 "debug lludp client set",
212 "debug lludp client set <param> <value> [<avatar-first-name> <avatar-last-name>]",
213 "Set a debug parameter for a particular client. If no name is given then the value is set on all clients.",
214 "process-unacked-sends - Do we take action if a sent reliable packet has not been acked.",
215 HandleClientSetCommand);
216 }
217
218 private void HandleShowServerThrottlesCommand(string module, string[] args)
219 {
220 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
221 return;
222
223 m_console.OutputFormat("Throttles for {0}", m_udpServer.Scene.Name);
224 ConsoleDisplayList cdl = new ConsoleDisplayList();
225 cdl.AddRow("Adaptive throttles", m_udpServer.ThrottleRates.AdaptiveThrottlesEnabled);
226
227 long maxSceneDripRate = m_udpServer.Throttle.MaxDripRate;
228 cdl.AddRow(
229 "Max scene throttle",
230 maxSceneDripRate != 0 ? string.Format("{0} kbps", maxSceneDripRate * 8 / 1000) : "unset");
231
232 int maxClientDripRate = m_udpServer.ThrottleRates.Total;
233 cdl.AddRow(
234 "Max new client throttle",
235 maxClientDripRate != 0 ? string.Format("{0} kbps", maxClientDripRate * 8 / 1000) : "unset");
236
237 m_console.Output(cdl.ToString());
238
239 m_console.OutputFormat("{0}\n", GetServerThrottlesReport(m_udpServer));
240 }
241
242 private string GetServerThrottlesReport(LLUDPServer udpServer)
243 {
244 StringBuilder report = new StringBuilder();
245
246 report.AppendFormat(
247 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}\n",
248 "Total",
249 "Resend",
250 "Land",
251 "Wind",
252 "Cloud",
253 "Task",
254 "Texture",
255 "Asset");
256
257 report.AppendFormat(
258 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}\n",
259 "kb/s",
260 "kb/s",
261 "kb/s",
262 "kb/s",
263 "kb/s",
264 "kb/s",
265 "kb/s",
266 "kb/s");
267
268 ThrottleRates throttleRates = udpServer.ThrottleRates;
269 report.AppendFormat(
270 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}",
271 (throttleRates.Total * 8) / 1000,
272 (throttleRates.Resend * 8) / 1000,
273 (throttleRates.Land * 8) / 1000,
274 (throttleRates.Wind * 8) / 1000,
275 (throttleRates.Cloud * 8) / 1000,
276 (throttleRates.Task * 8) / 1000,
277 (throttleRates.Texture * 8) / 1000,
278 (throttleRates.Asset * 8) / 1000);
279
280 return report.ToString();
281 }
282
283 protected string GetColumnEntry(string entry, int maxLength, int columnPadding)
284 {
285 return string.Format(
286 "{0,-" + maxLength + "}{1,-" + columnPadding + "}",
287 entry.Length > maxLength ? entry.Substring(0, maxLength) : entry,
288 "");
289 }
290
291 private void HandleDataCommand(string module, string[] args)
292 {
293 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
294 return;
295
296 if (args.Length != 7)
297 {
298 MainConsole.Instance.OutputFormat("Usage: debug lludp data out <true|false> <avatar-first-name> <avatar-last-name>");
299 return;
300 }
301
302 int level;
303 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out level))
304 return;
305
306 string firstName = args[5];
307 string lastName = args[6];
308
309 m_udpServer.Scene.ForEachScenePresence(sp =>
310 {
311 if (sp.Firstname == firstName && sp.Lastname == lastName)
312 {
313 MainConsole.Instance.OutputFormat(
314 "Data debug for {0} ({1}) set to {2} in {3}",
315 sp.Name, sp.IsChildAgent ? "child" : "root", level, m_udpServer.Scene.Name);
316
317 ((LLClientView)sp.ControllingClient).UDPClient.DebugDataOutLevel = level;
318 }
319 });
320 }
321
322 private void HandleThrottleCommand(string module, string[] args)
323 {
324 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
325 return;
326
327 bool all = args.Length == 5;
328 bool one = args.Length == 7;
329
330 if (!all && !one)
331 {
332 MainConsole.Instance.OutputFormat(
333 "Usage: debug lludp throttles log <level> [<avatar-first-name> <avatar-last-name>]");
334 return;
335 }
336
337 int level;
338 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out level))
339 return;
340
341 string firstName = null;
342 string lastName = null;
343
344 if (one)
345 {
346 firstName = args[5];
347 lastName = args[6];
348 }
349
350 m_udpServer.Scene.ForEachScenePresence(sp =>
351 {
352 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
353 {
354 MainConsole.Instance.OutputFormat(
355 "Throttle log level for {0} ({1}) set to {2} in {3}",
356 sp.Name, sp.IsChildAgent ? "child" : "root", level, m_udpServer.Scene.Name);
357
358 ((LLClientView)sp.ControllingClient).UDPClient.ThrottleDebugLevel = level;
359 }
360 });
361 }
362
363 private void HandleThrottleSetCommand(string module, string[] args)
364 {
365 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
366 return;
367
368 bool all = args.Length == 6;
369 bool one = args.Length == 8;
370
371 if (!all && !one)
372 {
373 MainConsole.Instance.OutputFormat(
374 "Usage: debug lludp throttles set <param> <value> [<avatar-first-name> <avatar-last-name>]");
375 return;
376 }
377
378 string param = args[4];
379 string rawValue = args[5];
380
381 string firstName = null;
382 string lastName = null;
383
384 if (one)
385 {
386 firstName = args[6];
387 lastName = args[7];
388 }
389
390 if (param == "adaptive")
391 {
392 bool newValue;
393 if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newValue))
394 return;
395
396 m_udpServer.Scene.ForEachScenePresence(sp =>
397 {
398 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
399 {
400 MainConsole.Instance.OutputFormat(
401 "Setting param {0} to {1} for {2} ({3}) in {4}",
402 param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
403
404 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
405 udpClient.FlowThrottle.AdaptiveEnabled = newValue;
406 // udpClient.FlowThrottle.MaxDripRate = 0;
407 // udpClient.FlowThrottle.AdjustedDripRate = 0;
408 }
409 });
410 }
411 else if (param == "request")
412 {
413 int newValue;
414 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
415 return;
416
417 int newCurrentThrottleKbps = newValue * 1000 / 8;
418
419 m_udpServer.Scene.ForEachScenePresence(sp =>
420 {
421 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
422 {
423 MainConsole.Instance.OutputFormat(
424 "Setting param {0} to {1} for {2} ({3}) in {4}",
425 param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
426
427 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
428 udpClient.FlowThrottle.RequestedDripRate = newCurrentThrottleKbps;
429 }
430 });
431 }
432 else if (param == "max")
433 {
434 int newValue;
435 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
436 return;
437
438 int newThrottleMaxKbps = newValue * 1000 / 8;
439
440 m_udpServer.Scene.ForEachScenePresence(sp =>
441 {
442 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
443 {
444 MainConsole.Instance.OutputFormat(
445 "Setting param {0} to {1} for {2} ({3}) in {4}",
446 param, newValue, sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
447
448 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
449 udpClient.FlowThrottle.MaxDripRate = newThrottleMaxKbps;
450 }
451 });
452 }
453 }
454
455 private void HandleThrottleGetCommand(string module, string[] args)
456 {
457 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
458 return;
459
460 bool all = args.Length == 4;
461 bool one = args.Length == 6;
462
463 if (!all && !one)
464 {
465 MainConsole.Instance.OutputFormat(
466 "Usage: debug lludp throttles get [<avatar-first-name> <avatar-last-name>]");
467 return;
468 }
469
470 string firstName = null;
471 string lastName = null;
472
473 if (one)
474 {
475 firstName = args[4];
476 lastName = args[5];
477 }
478
479 m_udpServer.Scene.ForEachScenePresence(sp =>
480 {
481 if (all || (sp.Firstname == firstName && sp.Lastname == lastName))
482 {
483 m_console.OutputFormat(
484 "Status for {0} ({1}) in {2}",
485 sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
486
487 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
488
489 ConsoleDisplayList cdl = new ConsoleDisplayList();
490 cdl.AddRow("adaptive", udpClient.FlowThrottle.AdaptiveEnabled);
491 cdl.AddRow("current", string.Format("{0} kbps", udpClient.FlowThrottle.DripRate * 8 / 1000));
492 cdl.AddRow("request", string.Format("{0} kbps", udpClient.FlowThrottle.RequestedDripRate * 8 / 1000));
493 cdl.AddRow("max", string.Format("{0} kbps", udpClient.FlowThrottle.MaxDripRate * 8 / 1000));
494
495 m_console.Output(cdl.ToString());
496 }
497 });
498 }
499
500 private void HandleGetCommand(string module, string[] args)
501 {
502 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
503 return;
504
505 m_console.OutputFormat("Debug settings for {0}", m_udpServer.Scene.Name);
506 ConsoleDisplayList cdl = new ConsoleDisplayList();
507
508 long maxSceneDripRate = m_udpServer.Throttle.MaxDripRate;
509 cdl.AddRow(
510 "max-scene-throttle",
511 maxSceneDripRate != 0 ? string.Format("{0} kbps", maxSceneDripRate * 8 / 1000) : "unset");
512
513 int maxClientDripRate = m_udpServer.ThrottleRates.Total;
514 cdl.AddRow(
515 "max-new-client-throttle",
516 maxClientDripRate != 0 ? string.Format("{0} kbps", maxClientDripRate * 8 / 1000) : "unset");
517
518 m_console.Output(cdl.ToString());
519 }
520
521 private void HandleSetCommand(string module, string[] args)
522 {
523 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
524 return;
525
526 if (args.Length != 5)
527 {
528 MainConsole.Instance.OutputFormat("Usage: debug lludp set <param> <value>");
529 return;
530 }
531
532 string param = args[3];
533 string rawValue = args[4];
534
535 int newValue;
536
537 if (param == "max-scene-throttle")
538 {
539 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
540 return;
541
542 m_udpServer.Throttle.MaxDripRate = newValue * 1000 / 8;
543 }
544 else if (param == "max-new-client-throttle")
545 {
546 if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, rawValue, out newValue))
547 return;
548
549 m_udpServer.ThrottleRates.Total = newValue * 1000 / 8;
550 }
551 else
552 {
553 return;
554 }
555
556 m_console.OutputFormat("{0} set to {1} in {2}", param, rawValue, m_udpServer.Scene.Name);
557 }
558
559 private void HandleClientGetCommand(string module, string[] args)
560 {
561 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
562 return;
563
564 if (args.Length != 4 && args.Length != 6)
565 {
566 MainConsole.Instance.OutputFormat("Usage: debug lludp client get [<avatar-first-name> <avatar-last-name>]");
567 return;
568 }
569
570 string name = null;
571
572 if (args.Length == 6)
573 name = string.Format("{0} {1}", args[4], args[5]);
574
575 m_udpServer.Scene.ForEachScenePresence(
576 sp =>
577 {
578 if ((name == null || sp.Name == name) && sp.ControllingClient is LLClientView)
579 {
580 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
581
582 m_console.OutputFormat(
583 "Client debug parameters for {0} ({1}) in {2}",
584 sp.Name, sp.IsChildAgent ? "child" : "root", m_udpServer.Scene.Name);
585
586 ConsoleDisplayList cdl = new ConsoleDisplayList();
587 cdl.AddRow("process-unacked-sends", udpClient.ProcessUnackedSends);
588
589 m_console.Output(cdl.ToString());
590 }
591 });
592 }
593
594 private void HandleClientSetCommand(string module, string[] args)
595 {
596 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
597 return;
598
599 if (args.Length != 6 && args.Length != 8)
600 {
601 MainConsole.Instance.OutputFormat("Usage: debug lludp client set <param> <value> [<avatar-first-name> <avatar-last-name>]");
602 return;
603 }
604
605 string param = args[4];
606 string rawValue = args[5];
607
608 string name = null;
609
610 if (args.Length == 8)
611 name = string.Format("{0} {1}", args[6], args[7]);
612
613 if (param == "process-unacked-sends")
614 {
615 bool newValue;
616
617 if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newValue))
618 return;
619
620 m_udpServer.Scene.ForEachScenePresence(
621 sp =>
622 {
623 if ((name == null || sp.Name == name) && sp.ControllingClient is LLClientView)
624 {
625 LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
626 udpClient.ProcessUnackedSends = newValue;
627
628 m_console.OutputFormat("{0} set to {1} for {2} in {3}", param, newValue, sp.Name, m_udpServer.Scene.Name);
629 }
630 });
631 }
632 }
633
634 private void HandlePacketCommand(string module, string[] args)
635 {
636 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
637 return;
638
639 bool setAsDefaultLevel = false;
640 bool setAll = false;
641 OptionSet optionSet = new OptionSet()
642 .Add("default", o => setAsDefaultLevel = (o != null))
643 .Add("all", o => setAll = (o != null));
644 List<string> filteredArgs = optionSet.Parse(args);
645
646 string name = null;
647
648 if (filteredArgs.Count == 6)
649 {
650 if (!(setAsDefaultLevel || setAll))
651 {
652 name = string.Format("{0} {1}", filteredArgs[4], filteredArgs[5]);
653 }
654 else
655 {
656 MainConsole.Instance.OutputFormat("ERROR: Cannot specify a user name when setting default/all logging level");
657 return;
658 }
659 }
660
661 if (filteredArgs.Count > 3)
662 {
663 int newDebug;
664 if (int.TryParse(filteredArgs[3], out newDebug))
665 {
666 if (setAsDefaultLevel || setAll)
667 {
668 m_udpServer.DefaultClientPacketDebugLevel = newDebug;
669
670 MainConsole.Instance.OutputFormat(
671 "Packet debug for {0} clients set to {1} in {2}",
672 (setAll ? "all" : "future"), m_udpServer.DefaultClientPacketDebugLevel, m_udpServer.Scene.Name);
673
674 if (setAll)
675 {
676 m_udpServer.Scene.ForEachScenePresence(sp =>
677 {
678 MainConsole.Instance.OutputFormat(
679 "Packet debug for {0} ({1}) set to {2} in {3}",
680 sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_udpServer.Scene.Name);
681
682 sp.ControllingClient.DebugPacketLevel = newDebug;
683 });
684 }
685 }
686 else
687 {
688 m_udpServer.Scene.ForEachScenePresence(sp =>
689 {
690 if (name == null || sp.Name == name)
691 {
692 MainConsole.Instance.OutputFormat(
693 "Packet debug for {0} ({1}) set to {2} in {3}",
694 sp.Name, sp.IsChildAgent ? "child" : "root", newDebug, m_udpServer.Scene.Name);
695
696 sp.ControllingClient.DebugPacketLevel = newDebug;
697 }
698 });
699 }
700 }
701 else
702 {
703 MainConsole.Instance.Output("Usage: debug lludp packet [--default | --all] 0..255 [<first-name> <last-name>]");
704 }
705 }
706 }
707
708 private void HandleDropCommand(string module, string[] args)
709 {
710 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
711 return;
712
713 if (args.Length != 6)
714 {
715 MainConsole.Instance.Output("Usage: debug lludp drop <in|out> <add|remove> <packet-name>");
716 return;
717 }
718
719 string direction = args[3];
720 string subCommand = args[4];
721 string packetName = args[5];
722
723 if (subCommand == "add")
724 {
725 MainConsole.Instance.OutputFormat(
726 "Adding packet {0} to {1} drop list for all connections in {2}",
727 direction, packetName, m_udpServer.Scene.Name);
728
729 m_udpServer.Scene.ForEachScenePresence(
730 sp =>
731 {
732 LLClientView llcv = (LLClientView)sp.ControllingClient;
733
734 if (direction == "in")
735 llcv.AddInPacketToDropSet(packetName);
736 else if (direction == "out")
737 llcv.AddOutPacketToDropSet(packetName);
738 }
739 );
740 }
741 else if (subCommand == "remove")
742 {
743 MainConsole.Instance.OutputFormat(
744 "Removing packet {0} from {1} drop list for all connections in {2}",
745 direction, packetName, m_udpServer.Scene.Name);
746
747 m_udpServer.Scene.ForEachScenePresence(
748 sp =>
749 {
750 LLClientView llcv = (LLClientView)sp.ControllingClient;
751
752 if (direction == "in")
753 llcv.RemoveInPacketFromDropSet(packetName);
754 else if (direction == "out")
755 llcv.RemoveOutPacketFromDropSet(packetName);
756 }
757 );
758 }
759 }
760
761 private void HandleStartCommand(string module, string[] args)
762 {
763 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
764 return;
765
766 if (args.Length != 4)
767 {
768 MainConsole.Instance.Output("Usage: debug lludp start <in|out|all>");
769 return;
770 }
771
772 string subCommand = args[3];
773
774 if (subCommand == "in" || subCommand == "all")
775 m_udpServer.StartInbound();
776
777 if (subCommand == "out" || subCommand == "all")
778 m_udpServer.StartOutbound();
779 }
780
781 private void HandleStopCommand(string module, string[] args)
782 {
783 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
784 return;
785
786 if (args.Length != 4)
787 {
788 MainConsole.Instance.Output("Usage: debug lludp stop <in|out|all>");
789 return;
790 }
791
792 string subCommand = args[3];
793
794 if (subCommand == "in" || subCommand == "all")
795 m_udpServer.StopInbound();
796
797 if (subCommand == "out" || subCommand == "all")
798 m_udpServer.StopOutbound();
799 }
800
801 private void HandlePoolCommand(string module, string[] args)
802 {
803 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
804 return;
805
806 if (args.Length != 4)
807 {
808 MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
809 return;
810 }
811
812 string enabled = args[3];
813
814 if (enabled == "on")
815 {
816 if (m_udpServer.EnablePools())
817 {
818 m_udpServer.EnablePoolStats();
819 MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_udpServer.Scene.Name);
820 }
821 }
822 else if (enabled == "off")
823 {
824 if (m_udpServer.DisablePools())
825 {
826 m_udpServer.DisablePoolStats();
827 MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_udpServer.Scene.Name);
828 }
829 }
830 else
831 {
832 MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
833 }
834 }
835
836 private void HandleAgentUpdateCommand(string module, string[] args)
837 {
838 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
839 return;
840
841 m_udpServer.DiscardInboundAgentUpdates = !m_udpServer.DiscardInboundAgentUpdates;
842
843 MainConsole.Instance.OutputFormat(
844 "Discard AgentUpdates now {0} for {1}", m_udpServer.DiscardInboundAgentUpdates, m_udpServer.Scene.Name);
845 }
846
847 private void HandleStatusCommand(string module, string[] args)
848 {
849 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
850 return;
851
852 MainConsole.Instance.OutputFormat(
853 "IN LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningInbound ? "enabled" : "disabled");
854
855 MainConsole.Instance.OutputFormat(
856 "OUT LLUDP packet processing for {0} is {1}", m_udpServer.Scene.Name, m_udpServer.IsRunningOutbound ? "enabled" : "disabled");
857
858 MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_udpServer.Scene.Name, m_udpServer.UsePools ? "on" : "off");
859
860 MainConsole.Instance.OutputFormat(
861 "Packet debug level for new clients is {0}", m_udpServer.DefaultClientPacketDebugLevel);
862 }
863
864 private void HandleOqreCommand(string module, string[] args)
865 {
866 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)
867 return;
868
869 if (args.Length != 4)
870 {
871 MainConsole.Instance.Output("Usage: debug lludp oqre <stop|start|status>");
872 return;
873 }
874
875 string subCommand = args[3];
876
877 if (subCommand == "stop")
878 {
879 m_udpServer.OqrEngine.Stop();
880 MainConsole.Instance.OutputFormat("Stopped OQRE for {0}", m_udpServer.Scene.Name);
881 }
882 else if (subCommand == "start")
883 {
884 m_udpServer.OqrEngine.Start();
885 MainConsole.Instance.OutputFormat("Started OQRE for {0}", m_udpServer.Scene.Name);
886 }
887 else if (subCommand == "status")
888 {
889 MainConsole.Instance.OutputFormat("OQRE in {0}", m_udpServer.Scene.Name);
890 MainConsole.Instance.OutputFormat("Running: {0}", m_udpServer.OqrEngine.IsRunning);
891 MainConsole.Instance.OutputFormat(
892 "Requests waiting: {0}",
893 m_udpServer.OqrEngine.IsRunning ? m_udpServer.OqrEngine.JobsWaiting.ToString() : "n/a");
894 }
895 else
896 {
897 MainConsole.Instance.OutputFormat("Unrecognized OQRE subcommand {0}", subCommand);
898 }
899 }
900 }
901} \ No newline at end of file