1 #ifndef MODEM_CORE_H 2 #define MODEM_CORE_H 1 3 4 typedef enum { 5 MDM_RESP_OK = 0, // Common code 6 MDM_RESP_CONNECT = 1, // Common code 7 MDM_RESP_RING = 2, // Common code 8 MDM_RESP_NO_CARRIER = 3, // Common code 9 MDM_RESP_ERROR = 4, // Common code 10 MDM_RESP_CONNECT_1200 = 5, // Common code 11 MDM_RESP_NO_DIALTONE = 6, // Common code 12 MDM_RESP_BUSY = 7, // Common code 13 MDM_RESP_NO_ANSWER = 8, // Common code 14 MDM_RESP_CONNECT_0600 = 9, // Conexant code 15 MDM_RESP_CONNECT_2400 = 10, // Common code 16 MDM_RESP_CONNECT_4800 = 11, // Common code 17 MDM_RESP_CONNECT_9600 = 12, // Common code 18 MDM_RESP_CONNECT_14400 = 13, // Hayes code 19 MDM_RESP_CONNECT_19200 = 14, // Hayes code 20 MDM_RESP_CONNECT_57600 = 18, // Conexant code 21 MDM_RESP_CONNECT_115200 = 19, // Conexant code 22 MDM_RESP_CONNECT_230400 = 20, // Conexant code 23 MDM_RESP_CONNECT_460800 = 21, // Conexant code 24 MDM_RESP_CONNECT_921600 = 22, // Conexant code 25 MDM_RESP_CONNECT_7200 = 24, // Hayes code 26 MDM_RESP_CONNECT_12000 = 25, // Hayes code 27 MDM_RESP_CONNECT_38400 = 28, // Hayes code 28 MDM_RESP_END_OF_LIST 29 } modem_response; 30 31 #define MDM_FC_RTS 1 32 #define MDM_FC_XON 2 33 34 typedef enum { 35 MDM_CONN_NONE = 0, 36 MDM_CONN_OUTGOING = 1, 37 MDM_CONN_INCOMING = 2 38 } conn_type; 39 40 #ifndef TRUE 41 #define TRUE 1 42 #define FALSE 0 43 #endif 44 45 #include "dce.h" 46 #include "line.h" 47 #include "nvt.h" 48 49 typedef struct x_config { 50 } x_config; 51 52 enum { 53 S_REG_RINGS = 0, 54 S_REG_RING_COUNT = 1, 55 S_REG_BREAK = 2, 56 S_REG_CR = 3, 57 S_REG_LF = 4, 58 S_REG_BS = 5, 59 S_REG_BLIND_WAIT = 6, 60 S_REG_CARRIER_WAIT = 7, 61 S_REG_COMMA_PAUSE = 8, 62 S_REG_CARRIER_TIME = 9, 63 S_REG_CARRIER_LOSS = 10, 64 S_REG_DTMF_TIME = 11, 65 S_REG_GUARD_TIME = 12, 66 S_REG_INACTIVITY_TIME = 30, 67 S_REG_MAX_ARRAY_SIZE 68 }; 69 70 typedef struct modem_config { 71 // master configuration information 72 int mp[2][2]; 73 int cp[2][2]; 74 int wp[2][2]; 75 char no_answer[256]; 76 char local_connect[256]; 77 char remote_connect[256]; 78 char local_answer[256]; 79 char remote_answer[256]; 80 char inactive[256]; 81 int direct_conn; 82 char direct_conn_num[256]; 83 84 // need to eventually change these 85 dce_config dce_data; 86 line_config line_data; 87 int line_speed; 88 int conn_type; 89 int is_ringing; 90 int is_off_hook; 91 int dsr_active; 92 int force_dsr; 93 int force_dcd; 94 int invert_dsr; 95 int invert_dcd; 96 int allow_transmit; 97 int is_binary_negotiated; 98 int ring_ctr; 99 // command information 100 int pre_break_delay; 101 unsigned char first_ch; 102 int is_cmd_started; 103 int is_cmd_mode; 104 char cur_line[1024]; 105 int cur_line_idx; 106 int last_line_idx; 107 // dailing information 108 char dialno[256]; 109 char last_dialno[256]; 110 char dial_type; 111 char last_dial_type; 112 int memory_dial; 113 // modem config 114 int connect_response; 115 int response_code_level; 116 int send_responses; 117 int text_responses; 118 int is_echo; 119 int s[S_REG_MAX_ARRAY_SIZE]; 120 int break_len; 121 int disconnect_delay; 122 char crlf[3]; 123 } modem_config; 124 125 void mdm_init(void); 126 void mdm_init_config(modem_config *cfg); 127 int mdm_set_control_lines(modem_config *cfg); 128 void mdm_write_char(modem_config *cfg, unsigned char data); 129 void mdm_write(modem_config *cfg, unsigned char *data, int len); 130 void mdm_send_response(int msg, modem_config *cfg); 131 int mdm_off_hook(modem_config *cfg); 132 int mdm_answer(modem_config *cfg); 133 int mdm_print_speed(modem_config *cfg); 134 int mdm_connect(modem_config *cfg); 135 int mdm_listen(modem_config *cfg); 136 int mdm_disconnect(modem_config *cfg, unsigned char force); 137 int mdm_parse_cmd(modem_config *cfg); 138 int mdm_handle_char(modem_config *cfg, unsigned char ch); 139 int mdm_clear_break(modem_config *cfg); 140 int mdm_parse_data(modem_config *cfg, unsigned char *data, int len); 141 int mdm_handle_timeout(modem_config *cfg); 142 int mdm_send_ring(modem_config *cfg); 143 int mdm_read(modem_config *cfg, unsigned char *data, int len); 144 145 #include "line.h" 146 #include "dce.h" 147 148 #endif