| 1 | --- lib/erl_interface/src/connect/ei_connect.c 2006-05-03 10:03:39.000000000 +0200 |
| 2 | +++ lib/erl_interface/src/connect/ei_connect.c 2009-01-19 14:52:25.000000000 +0100 |
| 3 | @@ -100,6 +100,11 @@ |
| 4 | |
| 5 | #define COOKIE_FILE "/.erlang.cookie" |
| 6 | #define EI_MAX_HOME_PATH 1024 |
| 7 | +#define DEFAULT_FLAGS \ |
| 8 | + (DFLAG_EXTENDED_REFERENCES \ |
| 9 | + | DFLAG_EXTENDED_PIDS_PORTS \ |
| 10 | + | DFLAG_FUN_TAGS \ |
| 11 | + | DFLAG_NEW_FUN_TAGS) |
| 12 | |
| 13 | /* FIXME why not macro? */ |
| 14 | static char *null_cookie = ""; |
| 15 | @@ -114,7 +119,7 @@ |
| 16 | static int send_status(int fd, char *status, unsigned ms); |
| 17 | static int recv_status(int fd, unsigned ms); |
| 18 | static int send_challenge(int fd, char *nodename, |
| 19 | - unsigned challenge, unsigned version, unsigned ms); |
| 20 | + unsigned challenge, unsigned version, unsigned ms, unsigned flags); |
| 21 | static int recv_challenge(int fd, unsigned *challenge, |
| 22 | unsigned *version, |
| 23 | unsigned *flags, ErlConnect *namebuf, unsigned ms); |
| 24 | @@ -129,7 +134,7 @@ |
| 25 | unsigned our_challenge, |
| 26 | char cookie[], unsigned ms); |
| 27 | static int send_name(int fd, char *nodename, |
| 28 | - unsigned version, unsigned ms); |
| 29 | + unsigned version, unsigned ms, unsigned flags); |
| 30 | |
| 31 | /* Common for both handshake types */ |
| 32 | static int recv_name(int fd, |
| 33 | @@ -566,6 +571,11 @@ |
| 34 | */ |
| 35 | int ei_connect_tmo(ei_cnode* ec, char *nodename, unsigned ms) |
| 36 | { |
| 37 | + return ei_connect_tmo_flags(ec, nodename, ms, DEFAULT_FLAGS); |
| 38 | +} |
| 39 | + |
| 40 | +int ei_connect_tmo_flags(ei_cnode* ec, char *nodename, unsigned ms, unsigned our_flags) |
| 41 | +{ |
| 42 | char *hostname, alivename[BUFSIZ]; |
| 43 | struct hostent *hp; |
| 44 | #if !defined (__WIN32__) |
| 45 | @@ -636,7 +646,7 @@ |
| 46 | } |
| 47 | } |
| 48 | #endif /* win32 */ |
| 49 | - return ei_xconnect_tmo(ec, (Erl_IpAddr) *hp->h_addr_list, alivename, ms); |
| 50 | + return ei_xconnect_tmo_flags(ec, (Erl_IpAddr) *hp->h_addr_list, alivename, ms, our_flags); |
| 51 | } /* ei_connect */ |
| 52 | |
| 53 | int ei_connect(ei_cnode* ec, char *nodename) |
| 54 | @@ -653,6 +663,11 @@ |
| 55 | */ |
| 56 | int ei_xconnect_tmo(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms) |
| 57 | { |
| 58 | + return ei_xconnect_tmo_flags(ec, adr, alivename, ms, DEFAULT_FLAGS); |
| 59 | +} |
| 60 | + |
| 61 | +int ei_xconnect_tmo_flags(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms, unsigned our_flags) |
| 62 | +{ |
| 63 | struct in_addr *ip_addr=(struct in_addr *) adr; |
| 64 | int rport = 0; /*uint16 rport = 0;*/ |
| 65 | int sockd; |
| 66 | @@ -690,7 +705,7 @@ |
| 67 | unsigned our_challenge, her_challenge; |
| 68 | unsigned char our_digest[16]; |
| 69 | |
| 70 | - if (send_name(sockd, ec->thisnodename, (unsigned) dist, ms)) |
| 71 | + if (send_name(sockd, ec->thisnodename, (unsigned) dist, ms, our_flags)) |
| 72 | goto error; |
| 73 | if (recv_status(sockd, ms)) |
| 74 | goto error; |
| 75 | @@ -749,6 +764,11 @@ |
| 76 | |
| 77 | int ei_accept_tmo(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms) |
| 78 | { |
| 79 | + return ei_accept_tmo_flags(ec, lfd, conp, ms, DEFAULT_FLAGS); |
| 80 | +} |
| 81 | + |
| 82 | +int ei_accept_tmo_flags(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms, unsigned our_flags) |
| 83 | +{ |
| 84 | int fd; |
| 85 | struct sockaddr_in cli_addr; |
| 86 | int cli_addr_len=sizeof(struct sockaddr_in); |
| 87 | @@ -786,7 +806,7 @@ |
| 88 | goto error; |
| 89 | our_challenge = gen_challenge(); |
| 90 | if (send_challenge(fd, ec->thisnodename, |
| 91 | - our_challenge, her_version, ms)) |
| 92 | + our_challenge, her_version, ms, our_flags)) |
| 93 | goto error; |
| 94 | if (recv_challenge_reply(fd, our_challenge, |
| 95 | ec->ei_connect_cookie, |
| 96 | @@ -1288,7 +1308,8 @@ |
| 97 | int f_chall, |
| 98 | unsigned challenge, |
| 99 | unsigned version, |
| 100 | - unsigned ms) |
| 101 | + unsigned ms, |
| 102 | + unsigned our_flags) |
| 103 | { |
| 104 | char *buf; |
| 105 | unsigned char *s; |
| 106 | @@ -1308,10 +1329,7 @@ |
| 107 | put16be(s,siz - 2); |
| 108 | put8(s, 'n'); |
| 109 | put16be(s, version); |
| 110 | - put32be(s, (DFLAG_EXTENDED_REFERENCES |
| 111 | - | DFLAG_EXTENDED_PIDS_PORTS |
| 112 | - | DFLAG_FUN_TAGS |
| 113 | - | DFLAG_NEW_FUN_TAGS)); |
| 114 | + put32be(s, our_flags); |
| 115 | if (f_chall) |
| 116 | put32be(s, challenge); |
| 117 | memcpy(s, nodename, strlen(nodename)); |
| 118 | @@ -1563,15 +1581,15 @@ |
| 119 | return -1; |
| 120 | } |
| 121 | |
| 122 | -static int send_name(int fd, char *nodename, unsigned version, unsigned ms) |
| 123 | +static int send_name(int fd, char *nodename, unsigned version, unsigned ms, unsigned flags) |
| 124 | { |
| 125 | - return send_name_or_challenge(fd, nodename, 0, 0, version, ms); |
| 126 | + return send_name_or_challenge(fd, nodename, 0, 0, version, ms, flags); |
| 127 | } |
| 128 | |
| 129 | static int send_challenge(int fd, char *nodename, |
| 130 | - unsigned challenge, unsigned version, unsigned ms) |
| 131 | + unsigned challenge, unsigned version, unsigned ms, unsigned flags) |
| 132 | { |
| 133 | - return send_name_or_challenge(fd, nodename, 1, challenge, version, ms); |
| 134 | + return send_name_or_challenge(fd, nodename, 1, challenge, version, ms, flags); |
| 135 | } |
| 136 | |
| 137 | static int recv_name(int fd, |