I am looking for a solution where I can program an MAC “allow” list into my Dynamic C program. I just want to give access to my Rabbit application if MAC adress is in my list (reply data if the MAC is in the list). I use a RCM3700.
For IP (but just for one connection):
when you init your connection and call tcp_listen, add the IP and/or PORT
tcp_listen ( socket, Port, IP, 0, NULL, 0 );
For MAC and IP:
Add code in tcp_handler(); where check for new connection (else if (s->state & tcp_StateLISTEN) { /* accepting SYNs */)
else if (s->state & tcp_StateLISTEN) { /* accepting SYNs */
// Ignore if not binding interface
if (s->iface == IF_ANY)
s->iface = iface;
else if (iface != s->iface)
goto _th_finish;
if (!s->sath) {
//Vantive 23956: now use ARP lookup instead of sending back to source’s MAC address.
//ath = arpcache_new(hisip, &((eth_Header *)hdrbuf)->source, iface);
ath = arpresolve_start_iface(hisip, iface);
if (ath <= 0) {
tcp_rst(LL, hdrbuf, tp);
goto _th_finish;
}
s->sath = ath;
if ((ath = arpresolve_check(ath, hisip)) > 0) {
#ifdef TCP_VERBOSE
if (debug_on > 0) printf("TCP: …passive open using ARP table entry
");
#endif
}
else {
#ifdef TCP_VERBOSE
if (debug_on > 0) printf("TCP: …passive open deferred ARP resolution
");
#endif
s->kflags |= TCP_KF_NOARP;
}
}
if( flags & tcp_FlagSYN && !(flags & tcp_FlagACK)) {
//PUT CODE HERE*****************>
temp_e = (eth_Header *)hdrbuf;
temp_eth = &temp_e->source;
if ( !AddressFiltering(&hisip, temp_eth) ) {
tcp_rst(LL, hdrbuf, tp); /* send a reset */
}
else{
//*****************<
//check if this is a connection to a reserved port
s->reservedport_flag = 0;
#ifdef USE_RESERVEDPORTS
for(x=0;xdstPort)
{
s->reservedport_flag = 1;
break;
}
#endif
s->acknum = hisseq + 1;
s->hisport = hisport;
s->hisaddr = hisip;
s->mss = _tcp_process_options(s, tp, iface);
tcp_setstate(s, tcp_StateSYNREC);
s->kflags |= TCP_KF_SYN;
send_ack = 1;
s->timeout = _SET_TIMEOUT( TCP_CONNTIMEOUT );
}
}
else
tcp_rst(LL, hdrbuf, tp); /* send a reset */
}
//ADD THIS FUNCTION
//THIS FUNCTION COMPARE ADDRESS WITH TABLE IN MEMORY*****************>
_tcp_nodebug int AddressFiltering( longword *hisIP, eth_address *hisMAC ){
auto int i;
#if 1 // used for test
AddrFiltering[0].Address.MACa.eaddr[0] = 0x00; //PC 1
AddrFiltering[0].Address.MACa.eaddr[1] = 0xE0;
AddrFiltering[0].Address.MACa.eaddr[2] = 0xB8;
AddrFiltering[0].Address.MACa.eaddr[3] = 0xB9;
AddrFiltering[0].Address.MACa.eaddr[4] = 0xB7;
AddrFiltering[0].Address.MACa.eaddr[5] = 0x4C;
AddrFiltering[0].ProgState = 2;
AddrFiltering[1].Address.IPa = 0xC0A80188; //PC 2
AddrFiltering[1].ProgState = 1;
AddrFiltering[2].Address.IPa = 0xC0A801AD; //PC 3
AddrFiltering[2].ProgState = 1;
#endif
if (AddrFiltering[0].ProgState == 0)
return 1;
for(i=0; i
typedef struct {
byte ProgState; // 0=not prog, 1=IP, 2=MAC
union {
longword IPa; // IP address of destination host
eth_address MACa; // Corresponding hardware (ethernet or MAC) address (byte eaddr[6]
}Address;
}AddressStruct;
extern AddressStruct AddrFiltering[MB_MAX_SKT];
AddressStruct AddrFiltering[MB_MAX_SKT];
//*****************<