Changeset 4476 for pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c
- Timestamp:
- Apr 19, 2013 6:05:06 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/cli_telnet.c
r4461 r4476 146 146 { 147 147 TRANSMIT_BINARY = 0, /* Transmit Binary. */ 148 ECHO = 1, /* Echo. */148 TERM_ECHO = 1, /* Echo. */ 149 149 RECONNECT = 2, /* Reconnection. */ 150 150 SUPPRESS_GA = 3, /* Suppress Go Aheah. */ … … 896 896 static pj_bool_t handle_alfa_num(cli_telnet_sess *sess, unsigned char *data) 897 897 { 898 if (is_local_option_state_ena(sess, ECHO)) {898 if (is_local_option_state_ena(sess, TERM_ECHO)) { 899 899 if (recv_buf_right_len(sess->rcmd) > 0) { 900 900 /* Cursor is not at EOL, insert character */ … … 1062 1062 1063 1063 status = pj_cli_sess_exec(&sess->base, (char *)&sess->rcmd->rbuf, 1064 pool, &info); 1064 pool, &info); 1065 1065 1066 1066 switch (status) { … … 1646 1646 set_peer_option(sess, STATUS, PJ_TRUE); 1647 1647 set_peer_option(sess, TIMING_MARK, PJ_TRUE); 1648 set_peer_option(sess, ECHO, PJ_TRUE);1648 set_peer_option(sess, TERM_ECHO, PJ_TRUE); 1649 1649 1650 1650 send_cmd_do(sess, SUPPRESS_GA); 1651 send_cmd_will(sess, ECHO);1651 send_cmd_will(sess, TERM_ECHO); 1652 1652 send_cmd_will(sess, STATUS); 1653 1653 send_cmd_will(sess, SUPPRESS_GA); … … 1728 1728 1729 1729 /* Start telnet daemon */ 1730 telnet_start(fe); 1730 status = telnet_start(fe); 1731 if (status != PJ_SUCCESS) 1732 goto on_exit; 1731 1733 1732 1734 pj_cli_register_front_end(cli, &fe->base); … … 1770 1772 &val, sizeof(val)); 1771 1773 1772 if (status != PJ_SUCCESS) 1773 goto on_exit; 1774 if (status != PJ_SUCCESS) { 1775 PJ_LOG(3, (THIS_FILE, "Failed setting socket options")); 1776 } 1774 1777 1775 1778 /* The loop is silly, but what else can we do? */ … … 1834 1837 } 1835 1838 1836 /** Fill telnet information and call pj_cli_telnet_on_started callback */ 1839 return PJ_SUCCESS; 1840 1841 on_exit: 1837 1842 if (fe->cfg.on_started) { 1838 char ip_addr[32]; 1839 pj_cli_telnet_info telnet_info; 1840 pj_sockaddr hostip; 1841 1842 telnet_info.ip_address.ptr = ip_addr; 1843 telnet_info.ip_address.slen = 0; 1844 1845 status = pj_gethostip(pj_AF_INET(), &hostip); 1846 if (status != PJ_SUCCESS) 1847 goto on_exit; 1848 1849 pj_strcpy2(&telnet_info.ip_address, 1850 pj_inet_ntoa(hostip.ipv4.sin_addr)); 1851 1852 telnet_info.port = fe->cfg.port; 1853 1854 (*fe->cfg.on_started)(&telnet_info); 1855 } 1856 1857 return PJ_SUCCESS; 1858 1859 on_exit: 1843 (*fe->cfg.on_started)(status); 1844 } 1845 1860 1846 if (fe->asock) 1861 1847 pj_activesock_close(fe->asock); … … 1908 1894 /** Start Telnet **/ 1909 1895 status = telnet_start(fe); 1910 if (status == PJ_SUCCESS) 1896 if (status == PJ_SUCCESS) { 1897 if (fe->cfg.on_started) { 1898 (*fe->cfg.on_started)(status); 1899 } 1911 1900 TRACE_((THIS_FILE, "Telnet Restarted")); 1912 1901 } 1913 1902 on_exit: 1914 1903 return status; 1915 1904 } 1905 1906 PJ_DEF(pj_status_t) pj_cli_telnet_get_info(pj_cli_front_end *fe, 1907 pj_cli_telnet_info *info) 1908 { 1909 pj_sockaddr hostip; 1910 pj_status_t status; 1911 cli_telnet_fe *tfe = (cli_telnet_fe*) fe; 1912 1913 PJ_ASSERT_RETURN(fe && (fe->type == PJ_CLI_TELNET_FRONT_END) && info, 1914 PJ_EINVAL); 1915 1916 pj_strset(&info->ip_address, info->buf_, 0); 1917 1918 status = pj_gethostip(pj_AF_INET(), &hostip); 1919 if (status != PJ_SUCCESS) 1920 return status; 1921 1922 pj_strcpy2(&info->ip_address, pj_inet_ntoa(hostip.ipv4.sin_addr)); 1923 1924 info->port = tfe->cfg.port; 1925 1926 return PJ_SUCCESS; 1927 }
Note: See TracChangeset
for help on using the changeset viewer.