Commit 6ad34b16 authored by Aurelio Colosimo's avatar Aurelio Colosimo

defined proto_ofst for raw handling of raw socket header in send

parent b9e54d18
......@@ -22,6 +22,10 @@ void posix_main_loop(struct pp_instance *ppi)
set_TimeInternal(&ppi->last_rcv_time, 0, 0);
if (OPTS(ppi)->ethernet_mode) {
NP(ppi)->proto_ofst = 14;
}
/*
* The main loop here is based on select. While we are not
* doing anything else but the protocol, this allows extra stuff
......
......@@ -135,10 +135,14 @@ int posix_send_packet(struct pp_instance *ppi, void *pkt, int len, int chtype,
int use_pdelay_addr)
{
struct sockaddr_in addr;
void *hdr;
if (OPTS(ppi)->ethernet_mode) {
hdr = PROTO_HDR(pkt);
/* TODO: fill header */
/* raw sockets implementation always use gen socket */
return send(NP(ppi)->ch[PP_NP_GEN].fd, pkt, len, 0);
return send(NP(ppi)->ch[PP_NP_GEN].fd, hdr,
len + NP(ppi)->proto_ofst, 0);
}
/* else: UDP */
......@@ -359,6 +363,9 @@ int posix_net_init(struct pp_instance *ppi)
{
int i;
ppi->buf_out = calloc(1, PP_PACKET_SIZE + NP(ppi)->proto_ofst);
ppi->buf_out = PROTO_PAYLOAD(ppi->buf_out);
if (OPTS(ppi)->ethernet_mode) {
PP_PRINTF("posix_net_init IEEE 802.3\n");
......
......@@ -42,7 +42,6 @@ int main(int argc, char **argv)
ppi->timePropertiesDS = calloc(1, sizeof(*ppi->timePropertiesDS));
ppi->net_path = calloc(1, sizeof(*ppi->net_path));
ppi->servo = calloc(1, sizeof(*ppi->servo));
ppi->buf_out = calloc(1, PP_PACKET_SIZE);
ppi->frgn_master = calloc(1, sizeof(*ppi->frgn_master));
ppi->arch_data = calloc(1, sizeof(struct posix_arch_data));
......
......@@ -154,7 +154,10 @@ struct pp_net_path {
/* FIXME check if useful Integer32 ucast_addr;*/
Integer32 mcast_addr;
Integer32 peer_mcast_addr;
int proto_ofst;
};
#define PROTO_HDR(x) ( (x) - NP(ppi)->proto_ofst);
#define PROTO_PAYLOAD(x) ( (x) + NP(ppi)->proto_ofst);
/*
* Structure for the standard protocol
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment