mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 01:25:33 -07:00
Merge pull request #6794 from chungy/switch-secrets
Local switch shared secrets
This commit is contained in:
14
src/config.c
14
src/config.c
@@ -910,10 +910,10 @@ load_network(void)
|
||||
nc->slirp_net[0] = '\0';
|
||||
}
|
||||
|
||||
sprintf(temp, "net_%02i_switch_group", c + 1);
|
||||
nc->switch_group = ini_section_get_int(cat, temp, NET_SWITCH_GRP_MIN);
|
||||
if (nc->switch_group < NET_SWITCH_GRP_MIN)
|
||||
nc->switch_group = NET_SWITCH_GRP_MIN;
|
||||
sprintf(temp, "net_%02i_secret", c + 1);
|
||||
p = ini_section_get_string(cat, temp, NULL);
|
||||
strncpy(nc->secret, p ? p : "", sizeof(nc->secret) - 1);
|
||||
nc->secret[sizeof(net_cards_conf[c].secret) - 1] = '\0';
|
||||
|
||||
sprintf(temp, "net_%02i_promisc", c + 1);
|
||||
nc->promisc_mode = ini_section_get_int(cat, temp, 0);
|
||||
@@ -3019,11 +3019,11 @@ save_network(void)
|
||||
ini_section_delete_var(cat, temp);
|
||||
}
|
||||
|
||||
sprintf(temp, "net_%02i_switch_group", c + 1);
|
||||
if (nc->switch_group == NET_SWITCH_GRP_MIN)
|
||||
sprintf(temp, "net_%02i_secret", c + 1);
|
||||
if (nc->secret[0] == '\0')
|
||||
ini_section_delete_var(cat, temp);
|
||||
else
|
||||
ini_section_set_int(cat, temp, nc->switch_group);
|
||||
ini_section_set_string(cat, temp, net_cards_conf[c].secret);
|
||||
|
||||
sprintf(temp, "net_%02i_promisc", c + 1);
|
||||
if (nc->promisc_mode == 0)
|
||||
|
||||
@@ -60,8 +60,6 @@
|
||||
#define NET_QUEUE_COUNT 4
|
||||
#define NET_CARD_MAX 4
|
||||
#define NET_HOST_INTF_MAX 64
|
||||
#define NET_SWITCH_GRP_MIN 1
|
||||
#define NET_SWITCH_GRP_MAX 10
|
||||
|
||||
#define NET_PERIOD_10M 0.8
|
||||
#define NET_PERIOD_100M 0.08
|
||||
@@ -97,7 +95,7 @@ typedef struct netcard_conf_t {
|
||||
int net_type;
|
||||
char host_dev_name[128];
|
||||
uint32_t link_state;
|
||||
uint8_t switch_group;
|
||||
char secret[256];
|
||||
uint8_t promisc_mode;
|
||||
char slirp_net[16];
|
||||
char nrs_hostname[128];
|
||||
|
||||
481
src/include/shathree.h
Normal file
481
src/include/shathree.h
Normal file
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
** This code is from SQLite
|
||||
** (https://sqlite.org/src/info/2025-02-27T21:17:55z), at file path
|
||||
** ext/misc/shathree.c. The SQLite functions have been removed, but
|
||||
** it is the same code written by D. Richard Hipp.
|
||||
*/
|
||||
|
||||
#ifndef SHATHREE_H
|
||||
|
||||
/*
|
||||
** 2017-03-08
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/******************************************************************************
|
||||
** The Hash Engine
|
||||
*/
|
||||
/*
|
||||
** Macros to determine whether the machine is big or little endian,
|
||||
** and whether or not that determination is run-time or compile-time.
|
||||
**
|
||||
** For best performance, an attempt is made to guess at the byte-order
|
||||
** using C-preprocessor macros. If that is unsuccessful, or if
|
||||
** -DSHA3_BYTEORDER=0 is set, then byte-order is determined
|
||||
** at run-time.
|
||||
*/
|
||||
#ifndef SHA3_BYTEORDER
|
||||
# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \
|
||||
defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \
|
||||
defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \
|
||||
defined(__arm__)
|
||||
# define SHA3_BYTEORDER 1234
|
||||
# elif defined(sparc) || defined(__ppc__)
|
||||
# define SHA3_BYTEORDER 4321
|
||||
# else
|
||||
# define SHA3_BYTEORDER 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define u64 uint64_t
|
||||
|
||||
|
||||
/*
|
||||
** State structure for a SHA3 hash in progress
|
||||
*/
|
||||
typedef struct SHA3Context SHA3Context;
|
||||
struct SHA3Context {
|
||||
union {
|
||||
u64 s[25]; /* Keccak state. 5x5 lines of 64 bits each */
|
||||
unsigned char x[1600]; /* ... or 1600 bytes */
|
||||
} u;
|
||||
unsigned nRate; /* Bytes of input accepted per Keccak iteration */
|
||||
unsigned nLoaded; /* Input bytes loaded into u.x[] so far this cycle */
|
||||
unsigned ixMask; /* Insert next input into u.x[nLoaded^ixMask]. */
|
||||
unsigned iSize; /* 224, 256, 358, or 512 */
|
||||
};
|
||||
|
||||
/*
|
||||
** A single step of the Keccak mixing function for a 1600-bit state
|
||||
*/
|
||||
static void KeccakF1600Step(SHA3Context *p){
|
||||
int i;
|
||||
u64 b0, b1, b2, b3, b4;
|
||||
u64 c0, c1, c2, c3, c4;
|
||||
u64 d0, d1, d2, d3, d4;
|
||||
static const u64 RC[] = {
|
||||
0x0000000000000001ULL, 0x0000000000008082ULL,
|
||||
0x800000000000808aULL, 0x8000000080008000ULL,
|
||||
0x000000000000808bULL, 0x0000000080000001ULL,
|
||||
0x8000000080008081ULL, 0x8000000000008009ULL,
|
||||
0x000000000000008aULL, 0x0000000000000088ULL,
|
||||
0x0000000080008009ULL, 0x000000008000000aULL,
|
||||
0x000000008000808bULL, 0x800000000000008bULL,
|
||||
0x8000000000008089ULL, 0x8000000000008003ULL,
|
||||
0x8000000000008002ULL, 0x8000000000000080ULL,
|
||||
0x000000000000800aULL, 0x800000008000000aULL,
|
||||
0x8000000080008081ULL, 0x8000000000008080ULL,
|
||||
0x0000000080000001ULL, 0x8000000080008008ULL
|
||||
};
|
||||
# define a00 (p->u.s[0])
|
||||
# define a01 (p->u.s[1])
|
||||
# define a02 (p->u.s[2])
|
||||
# define a03 (p->u.s[3])
|
||||
# define a04 (p->u.s[4])
|
||||
# define a10 (p->u.s[5])
|
||||
# define a11 (p->u.s[6])
|
||||
# define a12 (p->u.s[7])
|
||||
# define a13 (p->u.s[8])
|
||||
# define a14 (p->u.s[9])
|
||||
# define a20 (p->u.s[10])
|
||||
# define a21 (p->u.s[11])
|
||||
# define a22 (p->u.s[12])
|
||||
# define a23 (p->u.s[13])
|
||||
# define a24 (p->u.s[14])
|
||||
# define a30 (p->u.s[15])
|
||||
# define a31 (p->u.s[16])
|
||||
# define a32 (p->u.s[17])
|
||||
# define a33 (p->u.s[18])
|
||||
# define a34 (p->u.s[19])
|
||||
# define a40 (p->u.s[20])
|
||||
# define a41 (p->u.s[21])
|
||||
# define a42 (p->u.s[22])
|
||||
# define a43 (p->u.s[23])
|
||||
# define a44 (p->u.s[24])
|
||||
# define ROL64(a,x) ((a<<x)|(a>>(64-x)))
|
||||
|
||||
for(i=0; i<24; i+=4){
|
||||
c0 = a00^a10^a20^a30^a40;
|
||||
c1 = a01^a11^a21^a31^a41;
|
||||
c2 = a02^a12^a22^a32^a42;
|
||||
c3 = a03^a13^a23^a33^a43;
|
||||
c4 = a04^a14^a24^a34^a44;
|
||||
d0 = c4^ROL64(c1, 1);
|
||||
d1 = c0^ROL64(c2, 1);
|
||||
d2 = c1^ROL64(c3, 1);
|
||||
d3 = c2^ROL64(c4, 1);
|
||||
d4 = c3^ROL64(c0, 1);
|
||||
|
||||
b0 = (a00^d0);
|
||||
b1 = ROL64((a11^d1), 44);
|
||||
b2 = ROL64((a22^d2), 43);
|
||||
b3 = ROL64((a33^d3), 21);
|
||||
b4 = ROL64((a44^d4), 14);
|
||||
a00 = b0 ^((~b1)& b2 );
|
||||
a00 ^= RC[i];
|
||||
a11 = b1 ^((~b2)& b3 );
|
||||
a22 = b2 ^((~b3)& b4 );
|
||||
a33 = b3 ^((~b4)& b0 );
|
||||
a44 = b4 ^((~b0)& b1 );
|
||||
|
||||
b2 = ROL64((a20^d0), 3);
|
||||
b3 = ROL64((a31^d1), 45);
|
||||
b4 = ROL64((a42^d2), 61);
|
||||
b0 = ROL64((a03^d3), 28);
|
||||
b1 = ROL64((a14^d4), 20);
|
||||
a20 = b0 ^((~b1)& b2 );
|
||||
a31 = b1 ^((~b2)& b3 );
|
||||
a42 = b2 ^((~b3)& b4 );
|
||||
a03 = b3 ^((~b4)& b0 );
|
||||
a14 = b4 ^((~b0)& b1 );
|
||||
|
||||
b4 = ROL64((a40^d0), 18);
|
||||
b0 = ROL64((a01^d1), 1);
|
||||
b1 = ROL64((a12^d2), 6);
|
||||
b2 = ROL64((a23^d3), 25);
|
||||
b3 = ROL64((a34^d4), 8);
|
||||
a40 = b0 ^((~b1)& b2 );
|
||||
a01 = b1 ^((~b2)& b3 );
|
||||
a12 = b2 ^((~b3)& b4 );
|
||||
a23 = b3 ^((~b4)& b0 );
|
||||
a34 = b4 ^((~b0)& b1 );
|
||||
|
||||
b1 = ROL64((a10^d0), 36);
|
||||
b2 = ROL64((a21^d1), 10);
|
||||
b3 = ROL64((a32^d2), 15);
|
||||
b4 = ROL64((a43^d3), 56);
|
||||
b0 = ROL64((a04^d4), 27);
|
||||
a10 = b0 ^((~b1)& b2 );
|
||||
a21 = b1 ^((~b2)& b3 );
|
||||
a32 = b2 ^((~b3)& b4 );
|
||||
a43 = b3 ^((~b4)& b0 );
|
||||
a04 = b4 ^((~b0)& b1 );
|
||||
|
||||
b3 = ROL64((a30^d0), 41);
|
||||
b4 = ROL64((a41^d1), 2);
|
||||
b0 = ROL64((a02^d2), 62);
|
||||
b1 = ROL64((a13^d3), 55);
|
||||
b2 = ROL64((a24^d4), 39);
|
||||
a30 = b0 ^((~b1)& b2 );
|
||||
a41 = b1 ^((~b2)& b3 );
|
||||
a02 = b2 ^((~b3)& b4 );
|
||||
a13 = b3 ^((~b4)& b0 );
|
||||
a24 = b4 ^((~b0)& b1 );
|
||||
|
||||
c0 = a00^a20^a40^a10^a30;
|
||||
c1 = a11^a31^a01^a21^a41;
|
||||
c2 = a22^a42^a12^a32^a02;
|
||||
c3 = a33^a03^a23^a43^a13;
|
||||
c4 = a44^a14^a34^a04^a24;
|
||||
d0 = c4^ROL64(c1, 1);
|
||||
d1 = c0^ROL64(c2, 1);
|
||||
d2 = c1^ROL64(c3, 1);
|
||||
d3 = c2^ROL64(c4, 1);
|
||||
d4 = c3^ROL64(c0, 1);
|
||||
|
||||
b0 = (a00^d0);
|
||||
b1 = ROL64((a31^d1), 44);
|
||||
b2 = ROL64((a12^d2), 43);
|
||||
b3 = ROL64((a43^d3), 21);
|
||||
b4 = ROL64((a24^d4), 14);
|
||||
a00 = b0 ^((~b1)& b2 );
|
||||
a00 ^= RC[i+1];
|
||||
a31 = b1 ^((~b2)& b3 );
|
||||
a12 = b2 ^((~b3)& b4 );
|
||||
a43 = b3 ^((~b4)& b0 );
|
||||
a24 = b4 ^((~b0)& b1 );
|
||||
|
||||
b2 = ROL64((a40^d0), 3);
|
||||
b3 = ROL64((a21^d1), 45);
|
||||
b4 = ROL64((a02^d2), 61);
|
||||
b0 = ROL64((a33^d3), 28);
|
||||
b1 = ROL64((a14^d4), 20);
|
||||
a40 = b0 ^((~b1)& b2 );
|
||||
a21 = b1 ^((~b2)& b3 );
|
||||
a02 = b2 ^((~b3)& b4 );
|
||||
a33 = b3 ^((~b4)& b0 );
|
||||
a14 = b4 ^((~b0)& b1 );
|
||||
|
||||
b4 = ROL64((a30^d0), 18);
|
||||
b0 = ROL64((a11^d1), 1);
|
||||
b1 = ROL64((a42^d2), 6);
|
||||
b2 = ROL64((a23^d3), 25);
|
||||
b3 = ROL64((a04^d4), 8);
|
||||
a30 = b0 ^((~b1)& b2 );
|
||||
a11 = b1 ^((~b2)& b3 );
|
||||
a42 = b2 ^((~b3)& b4 );
|
||||
a23 = b3 ^((~b4)& b0 );
|
||||
a04 = b4 ^((~b0)& b1 );
|
||||
|
||||
b1 = ROL64((a20^d0), 36);
|
||||
b2 = ROL64((a01^d1), 10);
|
||||
b3 = ROL64((a32^d2), 15);
|
||||
b4 = ROL64((a13^d3), 56);
|
||||
b0 = ROL64((a44^d4), 27);
|
||||
a20 = b0 ^((~b1)& b2 );
|
||||
a01 = b1 ^((~b2)& b3 );
|
||||
a32 = b2 ^((~b3)& b4 );
|
||||
a13 = b3 ^((~b4)& b0 );
|
||||
a44 = b4 ^((~b0)& b1 );
|
||||
|
||||
b3 = ROL64((a10^d0), 41);
|
||||
b4 = ROL64((a41^d1), 2);
|
||||
b0 = ROL64((a22^d2), 62);
|
||||
b1 = ROL64((a03^d3), 55);
|
||||
b2 = ROL64((a34^d4), 39);
|
||||
a10 = b0 ^((~b1)& b2 );
|
||||
a41 = b1 ^((~b2)& b3 );
|
||||
a22 = b2 ^((~b3)& b4 );
|
||||
a03 = b3 ^((~b4)& b0 );
|
||||
a34 = b4 ^((~b0)& b1 );
|
||||
|
||||
c0 = a00^a40^a30^a20^a10;
|
||||
c1 = a31^a21^a11^a01^a41;
|
||||
c2 = a12^a02^a42^a32^a22;
|
||||
c3 = a43^a33^a23^a13^a03;
|
||||
c4 = a24^a14^a04^a44^a34;
|
||||
d0 = c4^ROL64(c1, 1);
|
||||
d1 = c0^ROL64(c2, 1);
|
||||
d2 = c1^ROL64(c3, 1);
|
||||
d3 = c2^ROL64(c4, 1);
|
||||
d4 = c3^ROL64(c0, 1);
|
||||
|
||||
b0 = (a00^d0);
|
||||
b1 = ROL64((a21^d1), 44);
|
||||
b2 = ROL64((a42^d2), 43);
|
||||
b3 = ROL64((a13^d3), 21);
|
||||
b4 = ROL64((a34^d4), 14);
|
||||
a00 = b0 ^((~b1)& b2 );
|
||||
a00 ^= RC[i+2];
|
||||
a21 = b1 ^((~b2)& b3 );
|
||||
a42 = b2 ^((~b3)& b4 );
|
||||
a13 = b3 ^((~b4)& b0 );
|
||||
a34 = b4 ^((~b0)& b1 );
|
||||
|
||||
b2 = ROL64((a30^d0), 3);
|
||||
b3 = ROL64((a01^d1), 45);
|
||||
b4 = ROL64((a22^d2), 61);
|
||||
b0 = ROL64((a43^d3), 28);
|
||||
b1 = ROL64((a14^d4), 20);
|
||||
a30 = b0 ^((~b1)& b2 );
|
||||
a01 = b1 ^((~b2)& b3 );
|
||||
a22 = b2 ^((~b3)& b4 );
|
||||
a43 = b3 ^((~b4)& b0 );
|
||||
a14 = b4 ^((~b0)& b1 );
|
||||
|
||||
b4 = ROL64((a10^d0), 18);
|
||||
b0 = ROL64((a31^d1), 1);
|
||||
b1 = ROL64((a02^d2), 6);
|
||||
b2 = ROL64((a23^d3), 25);
|
||||
b3 = ROL64((a44^d4), 8);
|
||||
a10 = b0 ^((~b1)& b2 );
|
||||
a31 = b1 ^((~b2)& b3 );
|
||||
a02 = b2 ^((~b3)& b4 );
|
||||
a23 = b3 ^((~b4)& b0 );
|
||||
a44 = b4 ^((~b0)& b1 );
|
||||
|
||||
b1 = ROL64((a40^d0), 36);
|
||||
b2 = ROL64((a11^d1), 10);
|
||||
b3 = ROL64((a32^d2), 15);
|
||||
b4 = ROL64((a03^d3), 56);
|
||||
b0 = ROL64((a24^d4), 27);
|
||||
a40 = b0 ^((~b1)& b2 );
|
||||
a11 = b1 ^((~b2)& b3 );
|
||||
a32 = b2 ^((~b3)& b4 );
|
||||
a03 = b3 ^((~b4)& b0 );
|
||||
a24 = b4 ^((~b0)& b1 );
|
||||
|
||||
b3 = ROL64((a20^d0), 41);
|
||||
b4 = ROL64((a41^d1), 2);
|
||||
b0 = ROL64((a12^d2), 62);
|
||||
b1 = ROL64((a33^d3), 55);
|
||||
b2 = ROL64((a04^d4), 39);
|
||||
a20 = b0 ^((~b1)& b2 );
|
||||
a41 = b1 ^((~b2)& b3 );
|
||||
a12 = b2 ^((~b3)& b4 );
|
||||
a33 = b3 ^((~b4)& b0 );
|
||||
a04 = b4 ^((~b0)& b1 );
|
||||
|
||||
c0 = a00^a30^a10^a40^a20;
|
||||
c1 = a21^a01^a31^a11^a41;
|
||||
c2 = a42^a22^a02^a32^a12;
|
||||
c3 = a13^a43^a23^a03^a33;
|
||||
c4 = a34^a14^a44^a24^a04;
|
||||
d0 = c4^ROL64(c1, 1);
|
||||
d1 = c0^ROL64(c2, 1);
|
||||
d2 = c1^ROL64(c3, 1);
|
||||
d3 = c2^ROL64(c4, 1);
|
||||
d4 = c3^ROL64(c0, 1);
|
||||
|
||||
b0 = (a00^d0);
|
||||
b1 = ROL64((a01^d1), 44);
|
||||
b2 = ROL64((a02^d2), 43);
|
||||
b3 = ROL64((a03^d3), 21);
|
||||
b4 = ROL64((a04^d4), 14);
|
||||
a00 = b0 ^((~b1)& b2 );
|
||||
a00 ^= RC[i+3];
|
||||
a01 = b1 ^((~b2)& b3 );
|
||||
a02 = b2 ^((~b3)& b4 );
|
||||
a03 = b3 ^((~b4)& b0 );
|
||||
a04 = b4 ^((~b0)& b1 );
|
||||
|
||||
b2 = ROL64((a10^d0), 3);
|
||||
b3 = ROL64((a11^d1), 45);
|
||||
b4 = ROL64((a12^d2), 61);
|
||||
b0 = ROL64((a13^d3), 28);
|
||||
b1 = ROL64((a14^d4), 20);
|
||||
a10 = b0 ^((~b1)& b2 );
|
||||
a11 = b1 ^((~b2)& b3 );
|
||||
a12 = b2 ^((~b3)& b4 );
|
||||
a13 = b3 ^((~b4)& b0 );
|
||||
a14 = b4 ^((~b0)& b1 );
|
||||
|
||||
b4 = ROL64((a20^d0), 18);
|
||||
b0 = ROL64((a21^d1), 1);
|
||||
b1 = ROL64((a22^d2), 6);
|
||||
b2 = ROL64((a23^d3), 25);
|
||||
b3 = ROL64((a24^d4), 8);
|
||||
a20 = b0 ^((~b1)& b2 );
|
||||
a21 = b1 ^((~b2)& b3 );
|
||||
a22 = b2 ^((~b3)& b4 );
|
||||
a23 = b3 ^((~b4)& b0 );
|
||||
a24 = b4 ^((~b0)& b1 );
|
||||
|
||||
b1 = ROL64((a30^d0), 36);
|
||||
b2 = ROL64((a31^d1), 10);
|
||||
b3 = ROL64((a32^d2), 15);
|
||||
b4 = ROL64((a33^d3), 56);
|
||||
b0 = ROL64((a34^d4), 27);
|
||||
a30 = b0 ^((~b1)& b2 );
|
||||
a31 = b1 ^((~b2)& b3 );
|
||||
a32 = b2 ^((~b3)& b4 );
|
||||
a33 = b3 ^((~b4)& b0 );
|
||||
a34 = b4 ^((~b0)& b1 );
|
||||
|
||||
b3 = ROL64((a40^d0), 41);
|
||||
b4 = ROL64((a41^d1), 2);
|
||||
b0 = ROL64((a42^d2), 62);
|
||||
b1 = ROL64((a43^d3), 55);
|
||||
b2 = ROL64((a44^d4), 39);
|
||||
a40 = b0 ^((~b1)& b2 );
|
||||
a41 = b1 ^((~b2)& b3 );
|
||||
a42 = b2 ^((~b3)& b4 );
|
||||
a43 = b3 ^((~b4)& b0 );
|
||||
a44 = b4 ^((~b0)& b1 );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize a new hash. iSize determines the size of the hash
|
||||
** in bits and should be one of 224, 256, 384, or 512. Or iSize
|
||||
** can be zero to use the default hash size of 256 bits.
|
||||
*/
|
||||
static void SHA3Init(SHA3Context *p, int iSize){
|
||||
memset(p, 0, sizeof(*p));
|
||||
p->iSize = iSize;
|
||||
if( iSize>=128 && iSize<=512 ){
|
||||
p->nRate = (1600 - ((iSize + 31)&~31)*2)/8;
|
||||
}else{
|
||||
p->nRate = (1600 - 2*256)/8;
|
||||
}
|
||||
#if SHA3_BYTEORDER==1234
|
||||
/* Known to be little-endian at compile-time. No-op */
|
||||
#elif SHA3_BYTEORDER==4321
|
||||
p->ixMask = 7; /* Big-endian */
|
||||
#else
|
||||
{
|
||||
static unsigned int one = 1;
|
||||
if( 1==*(unsigned char*)&one ){
|
||||
/* Little endian. No byte swapping. */
|
||||
p->ixMask = 0;
|
||||
}else{
|
||||
/* Big endian. Byte swap. */
|
||||
p->ixMask = 7;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** Make consecutive calls to the SHA3Update function to add new content
|
||||
** to the hash
|
||||
*/
|
||||
static void SHA3Update(
|
||||
SHA3Context *p,
|
||||
const unsigned char *aData,
|
||||
unsigned int nData
|
||||
){
|
||||
unsigned int i = 0;
|
||||
if( aData==0 ) return;
|
||||
#if SHA3_BYTEORDER==1234
|
||||
if( (p->nLoaded % 8)==0 && ((aData - (const unsigned char*)0)&7)==0 ){
|
||||
for(; i+7<nData; i+=8){
|
||||
p->u.s[p->nLoaded/8] ^= *(u64*)&aData[i];
|
||||
p->nLoaded += 8;
|
||||
if( p->nLoaded>=p->nRate ){
|
||||
KeccakF1600Step(p);
|
||||
p->nLoaded = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for(; i<nData; i++){
|
||||
#if SHA3_BYTEORDER==1234
|
||||
p->u.x[p->nLoaded] ^= aData[i];
|
||||
#elif SHA3_BYTEORDER==4321
|
||||
p->u.x[p->nLoaded^0x07] ^= aData[i];
|
||||
#else
|
||||
p->u.x[p->nLoaded^p->ixMask] ^= aData[i];
|
||||
#endif
|
||||
p->nLoaded++;
|
||||
if( p->nLoaded==p->nRate ){
|
||||
KeccakF1600Step(p);
|
||||
p->nLoaded = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** After all content has been added, invoke SHA3Final() to compute
|
||||
** the final hash. The function returns a pointer to the binary
|
||||
** hash value.
|
||||
*/
|
||||
static unsigned char *SHA3Final(SHA3Context *p){
|
||||
unsigned int i;
|
||||
if( p->nLoaded==p->nRate-1 ){
|
||||
const unsigned char c1 = 0x86;
|
||||
SHA3Update(p, &c1, 1);
|
||||
}else{
|
||||
const unsigned char c2 = 0x06;
|
||||
const unsigned char c3 = 0x80;
|
||||
SHA3Update(p, &c2, 1);
|
||||
p->nLoaded = p->nRate - 1;
|
||||
SHA3Update(p, &c3, 1);
|
||||
}
|
||||
for(i=0; i<p->nRate; i++){
|
||||
p->u.x[i+p->nRate] = p->u.x[i^p->ixMask];
|
||||
}
|
||||
return &p->u.x[p->nRate];
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -49,10 +49,11 @@
|
||||
#include <86box/config.h>
|
||||
#include <86box/net_event.h>
|
||||
#include <86box/bswap.h>
|
||||
#include <shathree.h>
|
||||
|
||||
#define SWITCH_PKT_BATCH NET_QUEUE_LEN
|
||||
|
||||
#define SWITCH_MULTICAST_GROUP 0xefff5656 /* 239.255.86.86 */
|
||||
#define SWITCH_MULTICAST_GROUP 0xefff5056 /* 239.255.80.86 */
|
||||
#define SWITCH_MULTICAST_PORT 8086
|
||||
|
||||
enum {
|
||||
@@ -80,6 +81,7 @@ typedef struct net_switch_t {
|
||||
net_switch_hostaddr_t *hostaddrs;
|
||||
uint16_t port_out;
|
||||
|
||||
uint8_t secret_hash[32];
|
||||
uint8_t promisc;
|
||||
union {
|
||||
uint8_t mac_addr[6];
|
||||
@@ -123,6 +125,15 @@ net_switch_in_available(void *priv)
|
||||
net_event_set(&netswitch->tx_event);
|
||||
}
|
||||
|
||||
static void
|
||||
net_switch_secret_hash(const char *secret, uint8_t *hash)
|
||||
{
|
||||
SHA3Context cx;
|
||||
SHA3Init(&cx, 256);
|
||||
SHA3Update(&cx, (const uint8_t *)secret, strlen(secret));
|
||||
memcpy(hash, SHA3Final(&cx), 32);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
net_switch_add_hostaddr(net_switch_t *netswitch, net_switch_sockaddr_t *addr, net_switch_sockaddr_t *broadcast, net_switch_sockaddr_t *netmask, unsigned int flags)
|
||||
{
|
||||
@@ -374,15 +385,30 @@ net_switch_thread(void *priv)
|
||||
packets = network_tx_popv(netswitch->card, netswitch->pkt_tx_v, SWITCH_PKT_BATCH);
|
||||
if (!(net_cards_conf[netswitch->card->card_num].link_state & NET_LINK_DOWN)) {
|
||||
for (int i = 0; i < packets; i++) {
|
||||
int orig_len = netswitch->pkt_tx_v[i].len;
|
||||
int send_len = orig_len + 32;
|
||||
|
||||
if (send_len > NET_MAX_FRAME) {
|
||||
netswitch_log("Network Switch: packet too large to add header (%d bytes)\n",
|
||||
orig_len);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Prepend secret hash data */
|
||||
memmove(netswitch->pkt_tx_v[i].data + 32,
|
||||
netswitch->pkt_tx_v[i].data,
|
||||
orig_len);
|
||||
memcpy(netswitch->pkt_tx_v[i].data, netswitch->secret_hash, 32);
|
||||
|
||||
#define MAC_FORMAT "(%02X:%02X:%02X:%02X:%02X:%02X -> %02X:%02X:%02X:%02X:%02X:%02X)"
|
||||
#define MAC_FORMAT_ARGS(p) (p)[6], (p)[7], (p)[8], (p)[9], (p)[10], (p)[11], (p)[0], (p)[1], (p)[2], (p)[3], (p)[4], (p)[5]
|
||||
#define MAC_FORMAT_ARGS(p) (p)[38], (p)[39], (p)[40], (p)[41], (p)[42], (p)[43], (p)[32], (p)[33], (p)[34], (p)[35], (p)[36], (p)[37]
|
||||
netswitch_log("Network Switch: sending %d-byte packet " MAC_FORMAT "\n",
|
||||
netswitch->pkt_tx_v[i].len, MAC_FORMAT_ARGS(netswitch->pkt_tx_v[i].data));
|
||||
|
||||
/* Send through all known host interfaces. */
|
||||
for (net_switch_hostaddr_t *hostaddr = netswitch->hostaddrs; hostaddr; hostaddr = hostaddr->next)
|
||||
sendto(hostaddr->socket_tx,
|
||||
(char *) netswitch->pkt_tx_v[i].data, netswitch->pkt_tx_v[i].len, 0,
|
||||
(char *) netswitch->pkt_tx_v[i].data, send_len, 0,
|
||||
&hostaddr->addr_tx.sa, sizeof(hostaddr->addr_tx.sa));
|
||||
}
|
||||
}
|
||||
@@ -407,9 +433,18 @@ net_switch_thread(void *priv)
|
||||
if (pfd[NET_EVENT_RX].revents & POLLIN) {
|
||||
#endif
|
||||
len = recv(netswitch->socket_rx, (char *) netswitch->pkt.data, NET_MAX_FRAME, 0);
|
||||
if (len < 12) {
|
||||
if (len < 44) {
|
||||
netswitch_log("Network Switch: recv error (%d)\n", len);
|
||||
} else if ((AS_U64(netswitch->pkt.data[6]) & le64_to_cpu(0xffffffffffffULL)) == netswitch->mac_addr_u64) {
|
||||
}
|
||||
|
||||
if (memcmp(netswitch->pkt.data, netswitch->secret_hash, 32) != 0) {
|
||||
/* This packet contains a different secret hash, ignore it. */
|
||||
continue;
|
||||
} else {
|
||||
memmove(netswitch->pkt.data, netswitch->pkt.data + 32, len - 32);
|
||||
}
|
||||
|
||||
if ((AS_U64(netswitch->pkt.data[6]) & le64_to_cpu(0xffffffffffffULL)) == netswitch->mac_addr_u64) {
|
||||
/* A packet we've sent has looped back, drop it. */
|
||||
} else if (!(net_cards_conf[netswitch->card->card_num].link_state & NET_LINK_DOWN) && (netswitch->promisc || /* promiscuous mode? */
|
||||
(netswitch->pkt.data[0] & 1) || /* broadcast packet? */
|
||||
@@ -443,13 +478,17 @@ net_switch_init(const netcard_t *card, const uint8_t *mac_addr, void *priv, char
|
||||
{
|
||||
netcard_conf_t *netcard = (netcard_conf_t *) priv;
|
||||
|
||||
netswitch_log("Network Switch: initializing with group %d...\n", netcard->switch_group);
|
||||
|
||||
net_switch_t *netswitch = calloc(1, sizeof(net_switch_t));
|
||||
memcpy(netswitch->mac_addr, mac_addr, sizeof(netswitch->mac_addr));
|
||||
netswitch->card = (netcard_t *) card;
|
||||
netswitch->promisc = !!netcard->promisc_mode;
|
||||
|
||||
{
|
||||
uint8_t temp[32];
|
||||
net_switch_secret_hash((const uint8_t *)netcard->secret, (uint8_t *) temp);
|
||||
memcpy(netswitch->secret_hash, temp, 32);
|
||||
}
|
||||
|
||||
/* Initialize receive socket. */
|
||||
netswitch->socket_rx = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (netswitch->socket_rx < 0) {
|
||||
@@ -473,7 +512,7 @@ net_switch_init(const netcard_t *card, const uint8_t *mac_addr, void *priv, char
|
||||
val = 0;
|
||||
setsockopt(netswitch->socket_rx, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &val, sizeof(val));
|
||||
|
||||
netswitch->port_out = htons(SWITCH_MULTICAST_PORT - NET_SWITCH_GRP_MIN + netcard->switch_group);
|
||||
netswitch->port_out = htons(SWITCH_MULTICAST_PORT);
|
||||
struct sockaddr_in addr = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_addr = { .s_addr = htonl(INADDR_ANY) },
|
||||
|
||||
@@ -2832,7 +2832,7 @@ msgstr ""
|
||||
msgid "Remote Switch"
|
||||
msgstr ""
|
||||
|
||||
msgid "Switch:"
|
||||
msgid "Shared secret:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Hub Mode"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Commutador local"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Commutador remot"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Commutador:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Secret compartit:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Modalitat de concentrador"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Lokální switch"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Vzdálený switch"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Switch:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Sdílené tajemství:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Režim hubu"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Lokaler Schalter"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Entfernter Schalter"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Schalter:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Gemeinsames Geheimnis:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Hub-Modus"
|
||||
|
||||
@@ -2883,8 +2883,8 @@ msgstr "Τοπικός Διακόπτης"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Απομακρυσμένος Διακόπτης"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Διακόπτης:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "κοινό μυστικό:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Λειτουργία Hub"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Conmutador local"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Conmutador remoto"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Conmutador:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Secreto compartido:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Modo de concentrador"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Paikallinen kytkin"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Etäkytkin"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Kytkin:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Jaettu salaisuus:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Hubitila"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Commutateur local"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Commutateur distant"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Commutateur :"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Secret partagé:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Mode concentrateur"
|
||||
|
||||
@@ -2840,8 +2840,8 @@ msgstr "Lokalni prekidač"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Udaljeni prekidač"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Prekidač:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Zajednička tajna:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Način čvorišta"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Commutatore locale"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Commutatore remoto"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Commutatore:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Segreto condiviso:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Modalità Hub"
|
||||
|
||||
@@ -2839,8 +2839,8 @@ msgstr "ローカルスイッチ"
|
||||
msgid "Remote Switch"
|
||||
msgstr "リモートスイッチ"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "スイッチ:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "きょうゆうひみつ:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "ハブモード"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "로컬 스위치"
|
||||
msgid "Remote Switch"
|
||||
msgstr "원격 스위치"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "스위치:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "공유 비밀:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "허브 모드"
|
||||
|
||||
@@ -2839,8 +2839,8 @@ msgstr "Lokal svitsj"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Ekstern svitsj"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Svitsj:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Delt hemmelighet:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Hub-modus"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Lokale Switch"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Externe Switch"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Switch:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Gedeeld geheim:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Hub-modus"
|
||||
|
||||
@@ -2839,8 +2839,8 @@ msgstr "Switch lokalny"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Switch zdalny"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Switch:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Wspólny sekret:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Tryb hub"
|
||||
|
||||
@@ -2832,8 +2832,8 @@ msgstr "Switch Local"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Switch Remoto"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Switch:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Segredo compartihado:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Modo Hub"
|
||||
|
||||
@@ -2839,8 +2839,8 @@ msgstr "Comutador local"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Comutador remoto"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Comutador:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Segredo compartihado:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Modo de concentrador"
|
||||
|
||||
@@ -2851,8 +2851,8 @@ msgstr "Локальный коммутатор"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Удалённый коммутатор"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Номер коммутатора:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Общий секрет:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Режим концентратора"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Lokálny prepínač"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Vzdialený prepínač"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Prepínač:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Zdieľané tajomstvo:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Režim hubu"
|
||||
|
||||
@@ -2840,8 +2840,8 @@ msgstr "Lokalno stikalo"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Oddaljeno stikalo"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Stikalo:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Skupni skrivnost:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Način koncentratorja"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Lokal switch"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Fjärr-switch"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Switch:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Delad hemlighet:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Hubb-läge"
|
||||
|
||||
@@ -2838,8 +2838,8 @@ msgstr "Yerel Switch"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Uzak Switch"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Switch:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Paylaşılan sır:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Hub Modu"
|
||||
|
||||
@@ -2840,8 +2840,8 @@ msgstr "Локальний комутатор"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Віддалений комутатор"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Номер комутатора:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Спільний секрет:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Режим концентратора"
|
||||
|
||||
@@ -2839,8 +2839,8 @@ msgstr "Công tắc cục bộ"
|
||||
msgid "Remote Switch"
|
||||
msgstr "Công tắc từ xa"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "Công tắc:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "Bí mật chia sẻ:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "Chế độ hub"
|
||||
|
||||
@@ -2839,8 +2839,8 @@ msgstr "本地交换机"
|
||||
msgid "Remote Switch"
|
||||
msgstr "远程交换机"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "交换机:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "共享秘密:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "集线器模式"
|
||||
|
||||
@@ -2839,8 +2839,8 @@ msgstr "本地交換器"
|
||||
msgid "Remote Switch"
|
||||
msgstr "遠端交換器"
|
||||
|
||||
msgid "Switch:"
|
||||
msgstr "交換器:"
|
||||
msgid "Shared secret:"
|
||||
msgstr "共享秘密:"
|
||||
|
||||
msgid "Hub Mode"
|
||||
msgstr "集線器模式"
|
||||
|
||||
@@ -49,13 +49,9 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
auto *option_list_label = findChild<QLabel *>(QString("labelOptionList%1").arg(i + 1));
|
||||
auto *option_list_line = findChild<QWidget *>(QString("lineOptionList%1").arg(i + 1));
|
||||
|
||||
// Switch group
|
||||
auto *switch_group_label = findChild<QLabel *>(QString("labelSwitch%1").arg(i + 1));
|
||||
// auto *switch_group_hlayout = findChild<QHBoxLayout *>(QString("HLayoutSwitch%1").arg(i + 1));
|
||||
// auto *switch_group_hspacer = findChild<QWidget *>(QString("horizontalSpacerSwitch%1").arg(i + 1));
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
switch_group_value->setMinimum(NET_SWITCH_GRP_MIN);
|
||||
switch_group_value->setMaximum(NET_SWITCH_GRP_MAX);
|
||||
// Shared secret
|
||||
auto *secret_label = findChild<QLabel *>(QString("labelSecret%1").arg(i + 1));
|
||||
auto *secret_value = findChild<QLineEdit *>(QString("secretSwitch%1").arg(i + 1));
|
||||
|
||||
// Promiscuous option
|
||||
auto *promisc_label = findChild<QLabel *>(QString("labelPromisc%1").arg(i + 1));
|
||||
@@ -73,10 +69,8 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
// NEW STUFF
|
||||
// Make all options invisible by default
|
||||
|
||||
// Switch group
|
||||
switch_group_label->setVisible(false);
|
||||
switch_group_value->setVisible(false);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
secret_label->setVisible(false);
|
||||
secret_value->setVisible(false);
|
||||
|
||||
// Promiscuous options
|
||||
promisc_label->setVisible(false);
|
||||
@@ -142,10 +136,9 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
option_list_label->setVisible(true);
|
||||
option_list_line->setVisible(true);
|
||||
|
||||
// Switch group
|
||||
switch_group_label->setVisible(true);
|
||||
switch_group_value->setVisible(true);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
// Shared secret
|
||||
secret_label->setVisible(true);
|
||||
secret_value->setVisible(true);
|
||||
|
||||
// Promiscuous options
|
||||
promisc_label->setVisible(true);
|
||||
@@ -157,10 +150,9 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
option_list_label->setVisible(true);
|
||||
option_list_line->setVisible(true);
|
||||
|
||||
// Switch group
|
||||
switch_group_label->setVisible(true);
|
||||
switch_group_value->setVisible(true);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
// Shared secret
|
||||
secret_label->setVisible(true);
|
||||
secret_value->setVisible(true);
|
||||
|
||||
// Hostname
|
||||
hostname_label->setVisible(true);
|
||||
@@ -215,7 +207,7 @@ SettingsNetwork::save()
|
||||
cbox = findChild<QComboBox *>(QString("comboBoxIntf%1").arg(i + 1));
|
||||
auto *hostname_value = findChild<QLineEdit *>(QString("hostnameSwitch%1").arg(i + 1));
|
||||
auto *promisc_value = findChild<QCheckBox *>(QString("boxPromisc%1").arg(i + 1));
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
auto *secret_value = findChild<QLineEdit *>(QString("secretSwitch%1").arg(i + 1));
|
||||
memset(net_cards_conf[i].host_dev_name, '\0', sizeof(net_cards_conf[i].host_dev_name));
|
||||
if (net_cards_conf[i].net_type == NET_TYPE_PCAP)
|
||||
strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1);
|
||||
@@ -230,10 +222,12 @@ SettingsNetwork::save()
|
||||
else if (net_cards_conf[i].net_type == NET_TYPE_NRSWITCH) {
|
||||
memset(net_cards_conf[i].nrs_hostname, '\0', sizeof(net_cards_conf[i].nrs_hostname));
|
||||
strncpy(net_cards_conf[i].nrs_hostname, hostname_value->text().toUtf8().constData(), sizeof(net_cards_conf[i].nrs_hostname) - 1);
|
||||
net_cards_conf[i].switch_group = switch_group_value->value();
|
||||
memset(net_cards_conf[i].secret, '\0', sizeof(net_cards_conf[i].secret));
|
||||
strncpy(net_cards_conf[i].secret, secret_value->text().toUtf8().constData(), sizeof(net_cards_conf[i].secret) - 1);
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_NLSWITCH) {
|
||||
net_cards_conf[i].promisc_mode = promisc_value->isChecked();
|
||||
net_cards_conf[i].switch_group = switch_group_value->value();
|
||||
memset(net_cards_conf[i].secret, '\0', sizeof(net_cards_conf[i].secret));
|
||||
strncpy(net_cards_conf[i].secret, secret_value->text().toUtf8().constData(), sizeof(net_cards_conf[i].secret) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -349,13 +343,13 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_NLSWITCH) {
|
||||
auto *promisc_value = findChild<QCheckBox *>(QString("boxPromisc%1").arg(i + 1));
|
||||
promisc_value->setCheckState(net_cards_conf[i].promisc_mode == 1 ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
switch_group_value->setValue(net_cards_conf[i].switch_group);
|
||||
auto *secret_value = findChild<QLineEdit *>(QString("secretSwitch%1").arg(i + 1));
|
||||
secret_value->setText(net_cards_conf[i].secret);
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_NRSWITCH) {
|
||||
auto *hostname_value = findChild<QLineEdit *>(QString("hostnameSwitch%1").arg(i + 1));
|
||||
hostname_value->setText(net_cards_conf[i].nrs_hostname);
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
switch_group_value->setValue(net_cards_conf[i].switch_group);
|
||||
auto *secret_value = findChild<QLineEdit *>(QString("secretSwitch%1").arg(i + 1));
|
||||
secret_value->setText(net_cards_conf[i].secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,38 +170,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelSwitch1">
|
||||
<widget class="QLabel" name="labelSecret1">
|
||||
<property name="text">
|
||||
<string>Switch:</string>
|
||||
<string>Shared secret:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="HLayoutSwitch1">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinnerSwitch1">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerSwitch1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLineEdit" name="secretSwitch1">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPromisc1">
|
||||
@@ -385,38 +365,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelSwitch2">
|
||||
<widget class="QLabel" name="labelSecret2">
|
||||
<property name="text">
|
||||
<string>Switch:</string>
|
||||
<string>Shared secret:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="HLayoutSwitch2">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinnerSwitch2">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerSwitch2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLineEdit" name="secretSwitch2">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPromisc2">
|
||||
@@ -600,38 +560,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelSwitch3">
|
||||
<widget class="QLabel" name="labelSecret3">
|
||||
<property name="text">
|
||||
<string>Switch:</string>
|
||||
<string>Shared secret:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="HLayoutSwitch3">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinnerSwitch3">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerSwitch3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLineEdit" name="secretSwitch3">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPromisc3">
|
||||
@@ -815,38 +755,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelSwitch4">
|
||||
<widget class="QLabel" name="labelSecret4">
|
||||
<property name="text">
|
||||
<string>Switch:</string>
|
||||
<string>Shared secret:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="HLayoutSwitch4">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinnerSwitch4">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacerSwitch4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLineEdit" name="secretSwitch4">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPromisc4">
|
||||
|
||||
Reference in New Issue
Block a user