mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-12-23 03:11:49 +01:00
Replace brony with tcp table
This commit is contained in:
parent
10d7ed6217
commit
c21aa5439e
BIN
data/banner.bin
BIN
data/banner.bin
Binary file not shown.
BIN
gfx/banner.png
BIN
gfx/banner.png
Binary file not shown.
Before Width: | Height: | Size: 87 KiB |
@ -1,4 +1,6 @@
|
||||
#include "console.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
@ -9,10 +11,10 @@
|
||||
#include "gfx.h"
|
||||
|
||||
#ifdef _3DS
|
||||
#include "banner_bin.h"
|
||||
|
||||
static PrintConsole status_console;
|
||||
static PrintConsole main_console;
|
||||
static PrintConsole tcp_console;
|
||||
|
||||
/*! initialize console subsystem */
|
||||
void
|
||||
@ -24,6 +26,8 @@ console_init(void)
|
||||
consoleInit(GFX_TOP, &main_console);
|
||||
consoleSetWindow(&main_console, 0, 1, 50, 29);
|
||||
|
||||
consoleInit(GFX_BOTTOM, &tcp_console);
|
||||
|
||||
consoleSelect(&main_console);
|
||||
|
||||
consoleDebugInit(debugDevice_NULL);
|
||||
@ -63,12 +67,71 @@ console_print(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*! print tcp tables */
|
||||
static void
|
||||
print_tcp_table(void)
|
||||
{
|
||||
static SOCU_TCPTableEntry tcp_entries[32];
|
||||
socklen_t optlen;
|
||||
size_t i;
|
||||
int rc;
|
||||
|
||||
consoleSelect(&tcp_console);
|
||||
console_print("\x1b[0;0H\x1b[K\n");
|
||||
optlen = sizeof(tcp_entries);
|
||||
rc = SOCU_GetNetworkOpt(0xFFFE, NETOPT_TCP_TABLE, tcp_entries, &optlen);
|
||||
if(rc != 0 && errno != ENODEV)
|
||||
console_print(RED "tcp table: %d %s\x1b[K\n" RESET, errno, strerror(errno));
|
||||
else if(rc == 0)
|
||||
{
|
||||
for(i = 0; i < optlen / sizeof(SOCU_TCPTableEntry); ++i)
|
||||
{
|
||||
SOCU_TCPTableEntry *entry = &tcp_entries[i];
|
||||
struct sockaddr_in *local = (struct sockaddr_in*)&entry->local;
|
||||
struct sockaddr_in *remote = (struct sockaddr_in*)&entry->remote;
|
||||
|
||||
console_print(GREEN "tcp[%zu]: ", i);
|
||||
switch(entry->state)
|
||||
{
|
||||
case TCP_STATE_CLOSED:
|
||||
console_print("CLOSED\x1b[K\n"); break;
|
||||
case TCP_STATE_LISTEN:
|
||||
console_print("LISTEN\x1b[K\n"); break;
|
||||
case TCP_STATE_ESTABLISHED:
|
||||
console_print("ESTABLISHED\x1b[K\n"); break;
|
||||
case TCP_STATE_FINWAIT1:
|
||||
console_print("FINWAIT1\x1b[K\n"); break;
|
||||
case TCP_STATE_FINWAIT2:
|
||||
console_print("FINWAIT2\x1b[K\n"); break;
|
||||
case TCP_STATE_CLOSE_WAIT:
|
||||
console_print("CLOSE_WAIT\x1b[K\n"); break;
|
||||
case TCP_STATE_LAST_ACK:
|
||||
console_print("LAST_ACK\x1b[K\n"); break;
|
||||
case TCP_STATE_TIME_WAIT:
|
||||
console_print("TIME_WAIT\x1b[K\n"); break;
|
||||
default:
|
||||
console_print("State %lu\x1b[K\n", entry->state); break;
|
||||
}
|
||||
|
||||
console_print(" Local %s:%u\x1b[K\n", inet_ntoa(local->sin_addr),
|
||||
ntohs(local->sin_port));
|
||||
console_print(" Peer %s:%u\x1b[K\n", inet_ntoa(remote->sin_addr),
|
||||
ntohs(remote->sin_port));
|
||||
console_print(RESET "\x1b[J");
|
||||
}
|
||||
}
|
||||
else
|
||||
console_print("\x1b[2J");
|
||||
|
||||
consoleSelect(&main_console);
|
||||
}
|
||||
|
||||
/*! draw console to screen */
|
||||
void
|
||||
console_render(void)
|
||||
{
|
||||
/* clear all screens */
|
||||
gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)banner_bin, 240, 320, 0, 0);
|
||||
/* print tcp table */
|
||||
print_tcp_table();
|
||||
|
||||
/* flush framebuffer */
|
||||
gfxFlushBuffers();
|
||||
|
@ -1587,6 +1587,7 @@ ftp_exit(void)
|
||||
|
||||
#ifdef _3DS
|
||||
/* deinitialize SOC service */
|
||||
console_render();
|
||||
console_print(CYAN "Waiting for socExit()...\n" RESET);
|
||||
ret = socExit();
|
||||
if(ret != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user