- /* is it for me? */
- tome = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0;
- fromme = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0;
-
- /*
- * Multiplex the packet to all the connections which want it.
- * If the packet is not to be used subsequently (fromwire != 0),
- * attempt to simply pass it into one of the connections, thereby
- * saving a copy of the data (usual case hopefully).
- */
- for(fp = ether->f; fp < ep; fp++){
- if(f = *fp)
- if(f->type == type || f->type < 0)
- if(tome || multi || f->prom){
- /* Don't want to hear loopback or bridged packets */
- if(f->bridge && (tome || !fromwire && !fromme))
- continue;
- if(!f->headersonly){
- if(fromwire && fx == 0)
- fx = f;
- else if(xbp = iallocb(len)){
- memmove(xbp->wp, pkt, len);
- xbp->wp += len;
- xbp->flag = bp->flag;
- if(qpass(f->in, xbp) < 0) {
- // print("soverflow for f->in\n");
- ether->soverflows++;
- }
- }
- else {
- // print("soverflow iallocb\n");
- ether->soverflows++;
- }
- }
- else
- etherrtrace(f, pkt, len);
+ port = -1;
+ if(ether->prom){
+ if((from == nil || (*from)->bridge) && (pkt->s[0] & 1) == 0){
+ Macent *t = macent(ether, pkt->s);
+ t->port = from == nil ? 0 : 1+(from - ether->f);
+ memmove(t->ea, pkt->s, Eaddrlen);
+ }
+ if(!tome && !multi){
+ Macent *t = macent(ether, pkt->d);
+ if(memcmp(t->ea, pkt->d, Eaddrlen) == 0)
+ port = t->port;