void apply_channel_normalization_in_imelda(norm_info *channorm, imeldata *outframe, imeldata *frame, int dimen) { int ii; ASSERT(channorm); ASSERT(frame); ASSERT(outframe); ASSERT(dimen <= channorm->dim); for (ii = 0; ii < dimen; ii++) outframe[ii] = MAKEBYTE(frame[ii] + channorm->imelda_adjust[ii]); return; }
void DisplayImageToMap (Image const * image, ScreenBuffer * buffer, Map const * map) { int i; int width, height; int pitch, imgPitch, mapPitch; // Initialization block { int index, mapIndex; int originX, originY; int xOffset, yOffset; originX = G_clipper.clipRegion.left; originY = G_clipper.clipRegion.top; xOffset = originX - image->location.X; yOffset = originY - image->location.Y; width = G_clipper.clipRegion.right - originX; height = G_clipper.clipRegion.bottom - originY; index = yOffset * image->width + xOffset; mapIndex = (map->yOffset + originY) * map->width + (map->xOffset + originX); /* G_flags = image->image.flags + index; G_flags2 = map->world.flags + mapIndex; G_data = image->image.data + index; G_cell = *(buffer->buffer + originY) + originX; G_cell2 = image->image.buffer + index; G_cell3 = map->world.buffer + mapIndex;*/ G_dest = *(buffer->buffer + originY) + originX; G_imgCell = image->image.buffer + index; G_mapCell = map->world.buffer + mapIndex; pitch = SCREEN_WIDTH - width; imgPitch = image->width - width; mapPitch = map->width - width; } for (i = 0; i < height; i++) { /* for (G_endCell = G_cell + width; G_cell < G_endCell; G_flags++, G_flags2++, G_data++, G_cell++, G_cell2++, G_cell3++) { if (FLAGSET(*G_flags,FLASH)) { FLIPFLAG(*G_flags,SHOWSECONDARY); } if (!FLAGSET(*G_flags,NONVISIBLE) && (FLAGSET(*G_flags,HIGH) || !FLAGSET(*G_flags2,OBSCURE))) { if (FLAGSET(*G_flags,SHOWSECONDARY)) { if (FLAGSET(*G_flags2,SHIMMER)) { G_cell->Attributes = MAKEBYTE(*G_data,HINYBBLE(G_cell3->Attributes)); } else { G_cell->Attributes = *G_data; } } else { if (FLAGSET(*G_flags2,SHIMMER)) { G_cell->Attributes = MAKEBYTE(G_cell2->Attributes,HINYBBLE(G_cell3->Attributes)); } else { G_cell->Attributes = G_cell2->Attributes; } } G_cell->Char.AsciiChar = G_cell2->Char.AsciiChar; } } G_cell += pitch; G_cell2 += imgPitch, G_flags += imgPitch, G_data += imgPitch; G_cell3 += mapPitch, G_flags2 += mapPitch;*/ for (G_end = G_imgCell + width; G_imgCell < G_end; G_dest++, G_mapCell++, G_imgCell++) { if (FLAGSET(G_imgCell->flags,FLASH)) { FLIPFLAG(G_imgCell->flags,SHOWSECONDARY); } if (!FLAGSET(G_imgCell->flags,NONVISIBLE) && (FLAGSET(G_imgCell->flags,HIGH) || !FLAGSET(G_mapCell->flags,OBSCURE))) { if (FLAGSET(G_imgCell->flags,SHOWSECONDARY)) { if (FLAGSET(G_mapCell->flags,SHIMMER)) { G_dest->Attributes = MAKEBYTE(G_imgCell->data,HINYBBLE(G_mapCell->graph.Attributes)); } else { G_dest->Attributes = G_imgCell->data; } } else { if (FLAGSET(G_mapCell->flags,SHIMMER)) { G_dest->Attributes = MAKEBYTE(G_imgCell->graph.Attributes,HINYBBLE(G_mapCell->graph.Attributes)); } else { G_dest->Attributes = G_imgCell->graph.Attributes; } } G_dest->Char.AsciiChar = G_imgCell->graph.Char.AsciiChar; } G_dest += pitch; G_mapCell += mapPitch; G_imgCell += imgPitch; } } }
/* functional description: packet forward(enqueue) module,we push packet into QoS queue or TX queue input mod: RX_MOD_FORWARD output mod: RX_MOD_DROP RX_MOD_IDLE module stack pos: as 1st action ,before drop module,and below any policy module */ dbg_local enum RX_MOD_INDEX rx_module_forward(dbg_local struct rte_mbuf*pktbuf,dbg_local enum RX_MOD_INDEX imodid) { dbg_local int iPortIn; dbg_local int iPortOut; dbg_local int iFlowIdx; dbg_local int iDstIdx; dbg_local int uiSIP; dbg_local int uiDIP; dbg_local int idx; dbg_local int rc; dbg_local int iUsed; dbg_local int iMod; dbg_local struct ether_hdr *eh; dbg_local struct ether_arp *ea; dbg_local struct iphdr *iph; dbg_local int iPortForwardFlag[MAX_PORT_NB]; dbg_local struct rte_mbuf*rmPortForwardMbuf[MAX_PORT_NB]; dbg_local enum RX_MOD_INDEX nextmodid=imodid; if(imodid!=RX_MOD_FORWARD) goto local_ret; //phaze 1,we filter packet with illegal l2 and l3 address,and drop it //printf("input port:%d\n",(int)pktbuf->pkt.in_port); eh=rte_pktmbuf_mtod(pktbuf,struct ether_hdr*); uiSIP=0xffffffff; switch(HTONS(eh->ether_type)) { case ETH_TYPE_ARP: ea=(struct ether_arp *)(sizeof(struct ether_hdr)+(char*)eh); uiSIP=HTONL(MAKEUINT32FROMUINT8ARR(ea->arp_spa)); uiDIP=HTONL(MAKEUINT32FROMUINT8ARR(ea->arp_tpa)); break; case ETH_TYPE_IP: iph=(struct iphdr *)(sizeof(struct ether_hdr)+(char*)eh); uiSIP=HTONL(iph->ip_src); uiDIP=HTONL(iph->ip_dst); break; default: goto exception_tag; break; } iFlowIdx=find_net_entry(uiSIP,TRUE); //pkt source legality checking if(iFlowIdx==-1) goto exception_tag; if(gFlow[iFlowIdx].b_mac_learned==FALSE) goto exception_tag; if(gFlow[iFlowIdx].b_flow_enabled==FALSE) goto exception_tag; if(gFlow[iFlowIdx].portid!=pktbuf->pkt.in_port) goto exception_tag; if(!IS_MAC_EQUAL(eh->s_addr.addr_bytes,gFlow[iFlowIdx].eaHostMAC.addr_bytes)) goto exception_tag; iDstIdx=find_net_entry(uiDIP,TRUE); /*printf("%02x,%02x,%02x,%02x,%02x,%02x,\n",eh->d_addr.addr_bytes[0] ,eh->d_addr.addr_bytes[1] ,eh->d_addr.addr_bytes[2] ,eh->d_addr.addr_bytes[3] ,eh->d_addr.addr_bytes[4] ,eh->d_addr.addr_bytes[5] );*/ if(IS_MAC_BROADCAST(eh->d_addr.addr_bytes)){//link broadcast iUsed=FALSE; for(idx=0;idx<gNBPort;idx++) if(port_brdcst_map[(int)pktbuf->pkt.in_port][idx]==TRUE){ iPortForwardFlag[idx]=1; if(iUsed==FALSE){ rmPortForwardMbuf[idx]=pktbuf; iUsed=TRUE; }else{ rmPortForwardMbuf[idx]=rte_pktmbuf_clone(pktbuf,gmempool); if(!rmPortForwardMbuf[idx]) iPortForwardFlag[idx]=0; } }else iPortForwardFlag[idx]=0; }else{//link uicast for(idx=0;idx<gNBPort;idx++) iPortForwardFlag[idx]=0; if(iDstIdx!=-1){ // printf(".......idstidx!=-1.%08x\n",gFlow[iDstIdx].uiInnerIP); if(gFlow[iDstIdx].b_mac_learned==FALSE) goto exception_tag; // printf("Heror1\n"); if(gFlow[iDstIdx].b_flow_enabled==FALSE) goto exception_tag; // printf("Heror2\n"); iPortForwardFlag[(int)gFlow[iDstIdx].portid]=1; rmPortForwardMbuf[(int)gFlow[iDstIdx].portid]=pktbuf; } else { // printf(".......idstidx==-1\n"); if(port_def_frd_map[(int)pktbuf->pkt.in_port]!=-1){ iPortForwardFlag[port_def_frd_map[(int)pktbuf->pkt.in_port]]=1; rmPortForwardMbuf[port_def_frd_map[(int)pktbuf->pkt.in_port]]=pktbuf; } else goto exception_tag; } } //mirror--pkt--cloning for(idx=0;idx<gNBPort;idx++) { if(!iPortForwardFlag[idx])continue; switch(port_policy_map[(int)pktbuf->pkt.in_port][idx]) { case PORT_POLICY_MAP_DIRECT: //printf("...direct:%d->%d\n",(int)pktbuf->pkt.in_port,idx); rc=EnqueueIntoPortQueue(idx,&rmPortForwardMbuf[idx],1); //printf("...rc:%d\n",rc); if(!rc) goto exception_tag; break; case PORT_POLICY_MAP_QOS: //high nibble:dst port //low nibble :src port iMod=sched_mod_map[(int)rmPortForwardMbuf[idx]->pkt.in_port][idx]; rmPortForwardMbuf[idx]->pkt.in_port=MAKEBYTE(idx,rmPortForwardMbuf[idx]->pkt.in_port); rc=rte_ring_mp_enqueue(sched_mod_list[iMod].rrFirLev,rmPortForwardMbuf[idx]); if(rc==-ENOBUFS){ goto exception_tag; } break; case PORT_POLICY_MAP_UNDEFINE: goto exception_tag; break; } } local_ret: return nextmodid; exception_tag: nextmodid=RX_MOD_DROP; goto local_ret; }