patch-src_node_c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. $OpenBSD: patch-src_node_c,v 1.3 2017/05/06 17:23:10 naddy Exp $
  2. Index: src/node.c
  3. --- src/node.c.orig
  4. +++ src/node.c
  5. @@ -49,7 +49,7 @@ int init( void )
  6. global.self.addr.sin_family = AF_INET;
  7. global.self.addr.sin_addr.s_addr = INADDR_ANY;
  8. if( !global.self.addr.sin_port )
  9. - global.self.addr.sin_port = DEFAULT_PORT; // no port chosen, use default
  10. + global.self.addr.sin_port = htons(DEFAULT_PORT); // no port chosen, use default
  11. global.self.sa_len = sizeof(global.self.addr);
  12. if( bind( global.self.socket,
  13. @@ -67,7 +67,7 @@ void sleep_mode( void )
  14. (struct sockaddr *)&global.master.addr,
  15. &global.master.sa_len );
  16. FD_SET(global.master.socket, &global.net_fds);
  17. - strcpy(global.master.ipstr,(u_char *)inet_ntoa(&global.master.addr.sin_addr));
  18. + strcpy(global.master.ipstr,(u_char *)inet_ntoa(global.master.addr.sin_addr));
  19. // indicate a first time connect to master
  20. write( global.master.socket, FIRST_SEND, strlen(FIRST_SEND) );
  21. }
  22. @@ -102,21 +102,22 @@ void clean_up( int exit_status )
  23. /////////////////////////////
  24. -int main( int argc, u_char **argv )
  25. +int main( int argc, char **argv )
  26. {
  27. u_int exit_state = 0;
  28. global.self.addr.sin_port = 0;
  29. // check for specific port request at command line
  30. - if(!commline_handler(argc,argv))
  31. + if(!commline_handler(argc,(u_char **)argv))
  32. clean_up(1);
  33. if(!init())
  34. - error("could not initialize on port: %d\n", global.self.addr.sin_port );
  35. + error("could not initialize on port: %d\n",
  36. + ntohs(global.self.addr.sin_port) );
  37. while(!exit_state)
  38. {
  39. // sleep
  40. - print_handler("listening on: %d\n", global.self.addr.sin_port );
  41. + print_handler("listening on: %d\n", ntohs(global.self.addr.sin_port) );
  42. sleep_mode();
  43. // awake
  44. print_handler("master connected at %s.\n",
  45. @@ -139,7 +140,7 @@ int main( int argc, u_char **argv )
  46. static u_int len;
  47. read(global.master.socket, netbuf, MAX_PACKET_SIZE);
  48. - if( pstr = message_handler(netbuf,&len) )
  49. + if( (pstr = message_handler(netbuf,&len)) )
  50. {
  51. write( global.master.socket, pstr, len );
  52. print(".\n");