• 大小: 777KB
    文件类型: .gz
    金币: 1
    下载: 0 次
    发布日期: 2021-06-01
  • 语言: 其他
  • 标签:

资源简介

基于linux arm-mx335平台,串口网口透传映射源码,直接编译测试通过,实现全双工 串口网口透传映射

资源截图

代码片段和文件信息

/*
 *  ser2net - A program for allowing telnet connection to serial ports
 *  Copyright (C) 2001  Corey Minyard 
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not write to the Free Software
 *  Foundation Inc. 59 Temple Place Suite 330 Boston MA  02111-1307  USA
 */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include “controller.h“
#include “selector.h“
#include “dataxfer.h“
#include “utils.h“
#include “telnet.h“


extern selector_t *ser2net_sel;

/** baseD ON sshd.c FROM openssh.com */
#ifdef HAVE_TCPD_H
#include 
int allow_severity = LOG_INFO;
int deny_severity = LOG_WARNING;
static char *progname = “ser2net-control“;
#endif /* HAVE_TCPD_H */

/* This file holds the code that runs the control port. */

static int acceptfd; /* The file descriptor for the accept port. */

static int max_controller_ports = 4; /* How many control connections
   do we allow at a time. */
static int num_controller_ports = 0; /* How many control connections
   are currently active. */

#define INBUF_SIZE 255 /* The size of the maximum input command. */

char *prompt = “-> “;

/* This data structure is kept for each control connection. */
typedef struct controller_info {
    int            tcpfd; /* When connected the file
                                           descriptor for the TCP
                                           port used for I/O. */
    struct sockaddr_in remote; /* The socket address of who
   is connected to this port. */

    unsigned char inbuf[INBUF_SIZE+1]; /* Buffer to receive command on. */
    int  inbuf_count; /* The number of bytes currently
   in the inbuf. */

    char *outbuf; /* The output buffer NULL if
   no output. */
    int  outbufsize; /* Total size of the memory
   allocated in outbuf. */
    int  outbuf_pos; /* The current position in the
   output buffer. */
    int  outbuf_count; /* The number of bytes
   (starting at outbuf_pos)
   left to transmit. */

    void *monitor_port_id; /* When port monitoring this is
   the id given when the monitoring
   is started.  It is used to stop
   monitoring. */

    struct controller_info *next; /* Used to keep these items in
   a linked list. */

   

评论

共有 条评论

相关资源