diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-08-30 01:27:34 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-08-30 01:27:34 +0200 |
commit | de3da7a6e42478f9092c82cd8b767a5c93730e84 (patch) | |
tree | 1cac223ff2d7c18681db15aec80af5b55344198d | |
parent | 044be347c872df833a454b76adfec817ada1be8c (diff) | |
download | ffd-de3da7a6e42478f9092c82cd8b767a5c93730e84.tar ffd-de3da7a6e42478f9092c82cd8b767a5c93730e84.zip |
Fix minimum packet size
-rw-r--r-- | ffvisd/ffvisd.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ffvisd/ffvisd.c b/ffvisd/ffvisd.c index d1b36f0..93e9b1b 100644 --- a/ffvisd/ffvisd.c +++ b/ffvisd/ffvisd.c @@ -462,7 +462,8 @@ static void send_announcement(const char *ifname, unsigned ifindex, void *arg) { sa.sll_halen = ETH_ALEN; memcpy(sa.sll_addr, ffd_addr.address, ETH_ALEN); - sendto(sockfd, packet, sizeof(ffvisd_packet_announce_t) + ntohs(packet->n_servers)*sizeof(ffvisd_packet_server_announce_t), 0, (struct sockaddr*)&sa, sizeof(sa)); + unsigned len = sizeof(ffvisd_packet_announce_t) + ntohs(packet->n_servers)*sizeof(ffvisd_packet_server_announce_t); + sendto(sockfd, packet, len > 46 ? len : 46, 0, (struct sockaddr*)&sa, sizeof(sa)); } free(if_mesh); } @@ -470,6 +471,8 @@ static void send_announcement(const char *ifname, unsigned ifindex, void *arg) { static void send_announcements() { ffvisd_packet_announce_t *packet = alloca(sizeof(ffvisd_packet_announce_t) + 75*sizeof(ffvisd_packet_server_announce_t)); + memset(packet, 0, 46); /* minimum ethernet packet size is 46 bytes */ + packet->magic = htons(FFD_MAGIC); packet->version = htons(FFVISD_VERSION); packet->csum = 0; |