2018-02-17 16:15:11 +11:00
# Minitel for OpenOS
2018-08-11 13:54:25 +10:00
This package includes the Minitel daemon, in etc/rc.d/minitel.lua, and the minitel library for using minitel, in usr/lib/minitel.lua.
2018-02-17 16:15:11 +11:00
## Minitel daemon
### Installation
2018-03-09 19:20:08 +11:00
#### With OPPM
2018-08-08 09:35:28 +10:00
1. Run `oppm install minitel-util` - this will install both the Minitel utilities and pull in the Minitel daemon as a dependency.
2018-08-04 05:24:07 +10:00
2. Run `mtcfg`
This will walk you through setting up Minitel.
2018-03-09 19:20:08 +11:00
#### Manual
2018-02-17 16:15:11 +11:00
1. Place minitel.lua into /etc/rc.d
2. Place your hostname into /etc/hostname
3. Run rc minitel enable; rc minitel start
### Configuration
2018-08-08 09:37:29 +10:00
The minitel daemon keeps a settings file in /etc/minitel.cfg, which is loaded on start. This can be edited directly and the daemon restarted, or settings can be changed from the command line.
2018-02-17 16:15:11 +11:00
To change a setting, one invokes:
2018-08-08 09:35:28 +10:00
`rc minitel set <option> <value>`
2018-02-17 16:15:11 +11:00
#### Available settings
- port: the physical port the protocol runs over
- pctime: the amount of time packets are kept in the packet cache
- retry: how many seconds between resend attempts of reliable packets
- rctime: How long items are kept in the routing cache
2018-08-08 09:35:28 +10:00
- retrycount: how many attempts to resend should be made
- route: whether to forward packets
- debug: whether to output debugging info to the display
2018-02-17 16:15:11 +11:00
2018-08-08 09:35:28 +10:00
In addition, one can invoke to get large amounts of debug output, *rc minitel set_route <hostname> <local_modem> <remote_modem>* to add a static route, and *rc minitel del_route <hostname>* to delete a static route.
2018-02-17 16:15:11 +11:00
2018-08-20 17:24:26 +10:00
### Events
2018-08-20 17:23:16 +10:00
The Minitel daemon handles both sending and receiving packets, via events. There are four types of events used:.
#### net\_msg, *from*, *port*, *data*
This event is triggered when the Minitel daemon receives a data (type 0 or 1) packet.
#### net\_ack, *packet ID*
This event is triggered when the Minitel daemon receives an acknowledgement (type 2) packet.
#### net\_broadcast, *from*, *port*, *data*
This event is triggered when the Minitel daemon receives a broadcast (addressed to '~') packet of type 1 or 2.
#### net\_send, *packet type*, *to*, *port*, *data*, *packet ID*
This event can be queued (with computer.pushSignal) to manually build packets. While you should never need to use this, it may be useful for certain edge cases.
2018-08-11 13:54:25 +10:00
## Minitel library
2018-02-17 16:15:11 +11:00
2018-08-11 13:54:25 +10:00
The minitel library provides an easy way of interacting with the minitel daemon, and implements higher-level features of the stack.
2018-02-17 16:15:11 +11:00
### API
#### Layer 3
2018-08-11 13:54:25 +10:00
*minitel.genPacketID()* - returns a string of random data
2018-02-17 16:15:11 +11:00
2018-08-11 13:54:25 +10:00
*minitel.usend(host, port, data, pid)* - Sends an unreliable packet to *host* on *port* containing *data* , optionally with the packet ID *pid* .
2018-02-17 16:15:11 +11:00
2018-08-11 13:54:25 +10:00
*minitel.rsend(host, port, data, block)* - Sends a reliable packet to *host* on *port* containing *data* . If *block* is true, don't wait for a reply.
2018-02-17 16:15:11 +11:00
#### Layer 4
2018-08-11 13:54:25 +10:00
*minitel.send(host, port, data)* - Sends *data* reliably and in order to *host* on *port* .
2018-02-17 16:15:11 +11:00
#### Layer 5
2018-08-11 13:54:25 +10:00
*minitel.open(to,port)* - Establishes a stream to *host* on *port* and returns a stream object
2018-02-17 16:15:11 +11:00
2018-08-11 13:54:25 +10:00
*minitel.listen(port)* - Waits for another node to establish a stream, and returns the stream object.
2018-02-17 16:15:11 +11:00
#### Stream objects
*stream:write(data)* - Sends *data* to the node at the other end of the stream
2018-08-16 20:54:23 +10:00
*stream:read(length)* - Reads data from the stream, in several modes:
- If you pass *length* as a number, up to *length* bytes will be read from the socket.
- If *length* == "\*a", everything in the buffer will be returned.
- If you pass *length* as any other string, and there is *length* in the buffer somewhere, the data up to *length* in the buffer will be returned. This ignores all but the first character.
- If *length* is nil, it will read up until the next newline.
2018-02-17 16:15:11 +11:00
*stream:close()* - Ends the stream and prevents further writing.
#### Variables
2018-08-11 13:54:25 +10:00
*minitel.mtu = 4096* - The maximum length of the data portion of a packet for *minitel.send*
2018-02-17 16:15:11 +11:00
2018-08-11 13:54:25 +10:00
*minitel.streamdelay = 60* - The time, in seconds, *minitel.open* will wait for a response while trying to establish a connection.
2018-02-17 16:15:11 +11:00
2018-08-11 13:54:25 +10:00
*minitel.minport = 32768* - The lowest port *minitel.listen* will allocate to a new connection.
2018-02-17 16:15:11 +11:00
2018-08-11 13:54:25 +10:00
*minitel.maxport = 65535* - The highest port *minitel.listen* will allocate to a new connection.