First Version (beta test) raw ethernet

Dependencies:   EthernetNetIf mbed

Committer:
ficofer
Date:
Mon Jul 09 22:31:28 2012 +0000
Revision:
0:db9ea2448fdd

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ficofer 0:db9ea2448fdd 1 /*
ficofer 0:db9ea2448fdd 2 * eth2.c
ficofer 0:db9ea2448fdd 3 * Send ethernet frames
ficofer 0:db9ea2448fdd 4 */
ficofer 0:db9ea2448fdd 5
ficofer 0:db9ea2448fdd 6 #include <stdio.h>
ficofer 0:db9ea2448fdd 7 #include <stdlib.h>
ficofer 0:db9ea2448fdd 8 #include <string.h>
ficofer 0:db9ea2448fdd 9 #include <inet.h>
ficofer 0:db9ea2448fdd 10 #include "mbed.h"
ficofer 0:db9ea2448fdd 11 #include "EthernetNetIf.h"
ficofer 0:db9ea2448fdd 12 #include "defines.h"
ficofer 0:db9ea2448fdd 13 #include "utils.h"
ficofer 0:db9ea2448fdd 14 #include "variables.h"
ficofer 0:db9ea2448fdd 15
ficofer 0:db9ea2448fdd 16
ficofer 0:db9ea2448fdd 17
ficofer 0:db9ea2448fdd 18 /*
ficofer 0:db9ea2448fdd 19 * Public functions
ficofer 0:db9ea2448fdd 20 * main: here starts ball rolling forever !!!
ficofer 0:db9ea2448fdd 21 */
ficofer 0:db9ea2448fdd 22
ficofer 0:db9ea2448fdd 23 int
ficofer 0:db9ea2448fdd 24 main( void )
ficofer 0:db9ea2448fdd 25 {
ficofer 0:db9ea2448fdd 26 int i;
ficofer 0:db9ea2448fdd 27
ficofer 0:db9ea2448fdd 28 set_to_mac( eth_txs_buffer, broadcast );
ficofer 0:db9ea2448fdd 29
ficofer 0:db9ea2448fdd 30 printf("Sending data to\n");
ficofer 0:db9ea2448fdd 31 for(i=0; i<6; i++)
ficofer 0:db9ea2448fdd 32 printf("%02X ", broadcast[i]);
ficofer 0:db9ea2448fdd 33 printf("\n");
ficofer 0:db9ea2448fdd 34
ficofer 0:db9ea2448fdd 35 mbed_mac_address(my_mac);
ficofer 0:db9ea2448fdd 36
ficofer 0:db9ea2448fdd 37 set_from_mac( eth_txs_buffer, my_mac );
ficofer 0:db9ea2448fdd 38
ficofer 0:db9ea2448fdd 39 printf("Sending data from\n");
ficofer 0:db9ea2448fdd 40 for(i=0; i<6; i++)
ficofer 0:db9ea2448fdd 41 printf("%02X ", my_mac[i]);
ficofer 0:db9ea2448fdd 42 printf("\n");
ficofer 0:db9ea2448fdd 43
ficofer 0:db9ea2448fdd 44 set_ether_type( eth_txs_buffer, ETHER_TYPE );
ficofer 0:db9ea2448fdd 45
ficofer 0:db9ea2448fdd 46 memset( eth_txs_buffer + PAYLOAD_OFF, 'Z', NUM_PAYLOAD );
ficofer 0:db9ea2448fdd 47
ficofer 0:db9ea2448fdd 48 printf("Flooding Data...\n");
ficofer 0:db9ea2448fdd 49 forever
ficofer 0:db9ea2448fdd 50 {
ficofer 0:db9ea2448fdd 51 eth.write( eth_txs_buffer, PAYLOAD_OFF + NUM_PAYLOAD );
ficofer 0:db9ea2448fdd 52 eth.send();
ficofer 0:db9ea2448fdd 53 wait_ms(1*SEC);
ficofer 0:db9ea2448fdd 54 }
ficofer 0:db9ea2448fdd 55 }
ficofer 0:db9ea2448fdd 56