Help Required With A Packet

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 096.
Note: Core 096 is no longer officially supported.

Moderator: POL Developer

Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Help Required With A Packet

Post by Steve »

Hi,

I'm new here so bare with me...
I'm trying to figure out the packet sequence required to send to POL type servers in order to get player count information back.

The one packet sequence i'm aware of, and works is the following...

Send...
\x7f\x00\x00\x01\xf1\x00\x04\xff

Returns...
RunUO, Name='x', Age='x', Clients='x', Items='x', Chars='x', Mem='x'

What i'd like to do is be able to return server information in the same manner for POL servers...

Send...
\x??\x?? etc etc ???
Returns...
whatever, mainly Clients='x'

This is to enable http://www.listuo.com to support POL shards as well as RunUO servers. This is a new site which is still in a very early stage of design etc etc, but i'd like to be able to support POL servers as well.

I've read as much as i can regarding POL servers & packets but i can't seem to find the answers i'm looking for.

Any help would be appriciated greatly,

Steve.
Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Re: Help Required With A Packet

Post by Steve »

Still looking for this information.

Shameless bump of an old post but i'm still searching for an answer to this problem.

The site which i run now has sphere shards listed there too and seems that these type shards are giving the required information needed for the web page of servers to be displayed correctly. The process works with the above packet, the data recieved comes back in a slightly different format (a string) but able to give a client count with it.

I'd still like to get POL type shards working with the site since theres now a POL shard listed there.

I'm working to re-write some of the checking app to allow for the POL type servers but i'm only able to display online or offline states, additional shard information to the site would be better, if anyone can help i'd appriciate it, thanks.
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

By default, I don't believe POL actually does respond at all the way you're looking for. But packets are scriptable in POL so this can be solved very easily by installing a small packethook package. Basically the info needed is what exact packet do you send or want to send to POL, what does each byte of the packet mean, and what exact packet do you want sent back?
Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Re: Help Required With A Packet

Post by Steve »

The shard checking application that ListUO uses opens a socket to server and sends the following...

Send...
\x7f\x00\x00\x01\xf1\x00\x04\xff

Socket s = ConnectSocket(server, port);
Byte[] UOG = { 127, 0, 0, 1, 241, 0, 4, 255 };
s.Send(UOG);

I currently have one Sphere type shard registered with the site which seems to respond to this packet thats sent, although the response is slightly different i'm able to strip out the client count in much the same way as a RunUO shard type does, the RunUO response & Sphere response are strings...

RunUO, Name=AOG Reborn, Age=0, Clients=4, Items=157349, Chars=27079, Mem=118870K
Sphere Items=44587, Mobiles=4159, Clients=5, Mem=220092

Each packet element thats sent can be checked against packet details (dont have them off hand) for POL shards here in a packet post i've seen, basically i'd like to know how to go about making a script for POL shards which can handle something like this, i could then provide the additional script POL users would need avaliable as a download from the ListUO site purley for POL users wishing to register there.

The only problem i have at the moment is i've never used or scripted for POL shards, any additional info or help would be great.

* EDIT *
I've looked for the first byte in the sequence x7f or 127... it seems this particular byte is not defined as a start point for packet communications (undefined), probably why it's been used for this task perhaps ?
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

Steve wrote:* EDIT *
I've looked for the first byte in the sequence x7f or 127... it seems this particular byte is not defined as a start point for packet communications (undefined), probably why it's been used for this task perhaps ?
That's exactly why so it doesn't conflict with a packet that the client is using and get a response that it doesn't know anything about (It'll either freeze or crash the client).

So basically if you send

\x7F\x00\x00\x01\xF1\x00\x04\xFF

you might want to receive

POL, Clients=x

it'll likely be sent back in this format
\x7F\x00\x12\x50\x4F\x4C\x2C\x20\x43\x6C\x69\x65\x6E\x74\x73\x3D\x00\x01

the breakdown:
first byte = 0x7F - The command
next 2 bytes = 16 bit integer for the size of the packet
Next 13 bytes = String for the server and clients - "POL, Clients="
Next 2 bytes = 16 bit integer for the number of players online (in the case of the return I displayed above, 1 person online)
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

Here it is. A total of 3 files. All files have to be in the same folder with eachother, they must retain the names that I have posted, and they have to reside somewhere within POL/Pkg (default) or whatever the shard has set as their package path.

This code is completely untested...

pkg.cfg

Code: Select all

Enabled 1
Maintainer Steve and CWO (http://www.listuo.com, http://forums.polserver.com)
Name ListUOHook
Version 1.0
uopacket.cfg

Code: Select all

Packet 0x7F
{
    Length variable
    ReceiveFunction listuo:ListUORecv
}
listuo.src

Code: Select all

use os;
use polsys;
use uo;

program ListUO()
	Print("Installing ListUO packet...");                        //Announce install
	return 1;                                                    //Install packet
endprogram

exported function ListUORecv(who, byref packet)
	packet.SetSize(18);                                          // Set the size of the packet
	packet.SetString(3, "POL, Clients=");                        // Insert POL, Clients= string
	var chars := CInt(EnumerateOnlineCharacters());              // Enumerate Online Characters
	packet.SetInt16(16, chars)                                   // Insert number of online players
	packet.SendPacket(who);                                      // Send packet
	Print("Sent info to ListUO. " + CStr(chars) + "  online.");  // Announce success
	return 1;                                                    // Hide packet from POL to avoid errors.
endfunction
Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Re: Help Required With A Packet

Post by Steve »

Thanks for the help with this/scripts, i'll try to get it tested today and let you know if i encounter any problems with it if i can contact the owner of the POL shard and ask if he/she can install those 3 scripts for me... failing that i'll attempt to setup a local POL server for testing purposes.
Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Re: Help Required With A Packet

Post by Steve »

Installed the latest distro's for the POL server and got it running ok. Connected and moved round etc etc.

Created those 3 files and added but hitting an error regarding ECL file types ?

I've created a folder called listuopacket, with sub folders to the same standards from what i can tell in the PKG folders to include the 3 files added above.

Going to research some of the details regarding ECL files to try and find where the problem is with this.

http://www.listuo.com/graphics/listuopacket.jpg
Nando
POL Developer
Posts: 282
Joined: Wed Sep 17, 2008 6:53 pm
Contact:

Re: Help Required With A Packet

Post by Nando »

Please run 'ecompile' to generate the ecl files, and make sure the path is right. :)

If you're unsure about running ecompile, just use StartHere.bat's option for ecompile ('b', I think) and then 'd', "Compile All Scripts...".
Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Re: Help Required With A Packet

Post by Steve »

Yeah, finally sussed that part out now.

I've had to remark most of this script out to get it to compile, maybe a syntax problem i think...

listuo.src

Code: Select all

use os;
use polsys;
use uo;

program listUO()
   Print("INSTALLING: ListUO packet...");                        //Announce install
   return 1;                                                    //Install packet
endprogram

exported function ListUORecv(who, byref packet)
   // packet.SetSize(18);                                          // Set the size of the packet
   // packet.SetString(3, "POL, Clients=");                        // Insert POL, Clients= string
   // var chars := CInt(EnumerateOnlineCharacters());              // Enumerate Online Characters
   // packet.SetInt16(16, chars)                                   // Insert number of online players
   // packet.SendPacket(who);                                      // Send packet
   // Print("Sent info to ListUO. " + CStr(chars) + "  online.");  // Announce success
   Print("Sent ListUO Info.");
   return 1;                                                    // Hide packet from POL to avoid errors.
endfunction
Problem i'm still having here tho is now i'm getting a message... 'sent non-allowed message type f1'

http://www.listuo.com/graphics/polpacket2.jpg

At the moment i'm just trying to get it to print the sent message in the server console to verify the packets triggering the ListUORecv function... no luck so far tho, there again it's my first 4 hours scripting POL :?
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: Help Required With A Packet

Post by Pierce »

There is already a packet 0xF1 defined for UOG and CUO.

http://forums.polserver.com/viewtopic.php?f=9&t=1518

I don't know if MuadDib already added that to the newer cores,
because i can't find a note about that inside the core changes.
But if you get this error, it seems the core reacts on the last 4 bytes
of your packet like described in the packet list:

F1 00 04 FF

So perhaps it's better to hook packet F1 not 7F.
Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Re: Help Required With A Packet

Post by Steve »

I've tried both ways... 1st 4 bytes sent and 2nd 4 bytes sent in seperate attempts... no luck so far.

I could side step it and just show if a POL shards online or offline, although not quite what i wanted.

Don't know enough about the syntax of the script language POL uses either really, which is where i might hit more problems later.

I still need to re-write the checking tool too in order to take into account the POL server i have listed, this is doing my head in today after spending a few hours researching it all... fingers crossed tho.

*EDIT*
I've also tried hooking both 0x7F and 0xF1 with no result, begining to wonder if the other parts/files might have problems i can't see.
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

Steve wrote: I've had to remark most of this script out to get it to compile, maybe a syntax problem i think...
oops sorry...

This time I tested compiling and it does compile.

Code: Select all

use os;
use polsys;
use uo;

program ListUO()
	Print("Installing ListUO packet...");                            //Announce install
	return 1;                                                        //Install packet
endprogram

exported function ListUORecv(who, byref packet)
	packet.SetSize(18);                                              // Set the size of the packet
	packet.SetString(3, "POL, Clients=");                            // Insert POL, Clients= string
	var chars := CInt(EnumerateOnlineCharacters().size());           // Enumerate Online Characters
	packet.SetInt16(16, chars);                                      // Insert number of online players
	packet.SendPacket(who);                                          // Send packet
	Print("Sent info to ListUO. " + CStr(chars) + "  online.");      // Announce success
	return 1;                                                        // Hide packet from POL to avoid errors.
endfunction
also, if you hook 0xF1 and send it, it will send back with 0xF1 instead of 0x7F as the first byte. I take the original packet that is sent and change everything but that first byte and bounce it back. I tested this by hooking a different packet to this that I can control (the guild button) and it worked. So I've tested it as far as I could without having your program itself connecting to it.

Just for the heck of it, if you're going to stick with 0x7F, try changing the packet to

\x7F\x00\x08\x01\xF1\x00\x04\xFF

just to see if POL doesn't throw it out due to it believing its 0 in length. (POL takes bytes 2 and 3 as the length in variable length packets)

Next, are you getting "Installing ListUO packet..." on startup when the packethooks load? This will tell me if the script is running.

I can almost wonder if packet.SendPacket(who); would work without having a full char reference but I thought this was how I got my shard to respond to UOGateway...

We should try everything possible to get this to work before going to the alternative. POL does support another way to communicate but its not as recommended since it requires shards to open another port to listen on and you'll have to configure your program to communicate on this alternate port instead. What I'm talking about is an AUX connection on POL. It causes some drawbacks and is less transparent but it is actually compatible with older versions of POL and I do guarantee it will work.
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

Wait... I think I just found the problem...

Steve did you send

\x7F\x00\x08\x01\xF1\x00\x04\xFF

and get that non-allowed message F1 from POL?

I was actually testing to see if I can get it to work using mIRC since its the only outside program I really script for that can do something similar to what you're doing and I figured out that POL somehow ignores the first 4 bytes of what I sent. If I padded the first 4 bytes with 0's then put the actual packet starting at the 5th byte, it figures out what I'm saying. I'm kinda wondering if this is how UO communicates because I even had to send the login packet (0x80) that way in order to get POL to respond correctly with the login failed message... Other than that, I have NO idea why its doing this.

Now for the kicker... it seems POL doesn't even allow 7F OR F1 to be hooked because they're "non-allowed" :x
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

OK I pulled basically an all-nighter testing this with mIRC as my program connection with POL.

What I've figured out is that POL ONLY seems to accept the login packet for a client that isn't logged in. This means we're forced to use 0x80 (which is what UOGateway used in the past). And the only way to get a reply is the Login failed packet (which is also what UOGateway used). So I've basically recreated the UOGateway packethook. Here it is...

First, you have to keep pkg.cfg exactly as is.

Delete uopacket.cfg and listuo.src (and the files that resulted from compiling)

here are the new uopacket.cfg and listuo.src files

uopacket.cfg

Code: Select all

Packet 0x80
{
  Length 62
  ReceiveFunction listuo:AcctLogin
}

Packet 0x82
{
  Length variable
  SendFunction listuo:LoginFailed
}
listuo.src

Code: Select all

exported function LoginFailed(who, byref packet)
	if (GetGlobalProperty("#ListUOReturn"))
		EraseGlobalProperty("#ListUOReturn");
		var online := CInt(EnumerateOnlineCharacters().size());
		Print("Reply to ListUO: " + online + " characters online.");
		packet.setsize(3);
		packet.setint16(1, online);
	endif
	return 0;
endfunction

exported function AcctLogin(char, byref packet)
	if ((packet.getint16(1)==65280))
		SetGlobalProperty("#ListUOReturn", 1);
		return 0;
	endif
endfunction
What your program should send:
{ 0, 0, 0, 0, 128, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

yes its preceded by 4 0's to pad for what POL ignores, followed by 128 (0x80 - Account login), 255 (first character of the username) and ended with 60 0's (the rest of the username and a null password). The packet MUST be 66 in length total or else POL will ignore it.

You'll get back
{130, ??, ??}

the ??, ?? is a 16 bit integer for the number of players online. Hopefully this is all you'll need to get it supported.

What literally is happening is you're logging in with a username and password that can't possibly exist in POL and getting the login failed message back with a bit of a modification to it.
Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Re: Help Required With A Packet

Post by Steve »

So far...

I've tried the new uopacket.cfg and also the listuo.src files you've posted, left pkg.cfg the same from the begining. The Ecompiler works, the shard would not start up with out the following in the listuo.src file at the top...

Code: Select all

use os;
use polsys;
use uo;
Next problem after installing this new set of files was unable to login at all with a current account on the server... stuck at login screen, tried sending the original packet anyway ( \x7F\x00\x00\x01\xF1\x00\x04\xFF ) to no avail.
Next, are you getting "Installing ListUO packet..." on startup when the packethooks load? This will tell me if the script is running.
Prior to the new set of files yes it was installing correctly, most of the original setup i remarked out as a temp measure just to try and get the Print("work godamit text"); to work >_< but... no luck. Changed the uopacket.cfg from 0x7F to 0xF1 to try and hook that instead and tried mulitiple times sending the first 1/2 and second half of the original 8 bytes just to check what was happening... no luck, no matter what i tried to send nothing made the src file code trigger the Print statment, making me think the defined functions just not getting the trigger correctly to run it at all.

The nearest i've managed to get is with the original script file, uopacket.cfg setup to hook the 0x7F sequence seemed more stable, allowing me to still allow characters to login on a testing account i've setup. Downside to this approach is the messages i get regarding 0xF1 not being allowed and being undefined.
Just for the heck of it, if you're going to stick with 0x7F, try changing the packet to

\x7F\x00\x08\x01\xF1\x00\x04\xFF
This was the code i found which works with Sphere & RunUO, since 0x7F wasn't used for anything else it made it the logical way to go but... i've now added to the forum of the ListUO site users with an additional dropdown box where they can register their server types, 3 being RUO, SPH & POL. Based on this option the new sites checking application (once i get my finger out and write it) will be able to send any sequence i'd need in order to allow POL shards to work... once i can get this POL hook sorted out, so once the checker finds a POL shard in the list... send a different sequence to the server if needed.

And yeah all-nighters are the killers, i've been on this for the last 2 days myself trying to figure it out... doing my head in again :x
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

Uh oh... try putting the return 0; in AcctLogin outside of the endif...

Code: Select all

exported function AcctLogin(char, byref packet)
   if ((packet.getint16(1)==65280))
      SetGlobalProperty("#ListUOReturn", 1);
   endif
   return 0;
endfunction
recompile and see if that works...

not including the use *; stuff at the top of listuo.src is a side effect of the all-nighter... This DID work with my setup though, the problem is, I was screwing with a hook that I already had on my shard for other things so I rescripted and extracted these 2 sections. I know it will work because like I said, I've tested it with mIRC connecting to POL and grabbing the number of online players and I was able to log in. I think the placement of return 0 is the problem since in my script it also comes later. If UOGateway can do it, I know your program can.
Nando
POL Developer
Posts: 282
Joined: Wed Sep 17, 2008 6:53 pm
Contact:

Re: Help Required With A Packet

Post by Nando »

Hm... I think this solution would break the AutoAccount Pkg in distro. :/
Steve
New User
Posts: 11
Joined: Fri Aug 08, 2008 10:46 pm

Re: Help Required With A Packet

Post by Steve »

I don't want to start to play around with login setups really, pretty much wanted to use the same sequence or a slight variation in the sequence sent for the POL type servers.

I have the latest version of the POL files so i'll continue to work on another solution but for now i have a couple of other things i need to start spending time on etc etc.

From what i can gather i can't seem to do a hook with POL on 0x7F or 0xF1 type bytes sent to it for whatever reason with the original sequence, what should have been something fairly straight forward seems to have me running round in circles... never mind eh :x
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: Help Required With A Packet

Post by Pierce »

If i read this thread: http://forums.polserver.com/viewtopic.php?f=10&t=1931

I am not sure if the 0xF1 works as intended or even not made it inside the official cores.
Just found that one. Perhaps only MuadDib can answer this.
It would be interested if that packet is checked by the core before the login procedure, which is obviously not the case atm.
Which i think only gave you one solution, to use login packet (0x80/0x82). There is a one already scripted by Shini inside the custom script release forum or the one above from CWO.

Btw the 4 bytes before the 0xF1 only seems to be a seed (from connectuo forum).
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

Pierce F1 is not working. Its "non-allowed" just like every other packet. And no, this does not break auto-account if you merge the scripts by putting the code I have here before the auto-account and put the return 0; back inside the if statement (this is why it was there when I originally posted it although the auto-account is disabled anyway on my shard). This looks for a specific login only that shouldn't be accepted by POL anyway. The username being only 0x255 and having no password. Again this is exactly how UOGateway pulled it off except I only send the number of clients online back with the login failed packet instead of a long string containing a ton of information that I don't think Steve is really looking for. When this is tested and works, I'll post a rewritten distro script to be implemented into the distro.
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: Help Required With A Packet

Post by Pierce »

CWO wrote:Pierce F1 is not working.
Yes i know. That was the last what Tekproxy posted in the topic i mentioned above.
It seems he and MuadDib never get this to work.
I did also some tests which result in the same problems.

If you send the 7F 00 00 01 F1 00 04 FF packet with no 0xF1 hook you get a

Code: Select all

Client#1: Unexpected message type f1, 4 bytes (IP:127.0.0.1, Account:None)
0000: f1 00 04 ff                                        ........ ........
If you hook 0xF1 nevertheless if the length is variable or 4 bytes, you get:

Code: Select all

Client#1 (127.0.0.1, Acct unknown) sent non-allowed message type f1.
If you hook 0xF1 and cut of the first 4 byte seed (obviously the local 127.0.0.1, which is quite useless) and send the pure F1 00 04 FF you get no error just the message that a client logged in from in my case 127.0.0.1 (local). But the hook script never reacts on that. If you cut that connection pol tells you that the client logged off (no account, no char).

This will obviously never work, cause pol expects the 0x80 packet, like CWO stated above and the existing packet hook from Shini also shows.

I think MuadDib perhaps tried to get the 0xF1 packet checked before 0x80 is activated. He even put that packet inside the packet list. The questions is, did it get inside the cores because that is not listed inside the core-changes only in the other topic.

MuadDib where are you? ;) :D
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

Pierce wrote: If you hook 0xF1 and cut of the first 4 byte seed (obviously the local 127.0.0.1, which is quite useless) and send the pure F1 00 04 FF you get no error just the message that a client logged in from in my case 127.0.0.1 (local).
Is it possible that POL just ignores the seed entirely so if you send a 4 byte packet, its basically like you sent nothing at all? This is what I seemed to conclude.
Nando
POL Developer
Posts: 282
Joined: Wed Sep 17, 2008 6:53 pm
Contact:

Re: Help Required With A Packet

Post by Nando »

It ignores the seed and checks for some "allowed" packets during the login process, 0xF1 is not there. It seems only login, char creation, game server login, server selection and a few others are allowed.
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Help Required With A Packet

Post by CWO »

Any way to be able to put a uopacket.cfg option in AllowedBeforeLogin=1? :cheesy: Although that would require a bit more of a reference on the "who" parameter. Right now its just a struct with .ip before login... maybe something we can use uo::SendPacket(who) or packet.sendpacket(who) with... Or like an AUX connection who.transmit(packet). Ya lets get a rewrite of the core's packethook feature! :D
Post Reply