Changeset 13883


Ignore:
Timestamp:
2009-01-06T15:08:07+01:00 (9 years ago)
Author:
nbd
Message:

ead: allow the client to override the source ip of the server, so that it can work with route filtering properly

Location:
trunk/package/ead/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/ead/src/ead-client.c

    r13849 r13883  
    4545static int s = 0; 
    4646static int sockflags; 
     47static struct in_addr serverip = { 
     48        .s_addr = 0x01010101 /* dummy */ 
     49}; 
    4750 
    4851static unsigned char *skey = NULL; 
     
    8184 
    8285        type = htonl(type); 
     86        memcpy(&msg->ip, &serverip.s_addr, sizeof(msg->ip)); 
    8387        set_nonblock(0); 
    8488        sendto(s, msgbuf, sizeof(struct ead_msg) + ntohl(msg->len), 0, (struct sockaddr *) &remote, sizeof(remote)); 
     
    295299usage(const char *prog) 
    296300{ 
    297         fprintf(stderr, "Usage: %s [-b <addr>] <node> <username>[:<password>] <command>\n" 
     301        fprintf(stderr, "Usage: %s [-s <addr>] [-b <addr>] <node> <username>[:<password>] <command>\n" 
    298302                "\n" 
     303                "\t-s <addr>:  Set the server's source address to <addr>\n" 
    299304                "\t-b <addr>:  Set the broadcast address to <addr>\n" 
    300305                "\t<node>:     Node ID (4 digits hex)\n" 
     
    329334        local.sin_port = 0; 
    330335 
    331         while ((ch = getopt(argc, argv, "b:")) != -1) { 
     336        while ((ch = getopt(argc, argv, "b:s:h")) != -1) { 
    332337                switch(ch) { 
     338                case 's': 
     339                        inet_aton(optarg, &serverip); 
     340                        break; 
    333341                case 'b': 
    334342                        inet_aton(optarg, &remote.sin_addr); 
    335343                        break; 
     344                case 'h': 
     345                        return usage(prog); 
    336346                } 
    337347        } 
  • trunk/package/ead/src/ead.c

    r13846 r13883  
    251251        pktbuf->len[0] = len >> 8; 
    252252        pktbuf->len[1] = len & 0xff; 
    253         memcpy(pktbuf->srcipaddr, pkt->destipaddr, 4); 
     253        memcpy(pktbuf->srcipaddr, &pkt->msg.ip, 4); 
    254254        memcpy(pktbuf->destipaddr, pkt->srcipaddr, 4); 
    255255 
  • trunk/package/ead/src/ead.h

    r13849 r13883  
    1515#define __EAD_H 
    1616 
    17 #define EAD_DEBUGLEVEL  2 
     17#define EAD_DEBUGLEVEL  1 
    1818 
    1919#include <stdint.h> 
     
    121121        uint16_t nid; /* node id */ 
    122122        uint16_t tid; /* transaction id */ 
     123        uint32_t ip; /* source ip for responses from the server */ 
    123124        union { 
    124125                struct ead_msg_pong pong; 
Note: See TracChangeset for help on using the changeset viewer.