Skip to content

Commit

Permalink
vty_utils: some iacs send a response
Browse files Browse the repository at this point in the history
MUST make that dynamic... really

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Oct 27, 2010
1 parent afadd69 commit 1f8faa5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion vty_utils.c
Expand Up @@ -9,6 +9,7 @@
#include <sys/types.h>
#include <sys/socket.h>

#include "utils.h"
#include "vty_utils.h"

static int check_vty(struct knet_vty *vty)
Expand Down Expand Up @@ -72,7 +73,7 @@ static int knet_vty_read_real(struct knet_vty *vty, unsigned char *buf, size_t b
if (readlen < 0)
goto out_clean;

/* at somepoint we *might* have to add IAC parsing */
/* at somepoint we have to add IAC parsing */
if ((buf[0] == IAC) && (ignore_iac))
goto iac_retry;

Expand Down Expand Up @@ -155,15 +156,25 @@ void knet_vty_print_banner(struct knet_vty *vty)

int knet_vty_set_iacs(struct knet_vty *vty)
{
unsigned char cmdreply[VTY_MAX_BUFFER_SIZE];
unsigned char cmdsga[] = { IAC, WILL, TELOPT_SGA, '\0' };
unsigned char cmdsgareply[] = { IAC, DO, TELOPT_SGA, '\0' };
unsigned char cmdlm[] = { IAC, DONT, TELOPT_LINEMODE, '\0' };
ssize_t readlen;

if (check_vty(vty))
return -1;

if (knet_vty_write(vty, "%s", cmdsga) < 0)
return -1;

readlen = knet_vty_read_real(vty, cmdreply, VTY_MAX_BUFFER_SIZE, 0);
if (readlen < 0)
return readlen;

if (memcmp(&cmdreply, &cmdsgareply, readlen))
return -1;

if (knet_vty_write(vty, "%s", cmdlm) < 0)
return -1;

Expand Down

0 comments on commit 1f8faa5

Please sign in to comment.