--- lib/erl_interface/src/connect/ei_connect.c	2006-05-03 10:03:39.000000000 +0200
+++ lib/erl_interface/src/connect/ei_connect.c	2009-01-19 14:52:25.000000000 +0100
@@ -100,6 +100,11 @@
 
 #define COOKIE_FILE "/.erlang.cookie"
 #define EI_MAX_HOME_PATH 1024
+#define DEFAULT_FLAGS \
+    (DFLAG_EXTENDED_REFERENCES \
+		| DFLAG_EXTENDED_PIDS_PORTS \
+		| DFLAG_FUN_TAGS \
+		| DFLAG_NEW_FUN_TAGS)
 
 /* FIXME why not macro? */
 static char *null_cookie = "";
@@ -114,7 +119,7 @@
 static int send_status(int fd, char *status, unsigned ms);
 static int recv_status(int fd, unsigned ms);
 static int send_challenge(int fd, char *nodename, 
-			  unsigned challenge, unsigned version, unsigned ms);
+			  unsigned challenge, unsigned version, unsigned ms, unsigned flags);
 static int recv_challenge(int fd, unsigned *challenge, 
 			  unsigned *version,
 			  unsigned *flags, ErlConnect *namebuf, unsigned ms);
@@ -129,7 +134,7 @@
 			      unsigned our_challenge,
 			      char cookie[], unsigned ms);
 static int send_name(int fd, char *nodename, 
-		     unsigned version, unsigned ms); 
+		     unsigned version, unsigned ms, unsigned flags); 
 
 /* Common for both handshake types */
 static int recv_name(int fd, 
@@ -566,6 +571,11 @@
 */
 int ei_connect_tmo(ei_cnode* ec, char *nodename, unsigned ms)
 {
+    return ei_connect_tmo_flags(ec, nodename, ms, DEFAULT_FLAGS);
+}
+
+int ei_connect_tmo_flags(ei_cnode* ec, char *nodename, unsigned ms, unsigned our_flags)
+{
     char *hostname, alivename[BUFSIZ];
     struct hostent *hp;
 #if !defined (__WIN32__) 
@@ -636,7 +646,7 @@
 	}
     }
 #endif /* win32 */
-    return ei_xconnect_tmo(ec, (Erl_IpAddr) *hp->h_addr_list, alivename, ms);
+    return ei_xconnect_tmo_flags(ec, (Erl_IpAddr) *hp->h_addr_list, alivename, ms, our_flags);
 } /* ei_connect */
 
 int ei_connect(ei_cnode* ec, char *nodename)
@@ -653,6 +663,11 @@
 */
 int ei_xconnect_tmo(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms)
 {
+    return ei_xconnect_tmo_flags(ec, adr, alivename, ms, DEFAULT_FLAGS);
+}
+
+int ei_xconnect_tmo_flags(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms, unsigned our_flags)
+{
     struct in_addr *ip_addr=(struct in_addr *) adr;
     int rport = 0; /*uint16 rport = 0;*/
     int sockd;
@@ -690,7 +705,7 @@
 	unsigned our_challenge, her_challenge;
 	unsigned char our_digest[16];
 	
-	if (send_name(sockd, ec->thisnodename, (unsigned) dist, ms))
+	if (send_name(sockd, ec->thisnodename, (unsigned) dist, ms, our_flags))
 	    goto error;
 	if (recv_status(sockd, ms))
 	    goto error;
@@ -749,6 +764,11 @@
 
 int ei_accept_tmo(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms)
 {
+    return ei_accept_tmo_flags(ec, lfd, conp, ms, DEFAULT_FLAGS);
+}
+
+int ei_accept_tmo_flags(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms, unsigned our_flags)
+{
     int fd;
     struct sockaddr_in cli_addr;
     int cli_addr_len=sizeof(struct sockaddr_in);
@@ -786,7 +806,7 @@
 	    goto error;
 	our_challenge = gen_challenge();
 	if (send_challenge(fd, ec->thisnodename, 
-	    our_challenge, her_version, ms))
+	    our_challenge, her_version, ms, our_flags))
 	    goto error;
 	if (recv_challenge_reply(fd, our_challenge, 
 	    ec->ei_connect_cookie, 
@@ -1288,7 +1308,8 @@
 				  int f_chall,
 				  unsigned challenge,
 				  unsigned version,
-				  unsigned ms) 
+				  unsigned ms,
+				  unsigned our_flags) 
 {
     char *buf;
     unsigned char *s;
@@ -1308,10 +1329,7 @@
     put16be(s,siz - 2);
     put8(s, 'n');
     put16be(s, version);
-    put32be(s, (DFLAG_EXTENDED_REFERENCES
-		| DFLAG_EXTENDED_PIDS_PORTS
-		| DFLAG_FUN_TAGS
-		| DFLAG_NEW_FUN_TAGS));
+    put32be(s, our_flags);
     if (f_chall)
 	put32be(s, challenge);
     memcpy(s, nodename, strlen(nodename));
@@ -1563,15 +1581,15 @@
     return -1;
 }
 
-static int send_name(int fd, char *nodename, unsigned version, unsigned ms) 
+static int send_name(int fd, char *nodename, unsigned version, unsigned ms, unsigned flags) 
 {
-    return send_name_or_challenge(fd, nodename, 0, 0, version, ms);
+    return send_name_or_challenge(fd, nodename, 0, 0, version, ms, flags);
 }
 
 static int send_challenge(int fd, char *nodename, 
-			  unsigned challenge, unsigned version, unsigned ms)
+			  unsigned challenge, unsigned version, unsigned ms, unsigned flags)
 {
-    return send_name_or_challenge(fd, nodename, 1, challenge, version, ms);
+    return send_name_or_challenge(fd, nodename, 1, challenge, version, ms, flags);
 }
 
 static int recv_name(int fd, 
