Build legacy drivers and publish per-OS packages with web activation and DEB

This commit is contained in:
2026-11-27 20:55:31 +00:00
96 changed files with 3204 additions and 25 deletions

View File

@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "client_core.h"
#include <string.h>
static const uint8_t bc[6]={255,255,255,255,255,255},zero[6]={0};
static int unicast(const uint8_t*p){return !(p[0]&1)&&memcmp(p,zero,6)!=0;}
static int allowed_type(const uint8_t*f,size_t n){unsigned h,total;if(n<14||n>PKT_FRAME)return 0;if(f[12]==8&&f[13]==0){if(n<34||(f[14]>>4)!=4)return 0;h=(f[14]&15)*4;total=((unsigned)f[16]<<8)|f[17];return h>=20&&total>=h&&total<=n-14;}return n>=42&&f[12]==8&&f[13]==6&&f[14]==0&&f[15]==1&&f[16]==8&&f[17]==0&&f[18]==6&&f[19]==4&&f[20]==0&&(f[21]==1||f[21]==2);}
int client_init(struct client_core*c,uint32_t net,const uint8_t*node,const uint8_t*server,uint16_t port){if(!c||!node||!server||!net||net==0xffffffffUL||!unicast(node)||!unicast(server)||!memcmp(node,server,6)||(port!=PKT_PLAIN&&port!=PKT_TRAIL))return -1;memset(c,0,sizeof *c);memcpy(c->node,node,6);memcpy(c->server,server,6);c->net=net;c->port=port;return 0;}
int client_tx(struct client_core*c,const uint8_t*f,size_t n,pkt_emit emit,void*ctx){if(!allowed_type(f,n)||memcmp(f+6,c->node,6)||(memcmp(f,c->server,6)&&memcmp(f,bc,6))||(f[13]==6&&memcmp(f+22,c->node,6))){c->dropped++;return -1;}if(pkt_send(c->port,++c->seq,f,n,emit,ctx)){c->dropped++;return -1;}c->tx++;return 0;}
int client_rx(struct client_core*c,uint32_t net,const uint8_t*node,uint16_t port,const uint8_t*p,size_t n,time_t now,uint8_t*out){int rc;if(net!=c->net||memcmp(node,c->server,6)||port!=c->port){c->dropped++;return -1;}if(now<c->last)memset(&c->rx,0,sizeof c->rx);c->last=now;rc=pkt_receive(&c->rx,net,node,port,p,n,now,out);if(rc==0)return 0;if(rc<0||!allowed_type(out,(size_t)rc)||memcmp(out+6,c->server,6)||(memcmp(out,c->node,6)&&memcmp(out,bc,6))||(out[13]==6&&memcmp(out+22,c->server,6))){c->dropped++;return -1;}c->received++;return rc;}
static int nibble(char c){if(c>='0'&&c<='9')return c-'0';if(c>='A'&&c<='F')return c-'A'+10;if(c>='a'&&c<='f')return c-'a'+10;return -1;}
int client_hex(const char*s,uint8_t*out,size_t n){size_t i;int a,b;if(!s||strlen(s)!=2*n)return -1;for(i=0;i<n;i++){a=nibble(s[2*i]);b=nibble(s[2*i+1]);if(a<0||b<0)return -1;out[i]=(uint8_t)(a*16+b);}return 0;}
/* An ARP probe with sender 0.0.0.0 is sufficient for server discovery before DHCP.
* The server records the IPX node but does NOT forward this probe to Linux. */
void client_probe(struct client_core*c,const uint8_t gw[4],uint8_t out[60]){memset(out,0,60);memset(out,255,6);memcpy(out+6,c->node,6);out[12]=8;out[13]=6;out[15]=1;out[16]=8;out[18]=6;out[19]=4;out[21]=1;memcpy(out+22,c->node,6);memcpy(out+38,gw,4);}