aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs1
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs355
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs4
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs35
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs47
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs15
6 files changed, 349 insertions, 108 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index b53a2fb..9869a99 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -31,7 +31,6 @@ using OpenMetaverse;
31using OpenMetaverse.Imaging; 31using OpenMetaverse.Imaging;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes.Hypergrid;
35using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
36using log4net; 35using log4net;
37using System.Reflection; 36using System.Reflection;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 731dc8e..3262419 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -40,11 +40,9 @@ using OpenMetaverse.Packets;
40using OpenMetaverse.StructuredData; 40using OpenMetaverse.StructuredData;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Client; 42using OpenSim.Framework.Client;
43using OpenSim.Framework.Communications.Cache;
44using OpenSim.Framework.Statistics; 43using OpenSim.Framework.Statistics;
45using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
47using OpenSim.Region.Framework.Scenes.Hypergrid;
48using OpenSim.Services.Interfaces; 46using OpenSim.Services.Interfaces;
49using Timer = System.Timers.Timer; 47using Timer = System.Timers.Timer;
50using AssetLandmark = OpenSim.Framework.AssetLandmark; 48using AssetLandmark = OpenSim.Framework.AssetLandmark;
@@ -98,6 +96,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
98 /// </summary> 96 /// </summary>
99 public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector 97 public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector
100 { 98 {
99 /// <value>
100 /// Debug packet level. At the moment, only 255 does anything (prints out all in and out packets).
101 /// </value>
102 protected int m_debugPacketLevel = 0;
103
101 #region Events 104 #region Events
102 105
103 public event GenericMessage OnGenericMessage; 106 public event GenericMessage OnGenericMessage;
@@ -122,7 +125,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
122 public event ObjectAttach OnObjectAttach; 125 public event ObjectAttach OnObjectAttach;
123 public event ObjectDeselect OnObjectDetach; 126 public event ObjectDeselect OnObjectDetach;
124 public event ObjectDrop OnObjectDrop; 127 public event ObjectDrop OnObjectDrop;
125 public event GenericCall2 OnCompleteMovementToRegion; 128 public event GenericCall1 OnCompleteMovementToRegion;
129 public event UpdateAgent OnPreAgentUpdate;
126 public event UpdateAgent OnAgentUpdate; 130 public event UpdateAgent OnAgentUpdate;
127 public event AgentRequestSit OnAgentRequestSit; 131 public event AgentRequestSit OnAgentRequestSit;
128 public event AgentSit OnAgentSit; 132 public event AgentSit OnAgentSit;
@@ -178,6 +182,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
178 public event TeleportLocationRequest OnSetStartLocationRequest; 182 public event TeleportLocationRequest OnSetStartLocationRequest;
179 public event UpdateAvatarProperties OnUpdateAvatarProperties; 183 public event UpdateAvatarProperties OnUpdateAvatarProperties;
180 public event CreateNewInventoryItem OnCreateNewInventoryItem; 184 public event CreateNewInventoryItem OnCreateNewInventoryItem;
185 public event LinkInventoryItem OnLinkInventoryItem;
181 public event CreateInventoryFolder OnCreateNewInventoryFolder; 186 public event CreateInventoryFolder OnCreateNewInventoryFolder;
182 public event UpdateInventoryFolder OnUpdateInventoryFolder; 187 public event UpdateInventoryFolder OnUpdateInventoryFolder;
183 public event MoveInventoryFolder OnMoveInventoryFolder; 188 public event MoveInventoryFolder OnMoveInventoryFolder;
@@ -348,11 +353,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
348 protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates; 353 protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates;
349 private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates; 354 private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates;
350 private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates; 355 private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates;
356
357 /// <value>
358 /// List used in construction of data blocks for an object update packet. This is to stop us having to
359 /// continually recreate it.
360 /// </value>
361 protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
362
363 /// <value>
364 /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
365 /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
366 /// ownerless phantom.
367 ///
368 /// All manipulation of this set has to occur under a m_primFullUpdate.SyncRoot lock
369 ///
370 /// </value>
371 protected HashSet<uint> m_killRecord;
372
351 private int m_moneyBalance; 373 private int m_moneyBalance;
352 private int m_animationSequenceNumber = 1; 374 private int m_animationSequenceNumber = 1;
353 private bool m_SendLogoutPacketWhenClosing = true; 375 private bool m_SendLogoutPacketWhenClosing = true;
354 private AgentUpdateArgs lastarg; 376 private AgentUpdateArgs lastarg;
355 private bool m_IsActive = true; 377 private bool m_IsActive = true;
378 private bool m_IsLoggingOut = false;
356 379
357 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); 380 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
358 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers 381 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
@@ -416,6 +439,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
416 get { return m_IsActive; } 439 get { return m_IsActive; }
417 set { m_IsActive = value; } 440 set { m_IsActive = value; }
418 } 441 }
442 public bool IsLoggingOut
443 {
444 get { return m_IsLoggingOut; }
445 set { m_IsLoggingOut = value; }
446 }
447
419 public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } } 448 public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
420 449
421 #endregion Properties 450 #endregion Properties
@@ -437,6 +466,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
437 m_avatarTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); 466 m_avatarTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
438 m_primTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); 467 m_primTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
439 m_primFullUpdates = new PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock>(m_scene.Entities.Count); 468 m_primFullUpdates = new PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock>(m_scene.Entities.Count);
469 m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
470 m_killRecord = new HashSet<uint>();
440 471
441 m_assetService = m_scene.RequestModuleInterface<IAssetService>(); 472 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
442 m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>(); 473 m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>();
@@ -466,6 +497,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
466 497
467 public void SetDebugPacketLevel(int newDebug) 498 public void SetDebugPacketLevel(int newDebug)
468 { 499 {
500 m_debugPacketLevel = newDebug;
469 } 501 }
470 502
471 #region Client Methods 503 #region Client Methods
@@ -610,7 +642,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
610 if (pprocessor.Async) 642 if (pprocessor.Async)
611 { 643 {
612 object obj = new AsyncPacketProcess(this, pprocessor.method, packet); 644 object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
613 Util.FireAndForget(ProcessSpecificPacketAsync,obj); 645 Util.FireAndForget(ProcessSpecificPacketAsync, obj);
614 result = true; 646 result = true;
615 } 647 }
616 else 648 else
@@ -638,8 +670,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
638 public void ProcessSpecificPacketAsync(object state) 670 public void ProcessSpecificPacketAsync(object state)
639 { 671 {
640 AsyncPacketProcess packetObject = (AsyncPacketProcess)state; 672 AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
641 packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack); 673
642 674 try
675 {
676 packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
677 }
678 catch (Exception e)
679 {
680 // Make sure that we see any exception caused by the asynchronous operation.
681 m_log.Error(
682 string.Format("[LLCLIENTVIEW]: Caught exception while processing {0}", packetObject.Pack), e);
683 }
643 } 684 }
644 685
645 #endregion Packet Handling 686 #endregion Packet Handling
@@ -825,6 +866,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
825 gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock(); 866 gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
826 gmp.ParamList[i++].Parameter = val; 867 gmp.ParamList[i++].Parameter = val;
827 } 868 }
869
828 OutPacket(gmp, ThrottleOutPacketType.Task); 870 OutPacket(gmp, ThrottleOutPacketType.Task);
829 } 871 }
830 872
@@ -1461,7 +1503,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1461 kill.ObjectData[0].ID = localID; 1503 kill.ObjectData[0].ID = localID;
1462 kill.Header.Reliable = true; 1504 kill.Header.Reliable = true;
1463 kill.Header.Zerocoded = true; 1505 kill.Header.Zerocoded = true;
1464 OutPacket(kill, ThrottleOutPacketType.State); 1506
1507 lock (m_primFullUpdates.SyncRoot)
1508 {
1509 m_killRecord.Add(localID);
1510 OutPacket(kill, ThrottleOutPacketType.State);
1511 }
1465 } 1512 }
1466 1513
1467 /// <summary> 1514 /// <summary>
@@ -2512,6 +2559,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2512 2559
2513 public void SendAsset(AssetRequestToClient req) 2560 public void SendAsset(AssetRequestToClient req)
2514 { 2561 {
2562 if (req.AssetInf.Data == null)
2563 {
2564 m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
2565 req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
2566 return;
2567 }
2568
2515 //m_log.Debug("sending asset " + req.RequestAssetID); 2569 //m_log.Debug("sending asset " + req.RequestAssetID);
2516 TransferInfoPacket Transfer = new TransferInfoPacket(); 2570 TransferInfoPacket Transfer = new TransferInfoPacket();
2517 Transfer.TransferInfo.ChannelType = 2; 2571 Transfer.TransferInfo.ChannelType = 2;
@@ -3501,21 +3555,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3501 if (count == 0) 3555 if (count == 0)
3502 return; 3556 return;
3503 3557
3504 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count]; 3558 m_fullUpdateDataBlocksBuilder.Clear();
3559
3505 for (int i = 0; i < count; i++) 3560 for (int i = 0; i < count; i++)
3506 { 3561 {
3507 outPacket.ObjectData[i] = m_primFullUpdates.Dequeue(); 3562 ObjectUpdatePacket.ObjectDataBlock block = m_primFullUpdates.Dequeue();
3508 3563
3564 if (!m_killRecord.Contains(block.ID))
3565 {
3566 m_fullUpdateDataBlocksBuilder.Add(block);
3567
3509// string text = Util.FieldToString(outPacket.ObjectData[i].Text); 3568// string text = Util.FieldToString(outPacket.ObjectData[i].Text);
3510// if (text.IndexOf("\n") >= 0) 3569// if (text.IndexOf("\n") >= 0)
3511// text = text.Remove(text.IndexOf("\n")); 3570// text = text.Remove(text.IndexOf("\n"));
3512// m_log.DebugFormat( 3571// m_log.DebugFormat(
3513// "[CLIENT]: Sending full info about prim {0} text {1} to client {2}", 3572// "[CLIENT]: Sending full info about prim {0} text {1} to client {2}",
3514// outPacket.ObjectData[i].ID, text, Name); 3573// outPacket.ObjectData[i].ID, text, Name);
3574 }
3575// else
3576// {
3577// m_log.WarnFormat(
3578// "[CLIENT]: Preventing full update for {0} after kill to {1}", block.ID, Name);
3579// }
3515 } 3580 }
3516 }
3517 3581
3518 OutPacket(outPacket, ThrottleOutPacketType.State); 3582 outPacket.ObjectData = m_fullUpdateDataBlocksBuilder.ToArray();
3583
3584 OutPacket(outPacket, ThrottleOutPacketType.State);
3585 }
3519 } 3586 }
3520 3587
3521 public void SendPrimTerseUpdate(SendPrimitiveTerseData data) 3588 public void SendPrimTerseUpdate(SendPrimitiveTerseData data)
@@ -4051,10 +4118,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4051 EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock(); 4118 EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
4052 edata.CovenantID = covenant; 4119 edata.CovenantID = covenant;
4053 edata.CovenantTimestamp = 0; 4120 edata.CovenantTimestamp = 0;
4054 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) 4121 edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
4055 edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
4056 else
4057 edata.EstateOwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
4058 edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName); 4122 edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
4059 einfopack.Data = edata; 4123 einfopack.Data = edata;
4060 OutPacket(einfopack, ThrottleOutPacketType.Task); 4124 OutPacket(einfopack, ThrottleOutPacketType.Task);
@@ -4075,8 +4139,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4075 4139
4076 //Sending Estate Settings 4140 //Sending Estate Settings
4077 returnblock[0].Parameter = Utils.StringToBytes(estateName); 4141 returnblock[0].Parameter = Utils.StringToBytes(estateName);
4078 // TODO: remove this cruft once MasterAvatar is fully deprecated
4079 //
4080 returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString()); 4142 returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
4081 returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString()); 4143 returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
4082 4144
@@ -4674,6 +4736,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4674 AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder); 4736 AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
4675 AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder); 4737 AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
4676 AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem); 4738 AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
4739 AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
4677 AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory); 4740 AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
4678 AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents); 4741 AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
4679 AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents); 4742 AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
@@ -4866,7 +4929,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4866 UpdateAgent handlerAgentUpdate = OnAgentUpdate; 4929 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
4867 lastarg = arg; // save this set of arguments for nexttime 4930 lastarg = arg; // save this set of arguments for nexttime
4868 if (handlerAgentUpdate != null) 4931 if (handlerAgentUpdate != null)
4932 {
4933 OnPreAgentUpdate(this, arg);
4869 OnAgentUpdate(this, arg); 4934 OnAgentUpdate(this, arg);
4935 }
4870 4936
4871 handlerAgentUpdate = null; 4937 handlerAgentUpdate = null;
4872 } 4938 }
@@ -5505,6 +5571,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5505 // for the client session anyway, in order to protect ourselves against bad code in plugins 5571 // for the client session anyway, in order to protect ourselves against bad code in plugins
5506 try 5572 try
5507 { 5573 {
5574
5508 byte[] visualparams = new byte[appear.VisualParam.Length]; 5575 byte[] visualparams = new byte[appear.VisualParam.Length];
5509 for (int i = 0; i < appear.VisualParam.Length; i++) 5576 for (int i = 0; i < appear.VisualParam.Length; i++)
5510 visualparams[i] = appear.VisualParam[i].ParamValue; 5577 visualparams[i] = appear.VisualParam[i].ParamValue;
@@ -5715,10 +5782,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5715 5782
5716 private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack) 5783 private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
5717 { 5784 {
5718 GenericCall2 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; 5785 GenericCall1 handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
5719 if (handlerCompleteMovementToRegion != null) 5786 if (handlerCompleteMovementToRegion != null)
5720 { 5787 {
5721 handlerCompleteMovementToRegion(); 5788 handlerCompleteMovementToRegion(sender);
5722 } 5789 }
5723 handlerCompleteMovementToRegion = null; 5790 handlerCompleteMovementToRegion = null;
5724 5791
@@ -5946,7 +6013,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5946 || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f) 6013 || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
5947 { 6014 {
5948 ScenePresence avatar = null; 6015 ScenePresence avatar = null;
5949 if (((Scene)m_scene).TryGetAvatar(AgentId, out avatar)) 6016 if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
5950 { 6017 {
5951 if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f) 6018 if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
5952 { 6019 {
@@ -6989,6 +7056,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6989 return true; 7056 return true;
6990 } 7057 }
6991 7058
7059 /// <summary>
7060 /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
7061 /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
7062 /// </summary>
7063 /// <param name="sender"></param>
7064 /// <param name="Pack"></param>
7065 /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
6992 private bool HandleTransferRequest(IClientAPI sender, Packet Pack) 7066 private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
6993 { 7067 {
6994 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); 7068 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
@@ -6999,37 +7073,95 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6999 // Has to be done here, because AssetCache can't do it 7073 // Has to be done here, because AssetCache can't do it
7000 // 7074 //
7001 UUID taskID = UUID.Zero; 7075 UUID taskID = UUID.Zero;
7002 if (transfer.TransferInfo.SourceType == 3) 7076 if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
7003 { 7077 {
7004 taskID = new UUID(transfer.TransferInfo.Params, 48); 7078 taskID = new UUID(transfer.TransferInfo.Params, 48);
7005 UUID itemID = new UUID(transfer.TransferInfo.Params, 64); 7079 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
7006 UUID requestID = new UUID(transfer.TransferInfo.Params, 80); 7080 UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
7081
7082// m_log.DebugFormat(
7083// "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
7084// requestID, itemID, taskID, Name);
7085
7007 if (!(((Scene)m_scene).Permissions.BypassPermissions())) 7086 if (!(((Scene)m_scene).Permissions.BypassPermissions()))
7008 { 7087 {
7009 if (taskID != UUID.Zero) // Prim 7088 if (taskID != UUID.Zero) // Prim
7010 { 7089 {
7011 SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID); 7090 SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
7091
7012 if (part == null) 7092 if (part == null)
7093 {
7094 m_log.WarnFormat(
7095 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
7096 Name, requestID, itemID, taskID);
7013 return true; 7097 return true;
7098 }
7014 7099
7015 if (part.OwnerID != AgentId) 7100 TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
7016 return true; 7101 if (tii == null)
7017 7102 {
7018 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) 7103 m_log.WarnFormat(
7019 return true; 7104 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
7020 7105 Name, requestID, itemID, taskID);
7021 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
7022 if (ti == null)
7023 return true;
7024
7025 if (ti.OwnerID != AgentId)
7026 return true;
7027
7028 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
7029 return true;
7030
7031 if (ti.AssetID != requestID)
7032 return true; 7106 return true;
7107 }
7108
7109 if (tii.Type == (int)AssetType.LSLText)
7110 {
7111 if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
7112 return true;
7113 }
7114 else if (tii.Type == (int)AssetType.Notecard)
7115 {
7116 if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
7117 return true;
7118 }
7119 else
7120 {
7121 // TODO: Change this code to allow items other than notecards and scripts to be successfully
7122 // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
7123 if (part.OwnerID != AgentId)
7124 {
7125 m_log.WarnFormat(
7126 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
7127 Name, requestID, itemID, taskID, part.OwnerID);
7128 return true;
7129 }
7130
7131 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
7132 {
7133 m_log.WarnFormat(
7134 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
7135 Name, requestID, itemID, taskID);
7136 return true;
7137 }
7138
7139 if (tii.OwnerID != AgentId)
7140 {
7141 m_log.WarnFormat(
7142 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
7143 Name, requestID, itemID, taskID, tii.OwnerID);
7144 return true;
7145 }
7146
7147 if ((
7148 tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
7149 != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
7150 {
7151 m_log.WarnFormat(
7152 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
7153 Name, requestID, itemID, taskID);
7154 return true;
7155 }
7156
7157 if (tii.AssetID != requestID)
7158 {
7159 m_log.WarnFormat(
7160 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
7161 Name, requestID, itemID, taskID, tii.AssetID);
7162 return true;
7163 }
7164 }
7033 } 7165 }
7034 else // Agent 7166 else // Agent
7035 { 7167 {
@@ -7038,7 +7170,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7038 assetRequestItem = invService.GetItem(assetRequestItem); 7170 assetRequestItem = invService.GetItem(assetRequestItem);
7039 if (assetRequestItem == null) 7171 if (assetRequestItem == null)
7040 { 7172 {
7041 assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 7173 ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
7174 if (lib != null)
7175 assetRequestItem = lib.LibraryRootFolder.FindItem(itemID);
7042 if (assetRequestItem == null) 7176 if (assetRequestItem == null)
7043 return true; 7177 return true;
7044 } 7178 }
@@ -7047,7 +7181,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7047 // only to notecards and scripts. All 7181 // only to notecards and scripts. All
7048 // other asset types are always available 7182 // other asset types are always available
7049 // 7183 //
7050 if (assetRequestItem.AssetType == 10) 7184 if (assetRequestItem.AssetType == (int)AssetType.LSLText)
7051 { 7185 {
7052 if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId)) 7186 if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId))
7053 { 7187 {
@@ -7055,7 +7189,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7055 return true; 7189 return true;
7056 } 7190 }
7057 } 7191 }
7058 else if (assetRequestItem.AssetType == 7) 7192 else if (assetRequestItem.AssetType == (int)AssetType.Notecard)
7059 { 7193 {
7060 if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId)) 7194 if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId))
7061 { 7195 {
@@ -7065,7 +7199,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7065 } 7199 }
7066 7200
7067 if (assetRequestItem.AssetID != requestID) 7201 if (assetRequestItem.AssetID != requestID)
7202 {
7203 m_log.WarnFormat(
7204 "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}",
7205 Name, requestID, itemID, assetRequestItem.AssetID);
7068 return true; 7206 return true;
7207 }
7069 } 7208 }
7070 } 7209 }
7071 } 7210 }
@@ -7268,6 +7407,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7268 return true; 7407 return true;
7269 } 7408 }
7270 7409
7410 private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
7411 {
7412 LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
7413
7414 #region Packet Session and User Check
7415 if (m_checkPackets)
7416 {
7417 if (createLink.AgentData.SessionID != SessionId ||
7418 createLink.AgentData.AgentID != AgentId)
7419 return true;
7420 }
7421 #endregion
7422
7423 LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
7424
7425 if (linkInventoryItem != null)
7426 {
7427 linkInventoryItem(
7428 this,
7429 createLink.InventoryBlock.TransactionID,
7430 createLink.InventoryBlock.FolderID,
7431 createLink.InventoryBlock.CallbackID,
7432 Util.FieldToString(createLink.InventoryBlock.Description),
7433 Util.FieldToString(createLink.InventoryBlock.Name),
7434 createLink.InventoryBlock.InvType,
7435 createLink.InventoryBlock.Type,
7436 createLink.InventoryBlock.OldItemID);
7437 }
7438
7439 return true;
7440 }
7441
7271 private bool HandleFetchInventory(IClientAPI sender, Packet Pack) 7442 private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
7272 { 7443 {
7273 if (OnFetchInventory != null) 7444 if (OnFetchInventory != null)
@@ -7612,12 +7783,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7612 newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask; 7783 newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
7613 newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask; 7784 newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
7614 newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask; 7785 newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
7786
7787 // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
7788 // different
7615 //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned; 7789 //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
7616 newTaskItem.Type = updatetask.InventoryData.Type; 7790 newTaskItem.Type = updatetask.InventoryData.Type;
7617 newTaskItem.InvType = updatetask.InventoryData.InvType; 7791 newTaskItem.InvType = updatetask.InventoryData.InvType;
7618 newTaskItem.Flags = updatetask.InventoryData.Flags; 7792 newTaskItem.Flags = updatetask.InventoryData.Flags;
7619 //newTaskItem.SaleType=updatetask.InventoryData.SaleType; 7793 //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
7620 //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;; 7794 //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
7621 newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name); 7795 newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
7622 newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description); 7796 newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
7623 newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate; 7797 newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
@@ -7625,7 +7799,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7625 newTaskItem, updatetask.UpdateData.LocalID); 7799 newTaskItem, updatetask.UpdateData.LocalID);
7626 } 7800 }
7627 } 7801 }
7628 } 7802 }
7629 7803
7630 return true; 7804 return true;
7631 } 7805 }
@@ -10928,7 +11102,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10928 LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length); 11102 LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
10929 #endregion BinaryStats 11103 #endregion BinaryStats
10930 11104
10931 m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); 11105 OutPacket(packet, throttlePacketType, true);
10932 } 11106 }
10933 11107
10934 /// <summary> 11108 /// <summary>
@@ -10941,6 +11115,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10941 /// handles splitting manually</param> 11115 /// handles splitting manually</param>
10942 protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting) 11116 protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
10943 { 11117 {
11118 if (m_debugPacketLevel >= 255)
11119 m_log.DebugFormat("[CLIENT]: Packet OUT {0}", packet.Type);
11120
10944 m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting); 11121 m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting);
10945 } 11122 }
10946 11123
@@ -11012,10 +11189,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11012 /// <param name="Pack">OpenMetaverse.packet</param> 11189 /// <param name="Pack">OpenMetaverse.packet</param>
11013 public void ProcessInPacket(Packet Pack) 11190 public void ProcessInPacket(Packet Pack)
11014 { 11191 {
11015// m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack); 11192 if (m_debugPacketLevel >= 255)
11016 11193 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type);
11194
11017 if (!ProcessPacketMethod(Pack)) 11195 if (!ProcessPacketMethod(Pack))
11018 m_log.Warn("[CLIENT]: unhandled packet " + Pack); 11196 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type);
11019 11197
11020 PacketPool.Instance.ReturnPacket(Pack); 11198 PacketPool.Instance.ReturnPacket(Pack);
11021 } 11199 }
@@ -11235,17 +11413,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11235 return String.Empty; 11413 return String.Empty;
11236 } 11414 }
11237 11415
11238 public void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID) 11416 /// <summary>
11417 /// Make an asset request to the asset service in response to a client request.
11418 /// </summary>
11419 /// <param name="transferRequest"></param>
11420 /// <param name="taskID"></param>
11421 protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
11239 { 11422 {
11240 UUID requestID = UUID.Zero; 11423 UUID requestID = UUID.Zero;
11241 if (transferRequest.TransferInfo.SourceType == 2) 11424 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
11242 { 11425 {
11243 //direct asset request
11244 requestID = new UUID(transferRequest.TransferInfo.Params, 0); 11426 requestID = new UUID(transferRequest.TransferInfo.Params, 0);
11245 } 11427 }
11246 else if (transferRequest.TransferInfo.SourceType == 3) 11428 else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11247 { 11429 {
11248 //inventory asset request
11249 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 11430 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
11250 //m_log.Debug("[XXX] inventory asset request " + requestID); 11431 //m_log.Debug("[XXX] inventory asset request " + requestID);
11251 //if (taskID == UUID.Zero) // Agent 11432 //if (taskID == UUID.Zero) // Agent
@@ -11258,29 +11439,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11258 // } 11439 // }
11259 } 11440 }
11260 11441
11261 //check to see if asset is in local cache, if not we need to request it from asset server. 11442// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
11262 //m_log.Debug("asset request " + requestID);
11263 11443
11264 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 11444 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
11265
11266 } 11445 }
11267 11446
11447 /// <summary>
11448 /// When we get a reply back from the asset service in response to a client request, send back the data.
11449 /// </summary>
11450 /// <param name="id"></param>
11451 /// <param name="sender"></param>
11452 /// <param name="asset"></param>
11268 protected void AssetReceived(string id, Object sender, AssetBase asset) 11453 protected void AssetReceived(string id, Object sender, AssetBase asset)
11269 { 11454 {
11270 TransferRequestPacket transferRequest = (TransferRequestPacket)sender; 11455 TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
11271 11456
11272 UUID requestID = UUID.Zero; 11457 UUID requestID = UUID.Zero;
11273 byte source = 2; 11458 byte source = (byte)SourceType.Asset;
11274 if ((transferRequest.TransferInfo.SourceType == 2) || (transferRequest.TransferInfo.SourceType == 2222)) 11459
11460 if ((transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
11461 || (transferRequest.TransferInfo.SourceType == 2222))
11275 { 11462 {
11276 //direct asset request
11277 requestID = new UUID(transferRequest.TransferInfo.Params, 0); 11463 requestID = new UUID(transferRequest.TransferInfo.Params, 0);
11278 } 11464 }
11279 else if ((transferRequest.TransferInfo.SourceType == 3) || (transferRequest.TransferInfo.SourceType == 3333)) 11465 else if ((transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11466 || (transferRequest.TransferInfo.SourceType == 3333))
11280 { 11467 {
11281 //inventory asset request
11282 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 11468 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
11283 source = 3; 11469 source = (byte)SourceType.SimInventoryItem;
11284 //m_log.Debug("asset request " + requestID); 11470 //m_log.Debug("asset request " + requestID);
11285 } 11471 }
11286 11472
@@ -11293,9 +11479,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11293 if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer())) 11479 if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer()))
11294 { 11480 {
11295 m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id); 11481 m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id);
11296 if (transferRequest.TransferInfo.SourceType == 2) 11482 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
11297 transferRequest.TransferInfo.SourceType = 2222; // marker 11483 transferRequest.TransferInfo.SourceType = 2222; // marker
11298 else if (transferRequest.TransferInfo.SourceType == 3) 11484 else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11299 transferRequest.TransferInfo.SourceType = 3333; // marker 11485 transferRequest.TransferInfo.SourceType = 3333; // marker
11300 11486
11301 m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived); 11487 m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived);
@@ -11310,7 +11496,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11310 } 11496 }
11311 11497
11312 // Scripts cannot be retrieved by direct request 11498 // Scripts cannot be retrieved by direct request
11313 if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) 11499 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
11314 return; 11500 return;
11315 11501
11316 // The asset is known to exist and is in our cache, so add it to the AssetRequests list 11502 // The asset is known to exist and is in our cache, so add it to the AssetRequests list
@@ -11336,6 +11522,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11336 const uint m_maxPacketSize = 600; 11522 const uint m_maxPacketSize = 600;
11337 int numPackets = 1; 11523 int numPackets = 1;
11338 11524
11525 if (data == null)
11526 return 0;
11527
11339 if (data.LongLength > m_maxPacketSize) 11528 if (data.LongLength > m_maxPacketSize)
11340 { 11529 {
11341 // over max number of bytes so split up file 11530 // over max number of bytes so split up file
@@ -11540,6 +11729,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11540 public PacketMethod method; 11729 public PacketMethod method;
11541 public bool Async; 11730 public bool Async;
11542 } 11731 }
11732
11543 public class AsyncPacketProcess 11733 public class AsyncPacketProcess
11544 { 11734 {
11545 public bool result = false; 11735 public bool result = false;
@@ -11581,5 +11771,40 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11581 packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages); 11771 packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
11582 OutPacket(packet, ThrottleOutPacketType.Task); 11772 OutPacket(packet, ThrottleOutPacketType.Task);
11583 } 11773 }
11774
11775 public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
11776 {
11777 ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
11778
11779 packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
11780 packet.AgentData.AgentID = agentID;
11781
11782 packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
11783 packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
11784 packet.Rights[0].AgentRelated = friendID;
11785 packet.Rights[0].RelatedRights = rights;
11786
11787 OutPacket(packet, ThrottleOutPacketType.Task);
11788 }
11789
11790 public void SendTextBoxRequest(string message, int chatChannel, string objectname, string ownerFirstName, string ownerLastName, UUID objectId)
11791 {
11792 ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
11793 dialog.Data.ObjectID = objectId;
11794 dialog.Data.ChatChannel = chatChannel;
11795 dialog.Data.ImageID = UUID.Zero;
11796 dialog.Data.ObjectName = Util.StringToBytes256(objectname);
11797 // this is the username of the *owner*
11798 dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
11799 dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
11800 dialog.Data.Message = Util.StringToBytes256(message);
11801
11802
11803 ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
11804 buttons[0] = new ScriptDialogPacket.ButtonsBlock();
11805 buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
11806 dialog.Buttons = buttons;
11807 OutPacket(dialog, ThrottleOutPacketType.Task);
11808 }
11584 } 11809 }
11585} 11810} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
index adf171e..10e5a95 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
@@ -197,7 +197,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
197 197
198 private void Initialise(UUID fileID, string fileName) 198 private void Initialise(UUID fileID, string fileName)
199 { 199 {
200 m_asset = new AssetBase(fileID, fileName, type); 200 m_asset = new AssetBase(fileID, fileName, type, UUID.Zero.ToString());
201 m_asset.Data = new byte[0]; 201 m_asset.Data = new byte[0];
202 m_asset.Description = "empty"; 202 m_asset.Description = "empty";
203 m_asset.Local = true; 203 m_asset.Local = true;
@@ -212,6 +212,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
212 212
213 public void RequestStartXfer(IClientAPI pRemoteClient) 213 public void RequestStartXfer(IClientAPI pRemoteClient)
214 { 214 {
215 m_asset.Metadata.CreatorID = pRemoteClient.AgentId.ToString();
216
215 if (!String.IsNullOrEmpty(m_asset.Name)) 217 if (!String.IsNullOrEmpty(m_asset.Name))
216 { 218 {
217 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name)); 219 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name));
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index 55d9c9c..6232c48 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -144,6 +144,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
144 /// <summary>A reference to the LLUDPServer that is managing this client</summary> 144 /// <summary>A reference to the LLUDPServer that is managing this client</summary>
145 private readonly LLUDPServer m_udpServer; 145 private readonly LLUDPServer m_udpServer;
146 146
147 /// <summary>Caches packed throttle information</summary>
148 private byte[] m_packedThrottles;
149
147 private int m_defaultRTO = 3000; 150 private int m_defaultRTO = 3000;
148 private int m_maxRTO = 60000; 151 private int m_maxRTO = 60000;
149 152
@@ -350,21 +353,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
350 bucket = m_throttleCategories[(int)ThrottleOutPacketType.Texture]; 353 bucket = m_throttleCategories[(int)ThrottleOutPacketType.Texture];
351 bucket.DripRate = texture; 354 bucket.DripRate = texture;
352 bucket.MaxBurst = texture; 355 bucket.MaxBurst = texture;
356
357 // Reset the packed throttles cached data
358 m_packedThrottles = null;
353 } 359 }
354 360
355 public byte[] GetThrottlesPacked() 361 public byte[] GetThrottlesPacked()
356 { 362 {
357 byte[] data = new byte[7 * 4]; 363 byte[] data = m_packedThrottles;
358 int i = 0; 364
359 365 if (data == null)
360 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Resend].DripRate), 0, data, i, 4); i += 4; 366 {
361 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Land].DripRate), 0, data, i, 4); i += 4; 367 data = new byte[7 * 4];
362 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate), 0, data, i, 4); i += 4; 368 int i = 0;
363 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate), 0, data, i, 4); i += 4; 369
364 Buffer.BlockCopy(Utils.FloatToBytes((float)(m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate) + 370 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Resend].DripRate), 0, data, i, 4); i += 4;
365 m_throttleCategories[(int)ThrottleOutPacketType.State].DripRate), 0, data, i, 4); i += 4; 371 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Land].DripRate), 0, data, i, 4); i += 4;
366 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate), 0, data, i, 4); i += 4; 372 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate), 0, data, i, 4); i += 4;
367 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate), 0, data, i, 4); i += 4; 373 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate), 0, data, i, 4); i += 4;
374 Buffer.BlockCopy(Utils.FloatToBytes((float)(m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate) +
375 m_throttleCategories[(int)ThrottleOutPacketType.State].DripRate), 0, data, i, 4); i += 4;
376 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate), 0, data, i, 4); i += 4;
377 Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate), 0, data, i, 4); i += 4;
378
379 m_packedThrottles = data;
380 }
368 381
369 return data; 382 return data;
370 } 383 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 3c4fa72..41e41e4 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -513,6 +513,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
513 byte flags = buffer.Data[0]; 513 byte flags = buffer.Data[0];
514 bool isResend = (flags & Helpers.MSG_RESENT) != 0; 514 bool isResend = (flags & Helpers.MSG_RESENT) != 0;
515 bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; 515 bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;
516 bool isZerocoded = (flags & Helpers.MSG_ZEROCODED) != 0;
516 LLUDPClient udpClient = outgoingPacket.Client; 517 LLUDPClient udpClient = outgoingPacket.Client;
517 518
518 if (!udpClient.IsConnected) 519 if (!udpClient.IsConnected)
@@ -522,23 +523,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
522 523
523 int dataLength = buffer.DataLength; 524 int dataLength = buffer.DataLength;
524 525
525 // Keep appending ACKs until there is no room left in the buffer or there are 526 // NOTE: I'm seeing problems with some viewers when ACKs are appended to zerocoded packets so I've disabled that here
526 // no more ACKs to append 527 if (!isZerocoded)
527 uint ackCount = 0;
528 uint ack;
529 while (dataLength + 5 < buffer.Data.Length && udpClient.PendingAcks.Dequeue(out ack))
530 { 528 {
531 Utils.UIntToBytesBig(ack, buffer.Data, dataLength); 529 // Keep appending ACKs until there is no room left in the buffer or there are
532 dataLength += 4; 530 // no more ACKs to append
533 ++ackCount; 531 uint ackCount = 0;
534 } 532 uint ack;
533 while (dataLength + 5 < buffer.Data.Length && udpClient.PendingAcks.Dequeue(out ack))
534 {
535 Utils.UIntToBytesBig(ack, buffer.Data, dataLength);
536 dataLength += 4;
537 ++ackCount;
538 }
535 539
536 if (ackCount > 0) 540 if (ackCount > 0)
537 { 541 {
538 // Set the last byte of the packet equal to the number of appended ACKs 542 // Set the last byte of the packet equal to the number of appended ACKs
539 buffer.Data[dataLength++] = (byte)ackCount; 543 buffer.Data[dataLength++] = (byte)ackCount;
540 // Set the appended ACKs flag on this packet 544 // Set the appended ACKs flag on this packet
541 buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS); 545 buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS);
546 }
542 } 547 }
543 548
544 buffer.DataLength = dataLength; 549 buffer.DataLength = dataLength;
@@ -596,15 +601,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
596 } 601 }
597 catch (MalformedDataException) 602 catch (MalformedDataException)
598 { 603 {
599 m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse packet from {0}:\n{1}",
600 buffer.RemoteEndPoint, Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
601 } 604 }
602 605
603 // Fail-safe check 606 // Fail-safe check
604 if (packet == null) 607 if (packet == null)
605 { 608 {
606 m_log.Warn("[LLUDPSERVER]: Couldn't build a message from incoming data " + buffer.DataLength + 609 m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse {0} byte packet from {1}:",
607 " bytes long from " + buffer.RemoteEndPoint); 610 buffer.DataLength, buffer.RemoteEndPoint);
611 m_log.Error(Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
608 return; 612 return;
609 } 613 }
610 614
@@ -919,7 +923,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
919 // Remove this client from the scene 923 // Remove this client from the scene
920 IClientAPI client; 924 IClientAPI client;
921 if (m_scene.TryGetClient(udpClient.AgentID, out client)) 925 if (m_scene.TryGetClient(udpClient.AgentID, out client))
926 {
927 client.IsLoggingOut = true;
922 client.Close(); 928 client.Close();
929 }
923 } 930 }
924 931
925 private void IncomingPacketHandler() 932 private void IncomingPacketHandler()
@@ -1018,7 +1025,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1018 1025
1019 // Handle outgoing packets, resends, acknowledgements, and pings for each 1026 // Handle outgoing packets, resends, acknowledgements, and pings for each
1020 // client. m_packetSent will be set to true if a packet is sent 1027 // client. m_packetSent will be set to true if a packet is sent
1021 m_scene.ForEachClient(clientPacketHandler, false); 1028 m_scene.ForEachClient(clientPacketHandler);
1022 1029
1023 // If nothing was sent, sleep for the minimum amount of time before a 1030 // If nothing was sent, sleep for the minimum amount of time before a
1024 // token bucket could get more tokens 1031 // token bucket could get more tokens
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index c7aeca14..e683821 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -56,13 +56,6 @@ namespace OpenSim.Region.ClientStack
56 56
57 protected uint m_httpServerPort; 57 protected uint m_httpServerPort;
58 58
59 public CommunicationsManager CommunicationsManager
60 {
61 get { return m_commsManager; }
62 set { m_commsManager = value; }
63 }
64 protected CommunicationsManager m_commsManager;
65
66 protected StorageManager m_storageManager; 59 protected StorageManager m_storageManager;
67 60
68 protected ClientStackManager m_clientStackManager; 61 protected ClientStackManager m_clientStackManager;
@@ -105,12 +98,14 @@ namespace OpenSim.Region.ClientStack
105 98
106 if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort)) 99 if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort))
107 { 100 {
108 m_log.Error("[HTTP]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); 101 m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports");
109 } 102 }
110 103
111 m_log.Info("[REGION]: Starting HTTP server"); 104 m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort);
112 m_httpServer.Start(); 105 m_httpServer.Start();
113 106
107 MainServer.Instance = m_httpServer;
108
114 base.StartupSpecific(); 109 base.StartupSpecific();
115 } 110 }
116 111
@@ -134,4 +129,4 @@ namespace OpenSim.Region.ClientStack
134 return physicsPluginManager.GetPhysicsScene(engine, meshEngine, config, osSceneIdentifier); 129 return physicsPluginManager.GetPhysicsScene(engine, meshEngine, config, osSceneIdentifier);
135 } 130 }
136 } 131 }
137} 132} \ No newline at end of file