diff options
-rw-r--r-- | lib/command.c | 3 | ||||
-rw-r--r-- | lib/qpnexus.c | 1 | ||||
-rw-r--r-- | lib/vty.c | 51 | ||||
-rw-r--r-- | lib/vty.h | 2 | ||||
-rw-r--r-- | vtysh/vtysh.c | 2 | ||||
-rw-r--r-- | vtysh/vtysh_config.c | 3 |
6 files changed, 28 insertions, 34 deletions
diff --git a/lib/command.c b/lib/command.c index efce3fa0..80b113e8 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2569,8 +2569,7 @@ DEFUN (config_write_file, } /* Make vty for configuration file. */ - file_vty = vty_new (); - file_vty->fd = fd; + file_vty = vty_new (fd); file_vty->type = VTY_FILE; /* Config file header print. */ diff --git a/lib/qpnexus.c b/lib/qpnexus.c index f1525e51..8e5b873d 100644 --- a/lib/qpnexus.c +++ b/lib/qpnexus.c @@ -51,7 +51,6 @@ qpn_init_new(qpn_nexus qpn) memset(qpn, 0, sizeof(struct qpn_nexus)) ; qpn->selection = qps_selection_init_new(qpn->selection); - printf("qps_selection_init_new after\n"); qpn->pile = qtimer_pile_init_new(qpn->pile); /* TODO mqueue initialisation */ @@ -96,6 +96,8 @@ static void vty_event_r (enum event event, int sock, struct vty *vty); static int uty_accept (int accept_sock); static int uty_timeout (struct vty *vty); static void vty_timeout_r (qtimer qtr, void* timer_info, qtime_t when); +static void vty_read_r (qps_file qf, void* file_info); +static void vty_flush_r (qps_file qf, void* file_info); /* Extern host structure from command.c */ extern struct host host; @@ -428,15 +430,23 @@ vty_dont_lflow_ahead (struct vty *vty) /* Allocate new vty struct. */ struct vty * -vty_new () +vty_new (int fd) { - struct vty *new = XCALLOC (MTYPE_VTY, sizeof (struct vty)); + struct vty *vty = XCALLOC (MTYPE_VTY, sizeof (struct vty)); - new->obuf = buffer_new(0); /* Use default buffer size. */ - new->buf = XCALLOC (MTYPE_VTY, VTY_BUFSIZ); - new->max = VTY_BUFSIZ; + vty->obuf = buffer_new(0); /* Use default buffer size. */ + vty->buf = XCALLOC (MTYPE_VTY, VTY_BUFSIZ); + vty->max = VTY_BUFSIZ; + vty->fd = fd; - return new; + if (master_nexus) + { + vty->qf = qps_file_init_new(vty->qf, NULL); + qps_add_file(master_nexus->selection, vty->qf, vty->fd, vty); + vty->qtr = qtimer_init_new(vty->qtr, master_nexus->pile, vty_timeout_r, vty); + } + + return vty; } /* Authentication of vty */ @@ -1842,8 +1852,7 @@ vty_create (int vty_sock, union sockunion *su) assert(vty_lock_count); /* Allocate new vty structure and set up default values. */ - vty = vty_new (); - vty->fd = vty_sock; + vty = vty_new (vty_sock); vty->type = VTY_TERM; vty->address = sockunion_su2str (su); if (no_password_check) @@ -1902,15 +1911,6 @@ vty_create (int vty_sock, union sockunion *su) vty_prompt (vty); - if (master_nexus) - { - vty->qf = qps_file_init_new(vty->qf, NULL); - qps_add_file(master_nexus->selection, vty->qf, vty_sock, vty); - qps_set_action(vty->qf, qps_read_mbit, vty_read_r); - qps_set_action(vty->qf, qps_write_mbit, vty_flush_r); - vty->qtr = qtimer_init_new(vty->qtr, master_nexus->pile, vty_timeout_r, vty); - } - /* Add read/write thread. */ vty_event (VTY_WRITE, vty_sock, vty); vty_event (VTY_READ, vty_sock, vty); @@ -2603,8 +2603,7 @@ vty_read_file (FILE *confp) int ret; struct vty *vty; - vty = vty_new (); - vty->fd = 0; /* stdout */ + vty = vty_new (0); /* stdout */ vty->type = VTY_TERM; vty->node = CONFIG_NODE; @@ -2969,10 +2968,9 @@ vty_event_r (enum event event, int sock, struct vty *vty) { accept_file = qps_file_init_new(accept_file, NULL); qps_add_file(master_nexus->selection, accept_file, sock, NULL); - qps_set_action(accept_file, qps_read_mbit, vty_accept_r); vector_set_index(Vvty_serv_thread, sock, accept_file); } - qps_enable_mode(accept_file, qps_read_mbit, NULL) ; + qps_enable_mode(accept_file, qps_read_mbit, vty_accept_r) ; break; #ifdef VTYSH case VTYSH_SERV: @@ -2981,20 +2979,19 @@ vty_event_r (enum event event, int sock, struct vty *vty) { accept_file = qps_file_init_new(accept_file, NULL); qps_add_file(master, accept_file, sock, NULL); - qps_set_action(accept_file, qps_read_mbit, vtysh_accept_r); vector_set_index(Vvty_serv_thread, sock, accept_file); } - qps_enable_mode(accept_file, qps_read_mbit, NULL) ; + qps_enable_mode(accept_file, qps_read_mbit, vtysh_accept_r) ; break; case VTYSH_READ: - qps_enable_mode(vty->file, qps_read_mbit, NULL) ; + qps_enable_mode(vty->file, qps_read_mbit, vtysh_read_r) ; break; case VTYSH_WRITE: - qps_enable_mode(vty->file, qps_write_mbit, NULL) ; + qps_enable_mode(vty->file, qps_write_mbit, vtysh_write_r) ; break; #endif /* VTYSH */ case VTY_READ: - qps_enable_mode(vty->qf, qps_read_mbit, NULL) ; + qps_enable_mode(vty->qf, qps_read_mbit, vty_read_r) ; /* Time out treatment. */ if (vty->v_timeout) @@ -3003,7 +3000,7 @@ vty_event_r (enum event event, int sock, struct vty *vty) } break; case VTY_WRITE: - qps_enable_mode(vty->qf, qps_write_mbit, NULL) ; + qps_enable_mode(vty->qf, qps_write_mbit, vty_flush_r) ; break; case VTY_TIMEOUT_RESET: if (vty->v_timeout) @@ -223,7 +223,7 @@ extern void vty_init (struct thread_master *); extern void vty_init_vtysh (void); extern void vty_terminate (void); extern void vty_reset (void); -extern struct vty *vty_new (void); +extern struct vty *vty_new (int); extern int vty_out (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3); extern int vty_puts(struct vty* vty, const char* str) ; extern int vty_out_newline(struct vty *vty) ; diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 3f189adb..935c4933 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2227,7 +2227,7 @@ void vtysh_init_vty (void) { /* Make vty structure. */ - vty = vty_new (); + vty = vty_new (0); vty->type = VTY_SHELL; vty->node = VIEW_NODE; diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index fb8a1269..f7071fc2 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -353,8 +353,7 @@ vtysh_read_file (FILE *confp) int ret; struct vty *vty; - vty = vty_new (); - vty->fd = 0; /* stdout */ + vty = vty_new (0); /* stdout */ vty->type = VTY_TERM; vty->node = CONFIG_NODE; |