mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 09:21:09 +02:00
imageinfo_ni: Make interface and network speed configurable
Required for generic hardware
Origin commit data
------------------
Branch: ni/coolstream
Commit: 938cde230d
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2016-09-24 (Sat, 24 Sep 2016)
Origin message was:
------------------
imageinfo_ni: Make interface and network speed configurable
Required for generic hardware
------------------
This commit was generated by Migit
This commit is contained in:
committed by
vanhofen
parent
c4a6b4ce10
commit
8eb8363f97
@@ -128,6 +128,9 @@ void CImageInfoNI::Init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
offset = offset + 15;
|
offset = offset + 15;
|
||||||
|
|
||||||
|
netIfName = "eth0";
|
||||||
|
netMaxBit = 104857600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CImageInfoNI::~CImageInfoNI()
|
CImageInfoNI::~CImageInfoNI()
|
||||||
@@ -702,11 +705,13 @@ void CImageInfoNI::get_NET_Info(uint64_t *read_akt, long *read_packet, long *dum
|
|||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char *line_buffer = NULL;
|
char *line_buffer = NULL;
|
||||||
char interface[20] = "eth0";
|
|
||||||
long *packet_ptr[3] = {read_packet, write_packet, dummy};
|
long *packet_ptr[3] = {read_packet, write_packet, dummy};
|
||||||
uint64_t *byte_ptr[2] = {read_akt, write_akt};
|
uint64_t *byte_ptr[2] = {read_akt, write_akt};
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
char interface[20];
|
||||||
|
memset(interface, '\0', sizeof(interface));
|
||||||
|
snprintf(interface, sizeof(interface)-1, "%s", netIfName.c_str());
|
||||||
|
|
||||||
if ((file = fopen("/proc/net/dev","r"))==NULL)
|
if ((file = fopen("/proc/net/dev","r"))==NULL)
|
||||||
{
|
{
|
||||||
@@ -741,8 +746,10 @@ void CImageInfoNI::get_NET_Info(uint64_t *read_akt, long *read_packet, long *dum
|
|||||||
|
|
||||||
void CImageInfoNI::paint_NET_Info(int posx, int posy)
|
void CImageInfoNI::paint_NET_Info(int posx, int posy)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_GENERIC_HARDWARE
|
||||||
if (g_settings.ifname != "eth0")
|
if (g_settings.ifname != "eth0")
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t read_akt =0;
|
uint64_t read_akt =0;
|
||||||
uint64_t write_akt =0;
|
uint64_t write_akt =0;
|
||||||
@@ -796,12 +803,16 @@ void CImageInfoNI::paint_NET_Info(int posx, int posy)
|
|||||||
* 13107200 Byte
|
* 13107200 Byte
|
||||||
* 104857600 Bit
|
* 104857600 Bit
|
||||||
*/
|
*/
|
||||||
#ifdef BOXMODEL_APOLLO
|
#ifdef HAVE_GENERIC_HARDWARE
|
||||||
|
int max_bit = netMaxBit; /* PC */
|
||||||
|
#else
|
||||||
|
# ifdef BOXMODEL_APOLLO
|
||||||
int max_bit = 104857600; /* Shiner, Kronos */
|
int max_bit = 104857600; /* Shiner, Kronos */
|
||||||
if (cs_get_revision() == 9)
|
if (cs_get_revision() == 9)
|
||||||
max_bit = 1073741824; /* Apollo */
|
max_bit = 1073741824; /* Apollo */
|
||||||
#else
|
# else ifdef
|
||||||
int max_bit = 104857600;
|
int max_bit = 104857600;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
int percent = ((rbit_s+wbit_s)*100/max_bit);
|
int percent = ((rbit_s+wbit_s)*100/max_bit);
|
||||||
|
|
||||||
@@ -820,7 +831,7 @@ void CImageInfoNI::paint_NET_Info(int posx, int posy)
|
|||||||
(int)(net_best*100/max_bit)
|
(int)(net_best*100/max_bit)
|
||||||
);
|
);
|
||||||
|
|
||||||
sprintf(temp_string,"Interface eth0 (%d%%):",percent);
|
sprintf(temp_string,"Interface %s (%d%%):", netIfName.c_str(), percent);
|
||||||
// progressbar ist in same line - so we not can use max_text_width
|
// progressbar ist in same line - so we not can use max_text_width
|
||||||
frameBuffer->paintBoxRel(posx-10,posy-sheight,boxX-posx+10,sheight, COL_INFOBAR_PLUS_0);
|
frameBuffer->paintBoxRel(posx-10,posy-sheight,boxX-posx+10,sheight, COL_INFOBAR_PLUS_0);
|
||||||
g_Font[font_small]->RenderString(posx, posy, boxX-posx, temp_string, COL_INFOBAR_TEXT);
|
g_Font[font_small]->RenderString(posx, posy, boxX-posx, temp_string, COL_INFOBAR_TEXT);
|
||||||
|
@@ -57,6 +57,8 @@ class CImageInfoNI : public CMenuTarget
|
|||||||
int font_head;
|
int font_head;
|
||||||
int font_info;
|
int font_info;
|
||||||
int font_small;
|
int font_small;
|
||||||
|
std::string netIfName;
|
||||||
|
int netMaxBit;
|
||||||
|
|
||||||
void paint();
|
void paint();
|
||||||
void paint_pig(int x, int y, int w, int h);
|
void paint_pig(int x, int y, int w, int h);
|
||||||
|
Reference in New Issue
Block a user