Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ KaVir protocol snippet

KaVir protocol snippet

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3 

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #30 on Fri 11 May 2018 06:00 AM (UTC)

Amended on Fri 11 May 2018 06:03 AM (UTC) by Nick Gammon

Message
Well, I presume you can send the commands, but what you are saying is the server doesn't react. The routines in comm.c are where input is handled.

In particular, if you haven't logged on, then in nanny:

So you could do something like this:


nick@Ubuntu-Windows:~/Development/smaugfuss/area$ gdb ../src/smaug
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
...
(gdb) break nanny
Breakpoint 1 at 0x4d5c09: file comm.c, line 2600.
(gdb) run
Starting program: /home/nick/Development/smaugfuss/src/smaug 
Fri May 11 16:50:20 2018 :: Booting Database
 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
Fri May 11 16:50:20 2018 :: [*****] BOOT: ---------------------[ Boot Log ]--------------------
Fri May 11 16:50:20 2018 :: Initializing libdl support...
Fri May 11 16:50:20 2018 :: Loading commands...
Fri May 11 16:50:20 2018 :: Loading spec_funs...
... blah blah ...
Fri May 11 16:50:20 2018 :: Loading Projects
Fri May 11 16:50:20 2018 :: Loading Morphs
Fri May 11 16:50:20 2018 :: Done.
Fri May 11 16:50:20 2018 :: Initializing socket
Fri May 11 16:50:20 2018 :: (Name Not Set) ready on port 4000.

... now you login and type your name, eg "nick" ...

Breakpoint 1, nanny (d=0xcd5cd0, argument=0x7fffffffd910 "nick") at comm.c:2600
2600	   while( isspace( *argument ) )
(gdb) list
2595	/*
2596	 * Deal with sockets that haven't logged in yet.
2597	 */
2598	void nanny( DESCRIPTOR_DATA * d, char *argument )
2599	{
2600	   while( isspace( *argument ) )
2601	      argument++;
2602	
2603	   switch ( d->connected )
2604	   {
(gdb) (Press <enter> to repeat the previous command, in this case "list")
2605	      default:
2606	         bug( "%s: bad d->connected %d.", __FUNCTION__, d->connected );
2607	         close_socket( d, TRUE );
2608	         return;
2609	
2610	      case CON_GET_NAME:
2611	         nanny_get_name( d, argument );
2612	         break;
2613	
2614	      case CON_GET_OLD_PASSWORD:
(gdb) 



This shows that your input was received. Then you can do "next" or "step". "next" goes onto the next (executed) line without going into sub-functions, but "step" will follow functions down. If you end up in a boring function (like, "isspace") you can type "finish" to leave that function and go back up to the higher-level function.

You can also usefully see what variables contain, eg "p foo" will print the value in foo.

Also try typing "list" which lists the source around where you currently are, to give you some context.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,551 posts)  Bio   Global Moderator
Date Reply #31 on Sat 12 May 2018 03:58 PM (UTC)
Message
Except that with this code you'll never actually reach nanny.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Fiendish   USA  (2,551 posts)  Bio   Global Moderator
Date Reply #32 on Sat 12 May 2018 04:15 PM (UTC)

Amended on Sat 12 May 2018 04:23 PM (UTC) by Fiendish

Message
Quote:
edit: and fiendish, I checked my read_from_buffer function against stock, and nothing inside the function itself was changed.

Let's say that I don't believe you, and, to be clear, I don't. Now what steps could you take to be more convincing here?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Joeyfogas   (41 posts)  Bio
Date Reply #33 on Sat 12 May 2018 08:52 PM (UTC)

Amended on Sun 13 May 2018 02:29 AM (UTC) by Nick Gammon

Message
Taken from STOCK.

you can compare



/*
 * Transfer one line from input buffer to input line.
 */
void read_from_buffer( DESCRIPTOR_DATA * d )
{
   int i, j, k, iac = 0;

   /*
    * Hold horses if pending command already.
    */
   if( d->incomm[0] != '\0' )
      return;

   /*
    * Look for at least one new line.
    */
   for( i = 0; i < MAX_INBUF_SIZE && d->inbuf[i] != '\n' && d->inbuf[i] != '\r'; i++ )
   {
      if( d->inbuf[i] == '\0' )
         return;
   }

   /*
    * Canonical input processing.
    */
   for( i = 0, k = 0; d->inbuf[i] != '\n' && d->inbuf[i] != '\r'; i++ )
   {
      if( k >= 254 )
      {
         write_to_descriptor( d, "Line too long.\r\n", 0 );

         /*
          * skip the rest of the line 
          */
         /*
          * for ( ; d->inbuf[i] != '\0' || i>= MAX_INBUF_SIZE ; i++ )
          * {
          * if ( d->inbuf[i] == '\n' || d->inbuf[i] == '\r' )
          * break;
          * }
          */
         d->inbuf[i] = '\n';
         d->inbuf[i + 1] = '\0';
         break;
      }

      if( d->inbuf[i] == ( signed char )IAC )
         iac = 1;
      else if( iac == 1
               && ( d->inbuf[i] == ( signed char )DO || d->inbuf[i] == ( signed char )DONT
                    || d->inbuf[i] == ( signed char )WILL ) )
         iac = 2;
      else if( iac == 2 )
      {
         iac = 0;
         if( d->inbuf[i] == ( signed char )TELOPT_COMPRESS2 )
         {
            if( d->inbuf[i - 1] == ( signed char )DO )
               compressStart( d );
            else if( d->inbuf[i - 1] == ( signed char )DONT )
               compressEnd( d );
         }
      }
      else if( d->inbuf[i] == '\b' && k > 0 )
         --k;
      else if( isascii( d->inbuf[i] ) && isprint( d->inbuf[i] ) )
         d->incomm[k++] = d->inbuf[i];
   }

   /*
    * Finish off the line.
    */
   if( k == 0 )
      d->incomm[k++] = ' ';
   d->incomm[k] = '\0';

   /*
    * Deal with bozos with #repeat 1000 ...
    */
   if( k > 1 || d->incomm[0] == '!' )
   {
      if( d->incomm[0] != '!' && strcmp( d->incomm, d->inlast ) )
      {
         d->repeat = 0;
      }
      else
      {
         if( ++d->repeat >= 20 )
         {
/*		log_printf( "%s input spamming!", d->host );
*/
            write_to_descriptor( d, "\r\n*** PUT A LID ON IT!!! ***\r\nYou cannot enter the same command more than 20 consecutive times!\r\n", 0 );
            mudstrlcpy( d->incomm, "quit", MAX_INPUT_LENGTH );
         }
      }
   }

   /*
    * Do '!' substitution.
    */
   if( d->incomm[0] == '!' )
      mudstrlcpy( d->incomm, d->inlast, MAX_INPUT_LENGTH );
   else
      mudstrlcpy( d->inlast, d->incomm, MAX_INPUT_LENGTH );

   /*
    * Shift the input buffer.
    */
   while( d->inbuf[i] == '\n' || d->inbuf[i] == '\r' )
      i++;
   for( j = 0; ( d->inbuf[j] = d->inbuf[i + j] ) != '\0'; j++ )
      ;
   return;
}

Top

Posted by Joeyfogas   (41 posts)  Bio
Date Reply #34 on Sun 13 May 2018 01:35 AM (UTC)
Message
ok I apologize, there was a step in there I took too literally. Fiendish, thank you for being so blunt. I did finally find the problem in the read_from_buffer
Top

Posted by Joeyfogas   (41 posts)  Bio
Date Reply #35 on Sun 13 May 2018 03:10 AM (UTC)
Message
there was this in the instruction..



Then replace every instance of "d->inbuf" with "read_buf", so that everything 
goes into the temporary buffer rather than directly into the characters input 
buffer.


I guess I took that literally and replaced everywhere, even in the read_from_buffer. restoring the "d->inbuf" in that area fixed it.
Top

Posted by Fiendish   USA  (2,551 posts)  Bio   Global Moderator
Date Reply #36 on Sun 13 May 2018 12:12 PM (UTC)
Message
Glad to be of service. :)

https://github.com/fiendish/aardwolfclientpackage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


105,973 views.

This is page 3, subject is 3 pages long:  [Previous page]  1  2  3 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.