123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- $OpenBSD: patch-src_master_c,v 1.3 2017/05/06 17:23:10 naddy Exp $
- Index: src/master.c
- --- src/master.c.orig
- +++ src/master.c
- @@ -56,7 +56,7 @@ int init( void )
- strcpy( global.node[id]->ipstr, str );
- global.node[id]->addr.sin_addr.s_addr = inet_addr(str);
- fscanf(fp,"%s\n", str );
- - global.node[id]->addr.sin_port = atoi(str);
- + global.node[id]->addr.sin_port = htons(atoi(str));
- global.node[id]->addr.sin_family = AF_INET;
- global.node[id]->socket = socket( AF_INET, SOCK_STREAM, 0 );
- }
- @@ -132,12 +132,12 @@ char *get_time_str( u_int seconds )
- return timestr;
- }
-
- -int main( int argc, u_char **argv )
- +int main( int argc, char **argv )
- {
- static unsigned id, init_time;
-
- global.num_nodes = 0;
- - if(!commline_handler(argc,argv))
- + if(!commline_handler(argc,(u_char **)argv))
- clean_up(1);
- if(!init())
- error("error: could not load %s\n", NODES_FILE );
- @@ -147,7 +147,7 @@ int main( int argc, u_char **argv )
- {
- print_handler("connecting to: %s %d: ",
- global.node[id]->ipstr,
- - global.node[id]->addr.sin_port );
- + ntohs(global.node[id]->addr.sin_port) );
- if(!connect_node(id))
- print_handler("connect failed.\n");
- else
- @@ -181,13 +181,13 @@ int main( int argc, u_char **argv )
- {
- static u_char *pstr;
- static u_int len;
- - if( pstr = message_handler(netbuf,&len) )
- + if( (pstr = message_handler(netbuf,&len)) )
- write( global.node[id++]->socket, pstr, len );
- else
- {
- print("closing connection: %s %d.\n",
- global.node[id]->ipstr,
- - global.node[id]->addr.sin_port );
- + ntohs(global.node[id]->addr.sin_port) );
- disconnect_node(id);
- }
- }
|