1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32 33 34 35 36
37
38 /*!
39 * ======== Telnet ========
40 * NDK module used for creating and configuring a telnet server.
41 *
42 * The Telnet module can be used to configure and create a telnet server in
43 * an NDK program.
44 *
45 * In order to configure a telnet server, users must create a Telnet module
46 * parameters structure, which contains all of the instance properties of a
47 * Telnet instance. Once the parameter structure is created, it may be used
48 * to change the properties of the telnet server that's being created.
49 *
50 * Users are able to create multiple telnet servers by creating multiple
51 * Telnet instances, and configuring each one. However, if multiple Telnet
52 * instances are created, one must be careful to ensure that they all
53 * have been configured to have unique and free port numbers.
54 */
55
56 @Template("./Telnet.xdt")
57
58 metaonly module Telnet {
59
60 /*! Function signature for CISARGS struct service reporting function */
61 typedef Void (*telnetServiceFxn)(Int, Int, Int, Void *);
62
63 /*! Function signature for NTPARAM_TELNET struct callback function */
64 typedef Int (*telnetCallbackFxn)(Void *);
65
66 /*! Type used to specify bits in mode */
67 typedef Bits16 CisFlags;
68
69 /*! Specifies if the IfIdx field is valid. */
70 const CisFlags CIS_FLG_IFIDXVALID = 0x0001;
71
72 /*!
73 * Requests that IfIdx be resolved to an IP address before service
74 * execution is initiated.
75 */
76 const CisFlags CIS_FLG_RESOLVEIP = 0x0002;
77
78 /*! Specifies that the service should be invoked by IP address */
79 const CisFlags CIS_FLG_CALLBYIP = 0x0004;
80
81 /*!
82 * A service that is dependent on a valid IP address (as determined by the
83 * RESOLVEIP flag) is shut down if the IP address becomes invalid.
84 *
85 * When this flag is set, the service will be restarted when a new address
86 * becomes available. Otherwise; the service will not be restarted.
87 */
88 const CisFlags CIS_FLG_RESTARTIPTERM = 0x0008;
89
90 /*!
91 * ======== create ========
92 * Creates an Telnet instance.
93 */
94 create();
95
96 instance:
97 /*! The maximum number of connections for the telnet server (1 - 24). */
98 config Int maxCon = 8;
99
100 /*! The port number which this telnet server will accept connections. */
101 config Int port = 23;
102
103 /*!
104 * Set of flags which represent the desired behavior of the telnet Server.
105 *
106 * The following flag values may be set either individually, or by or-ing
107 * flags together:
108 * @p(blist)
109 * - CIS_FLG_IFIDXVALID - specifies if the IfIdx field is valid.
110 *
111 * - CIS_FLG_RESOLVEIP - Requests that IfIdx be resolved to an IP
112 * addressbefore service execution is initiated.
113 *
114 * - CIS_FLG_CALLBYIP - Specifies that the service should be invoked by
115 * IP address
116 *
117 * - CIS_FLG_RESTARTIPTERM - A service that is dependent on a valid IP
118 * address.
119 * @p
120 */
121 config Int mode = 0;
122
123 /*!
124 * The physical device index on which the telnet server shall be
125 * executed. Must be greater than zero.
126 */
127 config Int ifIdx = 1;
128
129 /*!
130 * The IP address on which to initiate this service.
131 *
132 * To accept a connection from any IP, specify INADDR_ANY.
133 */
134 config String ipAddr = "INADDR_ANY";
135
136 /*! Telnet service reporting function. */
137 config telnetServiceFxn pCbSrv = '&ti_ndk_config_Global_serviceReport';
138
139 /*!
140 * Telnet callback function. This is a handle to the function which
141 * contains the telnet server code.
142 */
143 config telnetCallbackFxn callBackFxn = null;
144
145 /*! @_nodoc
146 *
147 * internal use only. Intermediate variables mapped to Grace checkboxes,
148 * used to update 'mode' flags variable.
149 */
150 config Bool IfIdXValid = false;
151
152 /*! @_nodoc
153 *
154 * internal use only. Intermediate variables mapped to Grace checkboxes,
155 * used to update 'mode' flags variable.
156 */
157 config Bool ResolveIP = false;
158
159 /*! @_nodoc
160 *
161 * internal use only. Intermediate variables mapped to Grace checkboxes,
162 * used to update 'mode' flags variable.
163 */
164 config Bool CallByIP = false;
165
166 /*! @_nodoc
167 *
168 * internal use only. Intermediate variables mapped to Grace checkboxes,
169 * used to update 'mode' flags variable.
170 */
171 config Bool RestartIPTerm = false;
172 }