mirror of
https://github.com/ksherlock/tcpsnooper.git
synced 2024-12-22 02:29:52 +00:00
clang-format
This commit is contained in:
parent
a4a81fbe4d
commit
e064126d90
185
ifconfig.c
185
ifconfig.c
@ -1,130 +1,111 @@
|
|||||||
#include <Locator.h>
|
#include <Locator.h>
|
||||||
#include <tcpip.h>
|
|
||||||
#include <TextTool.h>
|
#include <TextTool.h>
|
||||||
|
#include <tcpip.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ifconfig [ up | down | status ]
|
* ifconfig [ up | down | status ]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* callback by Marinetti to display a connect message
|
* callback by Marinetti to display a connect message
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void display(const char *pstr)
|
void display(const char *pstr) { WriteLine(pstr); }
|
||||||
{
|
|
||||||
WriteLine(pstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo - support flags
|
// todo - support flags
|
||||||
// -s: be silent (ie - no output, return value only
|
// -s: be silent (ie - no output, return value only
|
||||||
// -f: force disconnect
|
// -f: force disconnect
|
||||||
//
|
//
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
LongWord address;
|
||||||
LongWord address;
|
char buffer[16];
|
||||||
char buffer[16];
|
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2) {
|
||||||
{
|
WriteCString("Usage: ifconfig [ up | down | status ]\n\r");
|
||||||
WriteCString("Usage: ifconfig [ up | down | status ]\n\r");
|
WriteCString(" up Connects to network\n\r");
|
||||||
WriteCString(" up Connects to network\n\r");
|
WriteCString(" down Disconnects from network\n\r");
|
||||||
WriteCString(" down Disconnects from network\n\r");
|
WriteCString(" status Queries status\n\r");
|
||||||
WriteCString(" status Queries status\n\r");
|
exit(1);
|
||||||
exit(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(argv[1], "up"))
|
if (!strcmp(argv[1], "up")) {
|
||||||
{
|
|
||||||
|
|
||||||
TCPIPStatus();
|
TCPIPStatus();
|
||||||
if (_toolErr)
|
if (_toolErr) {
|
||||||
{
|
LoadOneTool(54, 0x0200);
|
||||||
LoadOneTool(54, 0x0200);
|
if (_toolErr) {
|
||||||
if (_toolErr)
|
ErrWriteCString("Unable to load Marinetti\r\n");
|
||||||
{
|
exit(1);
|
||||||
ErrWriteCString("Unable to load Marinetti\r\n");
|
}
|
||||||
exit(1);
|
}
|
||||||
}
|
// acedemic only - TCPStartup() just for show.
|
||||||
}
|
if (!TCPIPStatus()) {
|
||||||
// acedemic only - TCPStartup() just for show.
|
TCPIPStartUp();
|
||||||
if (!TCPIPStatus())
|
}
|
||||||
{
|
if (TCPIPGetConnectStatus()) {
|
||||||
TCPIPStartUp();
|
ErrWriteCString("Already connected to network\r\n");
|
||||||
}
|
exit(0);
|
||||||
if (TCPIPGetConnectStatus())
|
}
|
||||||
{
|
TCPIPConnect(display);
|
||||||
ErrWriteCString("Already connected to network\r\n");
|
if (_toolErr) {
|
||||||
exit(0);
|
ErrWriteCString("Error connecting to network\r\n");
|
||||||
}
|
exit(1);
|
||||||
TCPIPConnect(display);
|
}
|
||||||
if (_toolErr)
|
WriteCString("Connected to network\r\n");
|
||||||
{
|
WriteCString("IP Address is: ");
|
||||||
ErrWriteCString("Error connecting to network\r\n");
|
address = TCPIPGetMyIPAddress();
|
||||||
exit(1);
|
TCPIPConvertIPToCASCII(address, buffer, 0);
|
||||||
}
|
WriteCString(buffer);
|
||||||
WriteCString("Connected to network\r\n");
|
WriteCString("\r\n");
|
||||||
WriteCString("IP Address is: ");
|
exit(0);
|
||||||
address = TCPIPGetMyIPAddress();
|
}
|
||||||
TCPIPConvertIPToCASCII(address, buffer, 0);
|
|
||||||
WriteCString(buffer);
|
|
||||||
WriteCString("\r\n");
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(argv[1], "down"))
|
if (!strcmp(argv[1], "down")) {
|
||||||
{
|
// if tool isn't loaded, we're already down...
|
||||||
// if tool isn't loaded, we're already down...
|
TCPIPStatus();
|
||||||
TCPIPStatus();
|
if (_toolErr) {
|
||||||
if (_toolErr)
|
ErrWriteCString("Marinetti not loaded\r\n");
|
||||||
{
|
exit(0);
|
||||||
ErrWriteCString("Marinetti not loaded\r\n");
|
}
|
||||||
exit(0);
|
if (!TCPIPGetConnectStatus()) {
|
||||||
}
|
ErrWriteCString("Not connected to network\r\n");
|
||||||
if (!TCPIPGetConnectStatus())
|
exit(0);
|
||||||
{
|
}
|
||||||
ErrWriteCString("Not connected to network\r\n");
|
// todo - flag to force up & down
|
||||||
exit(0);
|
TCPIPDisconnect(true, display);
|
||||||
}
|
|
||||||
// todo - flag to force up & down
|
|
||||||
TCPIPDisconnect(true, display);
|
|
||||||
|
|
||||||
WriteCString("Disconnected from network\r\n");
|
WriteCString("Disconnected from network\r\n");
|
||||||
//UnloadOneTool(54);
|
// UnloadOneTool(54);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[1], "status"))
|
if (!strcmp(argv[1], "status")) {
|
||||||
{
|
// if tool isn't loaded, we're already down...
|
||||||
// if tool isn't loaded, we're already down...
|
TCPIPStatus();
|
||||||
TCPIPStatus();
|
if (_toolErr) {
|
||||||
if (_toolErr)
|
WriteCString("Network is down\r\n");
|
||||||
{
|
exit(1);
|
||||||
WriteCString("Network is down\r\n");
|
}
|
||||||
exit(1);
|
if (!TCPIPGetConnectStatus()) {
|
||||||
}
|
WriteCString("Network is down\r\n");
|
||||||
if (!TCPIPGetConnectStatus())
|
exit(1);
|
||||||
{
|
}
|
||||||
WriteCString("Network is down\r\n");
|
WriteCString("Network is up\r\n");
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
WriteCString("Network is up\r\n");
|
|
||||||
|
|
||||||
WriteCString("IP Address is: ");
|
|
||||||
address = TCPIPGetMyIPAddress();
|
|
||||||
TCPIPConvertIPToCASCII(address, buffer, 0);
|
|
||||||
WriteCString(buffer);
|
|
||||||
WriteCString("\r\n");
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrWriteCString("illegal option -- ");
|
WriteCString("IP Address is: ");
|
||||||
ErrWriteCString(argv[1]);
|
address = TCPIPGetMyIPAddress();
|
||||||
ErrWriteCString("\r\n");
|
TCPIPConvertIPToCASCII(address, buffer, 0);
|
||||||
exit (1);
|
WriteCString(buffer);
|
||||||
|
WriteCString("\r\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrWriteCString("illegal option -- ");
|
||||||
|
ErrWriteCString(argv[1]);
|
||||||
|
ErrWriteCString("\r\n");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user