Vaffel - A cross platform ROSE server emulator

Here you can talk about anything you want ;)

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Vaffel - A cross platform ROSE server emulator

Postby Jckf on Mon Nov 15, 2010 8:23 am

This was originally a thread where I asked questions about the ROSE network protocol, but now that they are answered I would like to give you the result =)

UPDATE: Project moved to http://www.vaffel.net/
Last edited by Jckf on Sat Nov 20, 2010 12:42 pm, edited 11 times in total.
User avatar
Jckf
Antares
Antares
 
Posts: 338
Joined: Wed Nov 28, 2007 1:09 am
Location: Norway

Re: ROSE network protocol

Postby lmame on Mon Nov 15, 2010 9:29 pm

I'll have to look at it to be sure but I think server to client isn't encoded, at least the version done in osRose it's sent that way directly in void CClientSocket::SendPacket( CPacket *P ):
  1. int retval = send( sock, (char*)P, P->Size, 0 );


You got the packet structure here:
  1.  
  2. // Structures
  3. // Packet information
  4. struct CPacket
  5. {
  6.     unsigned short  Size;            // Packet size
  7.     unsigned short  Command;         // Packet command
  8.     unsigned short  Unused;          // unused
  9.     unsigned char   Buffer[0x1000]// Packet data //0x600
  10. };
  11.  


The list of commands is found in the different servers, stuff like:
  1. bool CWorldServer::OnReceivePacket( CClientSocket* thisclient, CPacket *P )



Now on the exact structure of received data I know you got the size and stuff but I don't know that part by heart so I'll have to look at it.
You got all the received process in "bool CClientSocket::ReceiveData( )".
The header block of received data (actually the packet size) should be always > 6 but then it's kinda the same structure after decode since you got this after all data is received correctly:
  1.     cryptPacket( (char*)Buffer, this->CryptTable );
  2.     CPacket* pak = (CPacket*)Buffer;


Though indeed the first two Bytes aren't decoded in the CPacket if you look closely at the decode part, it only decodes from the "2" since the first two are actually the packet size ;)
  1. // en/decrypt packet
  2. void cryptPacket(char *packet, char* crypttable )
  3. {
  4.     unsigned short paksize=(*((unsigned short*)&packet[0])) - 2;
  5.     for(int i=2; i<paksize; i++)
  6.     {
  7.         packet[i] = 0x61 ^ packet[i];
  8.     }
  9. }



The only part where the servers are using the crypt function (apart from receiving data from client) is when they're talking to each other (worldserver to charserver and so on).
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: ROSE network protocol

Postby Jckf on Mon Nov 15, 2010 10:07 pm

Thank you, lmame. I've actually noticed all of the above pieces of code in osRose =) I'll have a look at how you handle the commands now ^^
User avatar
Jckf
Antares
Antares
 
Posts: 338
Joined: Wed Nov 28, 2007 1:09 am
Location: Norway

Re: ROSE network protocol

Postby Jckf on Tue Nov 16, 2010 1:17 pm

I just noticed something. The user ID is stored as a two byte word in the login packet, which means ROSE doesn't support more than 65 535 registered users. Or am I wrong?

EDIT: I might be misunderstanding what a WORD is.

In osRose source, you have ADDBYTE(), ADDWORD() and ADDSTRING(). The first one is simple: Add one byte. The last one is also simple: Add a string. However, what is the definition of a WORD?
User avatar
Jckf
Antares
Antares
 
Posts: 338
Joined: Wed Nov 28, 2007 1:09 am
Location: Norway

Re: ROSE network protocol

Postby xadet3 on Tue Nov 16, 2010 2:05 pm

A 'WORD' is (usually) an unsigned 16-bit int.
xadet3
Pero pero
Pero pero
 
Posts: 727
Joined: Tue Jan 08, 2008 11:51 pm
Location: Norwich, England.

Re: ROSE network protocol

Postby Jckf on Tue Nov 16, 2010 3:30 pm

xadet3 wrote:A 'WORD' is (usually) an unsigned 16-bit int.

Aah! I see what I'm doing wrong! =D I read both ADDWORD and ADDDWORD as the same. No wonder I was missing pieces of my packets -.-

EDIT: I don't want to publish my code just yet, but here is a snippet showing how easy packet handling is =)

  1. $server->register_handler(0x0703,sub {
  2.     my ($handle,$packet) = @_;
  3.     $server->send_packet($handle,$server->build_packet(0x07FF,
  4.         intword(0xAF02) .
  5.         intword(0xBD46) .
  6.         intword(0x0009) .
  7.         intword(0x0012) .
  8.         chr(0x00) .
  9.         intdword(0xCDCDCDCD) .
  10.         intdword(0xCDCDCDCD) .
  11.         intdword(0xCDCDCDCD) .
  12.         intdword(0xCDCDCDCD) .
  13.         intword(0xCDCD) .
  14.         chr(0xD3)
  15.     ));
  16. });


The same function in osRose, but without the code to tie it to the command is:
  1. bool CLoginServer::pakEncryptionRequest( CLoginClient* thisclient, CPacket* P )
  2. {
  3.     BEGINPACKET( pak, 0x7ff );
  4.     ADDWORD    ( pak, 0xaf02 );
  5.     ADDWORD    ( pak, 0xbd46 );
  6.     ADDWORD    ( pak, 0x0009 );
  7.     ADDWORD    ( pak, 0x0012 );
  8.     ADDBYTE    ( pak, 0x0000 );
  9.     ADDDWORD   ( pak, 0xcdcdcdcd );
  10.     ADDDWORD   ( pak, 0xcdcdcdcd );
  11.     ADDDWORD   ( pak, 0xcdcdcdcd );
  12.     ADDDWORD   ( pak, 0xcdcdcdcd );
  13.     ADDWORD    ( pak, 0xcdcd );
  14.     ADDBYTE    ( pak, 0xd3 );
  15.     thisclient->SendPacket( &pak );
  16.     return true;
  17. }
Last edited by Jckf on Wed Nov 17, 2010 1:19 pm, edited 1 time in total.
User avatar
Jckf
Antares
Antares
 
Posts: 338
Joined: Wed Nov 28, 2007 1:09 am
Location: Norway

Re: ROSE network protocol

Postby lmame on Wed Nov 17, 2010 12:53 am

I see :)

Though I kinda like "our" way because you can slice the packet like this:
  1.    BEGINPACKET( pak, 0x7ff );
  2.     ADDWORD    ( pak, 0xaf02 );
  3.     ADDWORD    ( pak, 0xbd46 );
  4.     ADDWORD    ( pak, 0x0009 );
  5.     ADDWORD    ( pak, 0x0012 );
  6.    
  7.     if(thisclient->is_invisible)
  8.     {
  9.         ADDBYTE    ( pak, 0x0001 );
  10.     }
  11.     else
  12.     {
  13.         ADDBYTE    ( pak, 0x0000 );
  14.     }
  15.  
  16.     ADDDWORD   ( pak, 0xcdcdcdcd );
  17.     ADDDWORD   ( pak, 0xcdcdcdcd );
  18.     ADDDWORD   ( pak, 0xcdcdcdcd );
  19.     ADDDWORD   ( pak, 0xcdcdcdcd );
  20.     ADDWORD    ( pak, 0xcdcd );
  21.     ADDBYTE    ( pak, 0xd3 );
  22.     thisclient->SendPacket( &pak );


And it happens sometimes (quite sometimes) in the code ;)
Just an example ^_^
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: ROSE network protocol

Postby Jckf on Wed Nov 17, 2010 1:18 pm

lmame wrote:I see :)

Though I kinda like "our" way because you can slice the packet like this:


And it happens sometimes (quite sometimes) in the code ;)
Just an example ^_^

That would look something like this at my end ;)

  1. my $args = intword(0x1234);
  2. if ($clients{$handle}{'invisible'}) {
  3.     $args .= intword(0x1337);
  4. } else {
  5.     $args .= intword(0x0000);
  6. }
  7. $args .= chr(0x00);
  8. $server->send_packet($server->build_packet(0x07FF,$args));

This is only bogus code though ;p
User avatar
Jckf
Antares
Antares
 
Posts: 338
Joined: Wed Nov 28, 2007 1:09 am
Location: Norway

Re: ROSE network protocol

Postby Jckf on Wed Nov 17, 2010 4:17 pm

A small update.
I'm now done with a version 1 of the login server. It uses MySQL and fully supports banned accounts, not activated accounts and GMs.

Next up, character server =)

PS: What's nice about this over osRose is the fact that it can be run on *NIX systems =) But I'm not doing this to be better than the osRose team. Please remember that. This is a learning project, and the packet structures are infact taken from osRose! So alot of thanks goes to them <3

EDIT: Updated first post.

EDIT2: A question. Are the 0x05** packets osRose's server->server communication?
User avatar
Jckf
Antares
Antares
 
Posts: 338
Joined: Wed Nov 28, 2007 1:09 am
Location: Norway

Re: pRoseEmu - A multiplatform ROSE server emulator

Postby Raavi on Wed Nov 17, 2010 7:05 pm

Never worked with perl but it looks kinda mutch as PHP. i know perl runs on Linux distros so it would be nice if this one is going to be a sister project POSRose :lol: Great work
Raavi
Rackie
Rackie
 
Posts: 243
Joined: Sun May 30, 2010 4:15 pm

Next

Return to Welcome to the bar

Who is online

Users browsing this forum: No registered users and 5 guests