Terminal Detection

Posted by Boborak on Fri 03 Jan 2003 12:37 AM — 6 posts, 25,568 views.

USA #0
Here's the deal, I've recently set up my mud, a SWR-derivitive, to auto-detect among other things a client's type, using IAC calls.

Now, the terminal detection works flawlessly, but ONLY if the user sends some type of data back to the mud. What I mean by this, is that it seems an 'enter' or ANYTHING sent from the client is needed for proper detection of the client. I'm looking to fix this somehow. My question here is, how and when is the reply sent back to the server? Is it merely waiting in the buffer? Or maybe there's something along the lines that's looking for a \n that I'm missing?

My ultimate goal is to have a color 'greeting' only for those clients that can support it, and currently I *DO* have such a thing. But, my players are required to hit 'enter' before anything else is displayed. I'd like to get rid of that enter ;-) Thanks in advance.
Australia Forum Administrator #1
I suppose I should ask "which client"? MUSHclient should send a response back without waiting for an enter.

However check the way the SMAUG code is handling the IACs. Its normal behaviour is to wait for a \n before passing the "line" on for processing. Perhaps this is where the block is? In other words, the IAC check might be too "high" in the server code.
USA #2
The IAC's are sent out right after the new descriptor is created and linked, and right before the stock 'greeting' is sent out. I read in the 'responses' in read_from_buffer(). I assume the \n is what's blocking things. Any reccomendations to get around this?
USA #3
Of note, I just did a packet debug and verified that at least mushclient *IS* sending the required data. But if I take out my required enter (which is just another CON state) the mud seems to dicard the IAC sequences (I'm also doing MCCP detection). Here's a snippet of the packet debug:

Incoming packet: 1 (32 bytes)
...........Press 0a 0d ff fb 19 ff fa 18 01 ff f0 50 72 65 73 73
[Enter]....V..Z 20 5b 45 6e 74 65 72 5d 0a 0d ff fb 56 ff fb 5a
Sent packet: 1 (3 bytes)
... ff fe 19
Sent packet: 2 (16 bytes)
....mushclient.. ff fa 18 00 6d 75 73 68 63 6c 69 65 6e 74 ff f0
Sent packet: 3 (3 bytes)
..V ff fd 56
Sent packet: 4 (3 bytes)
..Z ff fe 5a
Incoming packet: 2 (999 bytes) //the incoming greeting
Australia Forum Administrator #4
read_from_buffer reads a "line" from the input, ie. it looks for a \n. I put code in to detect IACs for MXP processing, which works, see example below. You should be able to modify it for your needs.

My code is in bold, the rest is the standard code.


/*
 * Transfer one line from input buffer to input line.
 */
void read_from_buffer( DESCRIPTOR_DATA *d )
{    
    int i, j, k;
    unsigned char * p;

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


/*

  Look for incoming telnet negotiation
*/


  for (p = d->inbuf; *p; p++)
    if (*p == IAC)
      {
      if (memcmp (p, do_mxp_str, strlen (do_mxp_str)) == 0)
        {
        turn_on_mxp (d);
        /* remove string from input buffer */
        memmove (p, &p [strlen (do_mxp_str)], strlen (&p [strlen (do_mxp_str)]) + 1);
        p--; /* adjust to allow for discarded bytes */
        } /* end of turning on MXP */
      else  if (memcmp (p, dont_mxp_str, strlen (dont_mxp_str)) == 0)
        {
        d->mxp = FALSE;
        /* remove string from input buffer */
        memmove (p, &p [strlen (dont_mxp_str)], strlen (&p [strlen (dont_mxp_str)]) + 1);
        p--; /* adjust to allow for discarded bytes */
        } /* end of turning off MXP */
      } /* end of finding an IAC */



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

Canada #5
I've been trying to get the mud to autodetected MCCP. But unfortuatly with the exception of mcclient, and occasionally zmud, I am unable to detect mccp at all.

I've been using the code listed both here and at http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1110 and still being unable exactly to get things detected.

For the most part, i'm using the smaug-1.4 patch on randomly.org:


   for (p = d->inbuf; *p; p++)
    {
            if (*p == IAC)
            {
                    if (memcmp (p, will_termtype_str, strlen(will_termtype_str)) == 0)
                    {
                            memmove (p, &p [strlen (will_termtype_str)], strlen (&p [strlen (will_termtype_str)]) + 1);
                            p--;
                            write_to_buffer(d, req_termtype_str, 0);
                    } else if (memcmp (p, wont_termtype_str, strlen(wont_termtype_str)) == 0) {
                            memmove (p, &p [strlen (wont_termtype_str)], strlen (&p [strlen (wont_termtype_str)]) + 1);
                            p--;
#ifdef MCCP
                    } else if (memcmp (p, do_compress1_str, strlen(do_compress1_str)) == 0) {
                            compressStart(d, TELOPT_COMPRESS);
                            memmove (p, &p [strlen (do_compress1_str)], strlen(&p[strlen(do_compress1_str)] + 1));
                            p--;
                    } else if (memcmp (p, dont_compress1_str, strlen(dont_compress1_str)) == 0) {
                            compressEnd(d);
                            memmove (p, &p [strlen (dont_compress1_str)], strlen(&p[strlen(do_compress1_str)] + 1));
                            p--;
                    } else if (memcmp (p, do_compress2_str, strlen(do_compress2_str)) == 0) {
                            compressStart(d, TELOPT_COMPRESS2);
                            memmove (p, &p [strlen (do_compress2_str)], strlen(&p[strlen(do_compress2_str)] + 1));
                            p--;
                    } else if (memcmp (p, dont_compress2_str, strlen(dont_compress2_str)) == 0 && compress == FALSE) {
                            compressEnd(d);
                            memmove (p, &p [strlen (dont_compress2_str)], strlen(&p[strlen(do_compress2_str)] + 1));
                            p--;
#endif


There are more lines of course, mainly todo with client detection.

I've been testing with MUSHclient 3.42.

For the retrofit, i've been looking at http://www.gammon.com.au/mushclient/addingservermxp.htm and using mccp stuff instead (mxp is another project i'd like todo something, but mccp is what i started first).

I tried putting in debug lines, I havn't actually tried a packet filter, but it looks like i get a DO COMPRESS2 then a DONT COMPRESS, thus killing off the compression. I've tried taking this into account, but it still doesn't seem to turn it on.

Can you give me any hints at all?

- Gavin