Rev 4722 | Rev 4731 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4722 | Rev 4728 | ||
|---|---|---|---|
| Line 456... | Line 456... | ||
| 456 | if(( ~ compute_crc32( ~ 0u, data, length * 8 )) != ntohl( * fcs )){ |
456 | if(( ~ compute_crc32( ~ 0u, data, length * 8 )) != ntohl( * fcs )){ |
| 457 | return NULL; |
457 | return NULL; |
| 458 | } |
458 | } |
| 459 | suffix += sizeof( eth_fcs_t ); |
459 | suffix += sizeof( eth_fcs_t ); |
| 460 | } |
460 | } |
| 461 | if( ERROR_OCCURRED( packet_set_addr( packet, header->header.src, header->header.dest, ETH_ADDR )) |
461 | if( ERROR_OCCURRED( packet_set_addr( packet, header->header.source_address, header->header.destination_address, ETH_ADDR )) |
| 462 | || ERROR_OCCURRED( packet_trim( packet, prefix, suffix ))){ |
462 | || ERROR_OCCURRED( packet_trim( packet, prefix, suffix ))){ |
| 463 | return NULL; |
463 | return NULL; |
| 464 | } |
464 | } |
| 465 | return eth_protos_find( & eth_globals.protos, type ); |
465 | return eth_protos_find( & eth_globals.protos, type ); |
| 466 | } |
466 | } |
| Line 596... | Line 596... | ||
| 596 | // TODO LSAP only device |
596 | // TODO LSAP only device |
| 597 | if( IS_DIX( flags ) || IS_8023_2_LSAP( flags )){ |
597 | if( IS_DIX( flags ) || IS_8023_2_LSAP( flags )){ |
| 598 | header_dix = PACKET_PREFIX( packet, eth_header_t ); |
598 | header_dix = PACKET_PREFIX( packet, eth_header_t ); |
| 599 | if( ! header_dix ) return ENOMEM; |
599 | if( ! header_dix ) return ENOMEM; |
| 600 | header_dix->ethertype = ( uint16_t ) ethertype; |
600 | header_dix->ethertype = ( uint16_t ) ethertype; |
| 601 | memcpy( header_dix->src, src_addr, ETH_ADDR ); |
601 | memcpy( header_dix->source_address, src_addr, ETH_ADDR ); |
| 602 | memcpy( header_dix->dest, dest, ETH_ADDR ); |
602 | memcpy( header_dix->destination_address, dest, ETH_ADDR ); |
| 603 | src = & header_dix->dest[ 0 ]; |
603 | src = & header_dix->destination_address[ 0 ]; |
| 604 | }else if( IS_8023_2_SNAP( flags )){ |
604 | }else if( IS_8023_2_SNAP( flags )){ |
| 605 | header = PACKET_PREFIX( packet, eth_header_ex_t ); |
605 | header = PACKET_PREFIX( packet, eth_header_ex_t ); |
| 606 | if( ! header ) return ENOMEM; |
606 | if( ! header ) return ENOMEM; |
| 607 | header->header.ethertype = htons( length + sizeof( eth_header_lsap_t ) + sizeof( eth_header_snap_t )); |
607 | header->header.ethertype = htons( length + sizeof( eth_header_lsap_t ) + sizeof( eth_header_snap_t )); |
| 608 | header->lsap.dsap = ( uint16_t ) ETH_LSAP_SNAP; |
608 | header->lsap.dsap = ( uint16_t ) ETH_LSAP_SNAP; |
| 609 | header->lsap.ssap = header->lsap.dsap; |
609 | header->lsap.ssap = header->lsap.dsap; |
| 610 | header->lsap.ctrl = 0; |
610 | header->lsap.ctrl = 0; |
| 611 | for( i = 0; i < 3; ++ i ) header->snap.proto[ i ] = 0; |
611 | for( i = 0; i < 3; ++ i ) header->snap.protocol[ i ] = 0; |
| 612 | header->snap.ethertype = ( uint16_t ) ethertype; |
612 | header->snap.ethertype = ( uint16_t ) ethertype; |
| 613 | memcpy( header->header.src, src_addr, ETH_ADDR ); |
613 | memcpy( header->header.source_address, src_addr, ETH_ADDR ); |
| 614 | memcpy( header->header.dest, dest, ETH_ADDR ); |
614 | memcpy( header->header.destination_address, dest, ETH_ADDR ); |
| 615 | src = & header->header.dest[ 0 ]; |
615 | src = & header->header.destination_address[ 0 ]; |
| 616 | } |
616 | } |
| 617 | if( IS_DUMMY( flags )){ |
617 | if( IS_DUMMY( flags )){ |
| 618 | fcs = PACKET_SUFFIX( packet, eth_fcs_t ); |
618 | fcs = PACKET_SUFFIX( packet, eth_fcs_t ); |
| 619 | if( ! fcs ) return ENOMEM; |
619 | if( ! fcs ) return ENOMEM; |
| 620 | * fcs = htonl( ~ compute_crc32( ~ 0u, src, length * 8 )); |
620 | * fcs = htonl( ~ compute_crc32( ~ 0u, src, length * 8 )); |