Rev 4731 | Rev 4743 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4731 | Rev 4732 | ||
---|---|---|---|
Line 147... | Line 147... | ||
147 | int index; |
147 | int index; |
148 | 148 | ||
149 | printf( "Task %d - ", task_get_id()); |
149 | printf( "Task %d - ", task_get_id()); |
150 | printf( "%s\n", NAME ); |
150 | printf( "%s\n", NAME ); |
151 | 151 | ||
- | 152 | if( argc <= 1 ){ |
|
- | 153 | print_help(); |
|
- | 154 | return EINVAL; |
|
- | 155 | } |
|
- | 156 | ||
152 | for( index = 1; ( index < argc - 1 ) || (( index == argc ) && ( argv[ index ][ 0 ] == '-' )); ++ index ){ |
157 | for( index = 1; ( index < argc - 1 ) || (( index == argc ) && ( argv[ index ][ 0 ] == '-' )); ++ index ){ |
153 | if( argv[ index ][ 0 ] == '-' ){ |
158 | if( argv[ index ][ 0 ] == '-' ){ |
154 | switch( argv[ index ][ 1 ] ){ |
159 | switch( argv[ index ][ 1 ] ){ |
155 | case 'c': ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & count, "count", 0 )); |
160 | case 'c': ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & count, "count", 0 )); |
156 | break; |
161 | break; |
Line 166... | Line 171... | ||
166 | timeout = (value >= 0 ) ? ( suseconds_t ) value : 0; |
171 | timeout = (value >= 0 ) ? ( suseconds_t ) value : 0; |
167 | break; |
172 | break; |
168 | case 'v': verbose = 1; |
173 | case 'v': verbose = 1; |
169 | break; |
174 | break; |
170 | case '-': if( str_lcmp( argv[ index ] + 2, "count=", 6 ) == 0 ){ |
175 | case '-': if( str_lcmp( argv[ index ] + 2, "count=", 6 ) == 0 ){ |
171 | ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & count, "received count", 8 )) |
176 | ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & count, "received count", 8 )); |
172 | }else if( str_lcmp( argv[ index ] + 2, "dont_fragment", 13 ) == 0 ){ |
177 | }else if( str_lcmp( argv[ index ] + 2, "dont_fragment", 13 ) == 0 ){ |
173 | dont_fragment = 1; |
178 | dont_fragment = 1; |
174 | }else if( str_lcmp( argv[ index ] + 2, "family=", 7 ) == 0 ){ |
179 | }else if( str_lcmp( argv[ index ] + 2, "family=", 7 ) == 0 ){ |
175 | ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & family, "address family", 9, parse_address_family )); |
180 | ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & family, "address family", 9, parse_address_family )); |
176 | }else if( str_lcmp( argv[ index ] + 2, "help", 5 ) == 0 ){ |
181 | }else if( str_lcmp( argv[ index ] + 2, "help", 5 ) == 0 ){ |
Line 219... | Line 224... | ||
219 | address_in6->sin6_family = AF_INET6; |
224 | address_in6->sin6_family = AF_INET6; |
220 | address_start = ( uint8_t * ) & address_in6->sin6_addr.s6_addr; |
225 | address_start = ( uint8_t * ) & address_in6->sin6_addr.s6_addr; |
221 | addrlen = sizeof( struct sockaddr_in6 ); |
226 | addrlen = sizeof( struct sockaddr_in6 ); |
222 | break; |
227 | break; |
223 | default: |
228 | default: |
224 | fprintf( stderr, "Protocol family is not supported\n" ); |
229 | fprintf( stderr, "Address family is not supported\n" ); |
225 | return EAFNOSUPPORT; |
230 | return EAFNOSUPPORT; |
226 | } |
231 | } |
227 | 232 | ||
228 | if( ERROR_OCCURRED( inet_pton( family, argv[ argc - 1 ], address_start ))){ |
233 | if( ERROR_OCCURRED( inet_pton( family, argv[ argc - 1 ], address_start ))){ |
229 | fprintf( stderr, "Address parse error %d\n", ERROR_CODE ); |
234 | fprintf( stderr, "Address parse error %d\n", ERROR_CODE ); |
230 | return ERROR_CODE; |
235 | return ERROR_CODE; |
231 | } |
236 | } |
232 | 237 | ||
- | 238 | // TODO timeout? |
|
233 | icmp_phone = icmp_connect_module( SERVICE_ICMP ); |
239 | icmp_phone = icmp_connect_module( SERVICE_ICMP ); |
234 | if( icmp_phone < 0 ){ |
240 | if( icmp_phone < 0 ){ |
235 | fprintf( stderr, "ICMP connect error %d\n", icmp_phone ); |
241 | fprintf( stderr, "ICMP connect error %d\n", icmp_phone ); |
236 | } |
242 | } |
237 | 243 |