void nic_hdlr(int evt) { int whichifc; uchar src_addr[16+1]; uchar rxbuf[MAX_FRAMEBYTES]; uchar *tdataptr; ulong tframelen; ulong rx_frame_size; /* Lower 12 bits of interrupt code specify IFC # */ whichifc = evt & 0xFFF; rx_frame_size = devnet_getmaxfsz(whichifc); devnet_recv(&rxbuf[0], rx_frame_size, whichifc); memmove(&src_addr, (uchar *)&rxbuf[0], 16); /* Get payload and length */ tdataptr = (uchar *)&rxbuf[0]+37; tframelen = 0; tframelen |= rxbuf[32] << 24; tframelen |= rxbuf[33] << 16; tframelen |= rxbuf[34] << 8; tframelen |= rxbuf[35]; memmove((void *)&fb1, tdataptr, sizeof(fb1)); sample_flag = 1; /* print("swradio-lpf [%s] : Just got frame from node [%s], length [%d]\n",\ NIC_OUI, &src_addr[0], tframelen); print("fb1.rpos = [%d], fb1.rlen = [%d]\n", fb1.rpos, fb1.rlen); */ return; }
void nic_hdlr(int evt) { int whichifc; uchar src_addr[16+1]; uchar rxbuf[MAX_FRAMEBYTES]; uchar *tdataptr; ulong tframelen; ulong rx_frame_size; /* Lower 12 bits of interrupt code specify IFC # */ whichifc = evt & 0xFFF; rx_frame_size = devnet_getrxfsz(whichifc); devnet_recv(&rxbuf[0], rx_frame_size, whichifc); //memmove(&src_addr, &rxbuf[0], 16); /* DEBUG */ printf("swradio-source : Just got frame from node [%d], length [%d]\n", whichifc, rx_frame_size); return; }
void nic_hdlr(int evt) { int whichifc; char proto; uchar src_addr[16+1]; uchar rxbuf[MAX_FRAMEBYTES]; uchar *tdataptr; ulong tframelen, timestamp, now; ulong rx_frame_size; EARSrcPayloadTuple *x; /* Lower 12 bits of interrupt code specify IFC # */ whichifc = evt & 0xFFF; NETTRACEMARK(8); LOGMARK(0); rx_frame_size = devnet_getrxfsz(whichifc); //printf("\tRX frame size is %d\n", rx_frame_size); devnet_recv(&rxbuf[0], rx_frame_size, whichifc); memmove(&src_addr[0], &rxbuf[0], 16); /* Get payload and length */ tdataptr = &rxbuf[0]+37; tframelen = 0; tframelen |= rxbuf[32] << 24; tframelen |= rxbuf[33] << 16; tframelen |= rxbuf[34] << 8; tframelen |= rxbuf[35]; proto = rxbuf[36]; LOGMARK(1); NETTRACEMARK(9); now = devrtc_getusecs(); /* DEBUG */ printf("\t\tDAM node [%s]: Just got frame from node [%s], length [%lu], proto [%s]\n", dam_myID, &src_addr[0], tframelen, (proto == PROTO_DAM_INTERNAL ? "DAM" : (proto == PROTO_EAR ? "EAR" : "UNKNOWN"))); if (proto == PROTO_EAR) { NETTRACEMARK(12); LOGMARK(18); x = ear_recv(Ear, tdataptr, tframelen); if (x != NULL) { int id; char tmp; char *ep = &tmp; id = strtol(dam_leaderID, &ep, 0); /* */ /* Immediately send response w/ no payload */ /* but with DAM leader ID in nxthdr field */ /* (we ignore incoming payload which is in */ /* x->payload). Cache sink for use whenever */ /* we are in DAM cluster */ /* */ strncpy(dam_sink, x->src, DAM_ID_LEN); if (dam_participating) { ear_response(Ear, dam_sink, NULL, 0, id); } //printf("\n\n\nsent EAR response = [%d] (dam_leader = [%s])\n\n\n", // (dam_leaderID[0] - '0')*10 + (dam_leaderID[1]-'0'), dam_leaderID); } free(x); LOGMARK(19); NETTRACEMARK(13); return; } /* There will always be some old frames, since broadcast leads to loops */ memmove(×tamp, tdataptr, 4); if ((now - timestamp) > dam_period) { printf("Frame is too old (timestamp @ %d usecs) discarding...\n", timestamp); return; } if (proto == PROTO_DAM_INTERNAL) { LOGMARK(14); dam_rcv_pkt(tdataptr); LOGMARK(15); } return; }