> Hello,
>
> I want to create an ethernet frame header and then append raw bytes to the back of this frame. Then generate my packet_out message and send to the OF switch. I am using original Trema (OF 1.0). I am having problems. Can someone help out please. The issue is I am not able to see my received bytes (from socket) - the ethernet header is constructed fine and seen on the wireshark trace.
>
> See below:
>
> unsigned char *buf;
> buf = (unsigned char *) calloc (1500);
This allocates memory.
>
> int rxBytes = read(sfd, buf, 1500); // read raw bytes from the socket (which is successful)
This reads from the socket into the allocated memory.
>
> buffer *frame = alloc_buffer_with_length( rxBytes + sizeof(ether_header_t) );
> ether_header_t *ether = append_back_buffer( frame, sizeof(ether_header_t) );
>
> buf = (unsigned char *)append_back_buffer( frame, (size_t)rxBytes );
This leaks the allocated memory that holds the data read from the socket and sets the pointer to something else. Probably you want to read from the socket after the line above, not before.
>
> memcpy (ether->macsa, trema_macsa, ETH_ADDRLEN);
> memcpy (ether->macda, pae_group_addr, ETH_ADDRLEN);
> ether->type = htons( ETH_ETHTYPE_8021X );
>
> openflow_actions *actions = create_actions();
> append_action_output( actions, OFPP_FLOOD, UINT16_MAX );
> fill_ether_padding( frame );
>
> buffer *packet_out = create_packet_out( get_transaction_id(), UINT32_MAX, OFPP_NONE, actions, frame);
>
> int ret = send_openflow_message( 1, packet_out);
>
--
Denis Ovsienko