1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- $OpenBSD: patch-src_node_c,v 1.3 2017/05/06 17:23:10 naddy Exp $
- Index: src/node.c
- --- src/node.c.orig
- +++ src/node.c
- @@ -49,7 +49,7 @@ int init( void )
- global.self.addr.sin_family = AF_INET;
- global.self.addr.sin_addr.s_addr = INADDR_ANY;
- if( !global.self.addr.sin_port )
- - global.self.addr.sin_port = DEFAULT_PORT; // no port chosen, use default
- + global.self.addr.sin_port = htons(DEFAULT_PORT); // no port chosen, use default
- global.self.sa_len = sizeof(global.self.addr);
-
- if( bind( global.self.socket,
- @@ -67,7 +67,7 @@ void sleep_mode( void )
- (struct sockaddr *)&global.master.addr,
- &global.master.sa_len );
- FD_SET(global.master.socket, &global.net_fds);
- - strcpy(global.master.ipstr,(u_char *)inet_ntoa(&global.master.addr.sin_addr));
- + strcpy(global.master.ipstr,(u_char *)inet_ntoa(global.master.addr.sin_addr));
- // indicate a first time connect to master
- write( global.master.socket, FIRST_SEND, strlen(FIRST_SEND) );
- }
- @@ -102,21 +102,22 @@ void clean_up( int exit_status )
-
-
- /////////////////////////////
- -int main( int argc, u_char **argv )
- +int main( int argc, char **argv )
- {
- u_int exit_state = 0;
- global.self.addr.sin_port = 0;
-
- // check for specific port request at command line
- - if(!commline_handler(argc,argv))
- + if(!commline_handler(argc,(u_char **)argv))
- clean_up(1);
- if(!init())
- - error("could not initialize on port: %d\n", global.self.addr.sin_port );
- + error("could not initialize on port: %d\n",
- + ntohs(global.self.addr.sin_port) );
-
- while(!exit_state)
- {
- // sleep
- - print_handler("listening on: %d\n", global.self.addr.sin_port );
- + print_handler("listening on: %d\n", ntohs(global.self.addr.sin_port) );
- sleep_mode();
- // awake
- print_handler("master connected at %s.\n",
- @@ -139,7 +140,7 @@ int main( int argc, u_char **argv )
- static u_int len;
-
- read(global.master.socket, netbuf, MAX_PACKET_SIZE);
- - if( pstr = message_handler(netbuf,&len) )
- + if( (pstr = message_handler(netbuf,&len)) )
- {
- write( global.master.socket, pstr, len );
- print(".\n");
|