~ubuntu-branches/ubuntu/saucy/ucarp/saucy

« back to all changes in this revision

Viewing changes to src/garp.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Evans
  • Date: 2004-12-24 12:39:30 UTC
  • Revision ID: james.westby@ubuntu.com-20041224123930-9qnzcd6o5j0jjjvm
Tags: 1.1-2
Patched to correct a bug that caused upscript to also be applied
when state changed to BACKUP, if --dowscript was passed before
--upscript, (Closes: #284891). Thanks Michail Bachmann
<michail.bachmann@cms.hu-berlin.de>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <config.h>
2
2
#include "ucarp.h"
3
3
#include "garp.h"
 
4
#include "log.h"
4
5
 
5
6
#ifdef WITH_DMALLOC
6
7
# include <dmalloc.h>
32
33
        memset(&arp[24], 0xff, ETHER_ADDR_LEN);        
33
34
    }
34
35
    if ((pkt = ALLOCA(sizeof *eh_ptr + sizeof arp)) == NULL) {
35
 
        perror("out of memory to send gratuitous arp");
 
36
        logfile(LOG_ERR, _("out of memory to send gratuitous ARP"));
36
37
        return -1;
37
38
    }
38
39
    memcpy(pkt + sizeof *eh_ptr, arp, sizeof arp);
39
 
    eh_ptr = (struct ether_header *) pkt;
40
 
    memcpy(eh_ptr->ether_shost, &arp[8], ETHER_ADDR_LEN);
41
 
    memcpy(eh_ptr->ether_dhost, &arp[18], ETHER_ADDR_LEN);
42
 
    eh_ptr->ether_type = htons(ETHERTYPE_ARP);    
 
40
    {
 
41
        struct ether_header eh;
 
42
        
 
43
        memcpy(&eh, pkt, sizeof eh);
 
44
        memcpy(&eh.ether_shost, &arp[8], ETHER_ADDR_LEN);
 
45
        memcpy(&eh.ether_dhost, &arp[18], ETHER_ADDR_LEN);
 
46
        eh.ether_type = htons(ETHERTYPE_ARP);
 
47
        memcpy(pkt, &eh, sizeof eh);
 
48
    }
43
49
    if (write(dev_desc_fd, pkt, sizeof *eh_ptr + sizeof arp) < 0) {
44
50
#ifdef DEBUG
45
 
        perror("write");
 
51
        logfile(LOG_DEBUG, "write() in garp: %s", strerror(errno));
46
52
#endif
47
53
        ALLOCA_FREE(pkt);
48
54
        return -1;