Changes in / [d76a329:b1213b0] in mainline
- Files:
-
- 92 added
- 120 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
rd76a329 rb1213b0 106 106 $(USPACE_PATH)/srv/fs/ext2fs/ext2fs \ 107 107 $(USPACE_PATH)/srv/hid/remcons/remcons \ 108 $(USPACE_PATH)/srv/net/ethip/ethip \ 109 $(USPACE_PATH)/srv/net/inet/inet \ 110 $(USPACE_PATH)/srv/net/tcp/tcp \ 111 $(USPACE_PATH)/srv/net/udp/udp \ 108 112 $(USPACE_PATH)/srv/taskmon/taskmon \ 109 $(USPACE_PATH)/srv/net/nil/eth/eth \110 $(USPACE_PATH)/srv/net/nil/nildummy/nildummy \111 $(USPACE_PATH)/srv/net/il/arp/arp \112 $(USPACE_PATH)/srv/net/il/ip/ip \113 $(USPACE_PATH)/srv/net/tl/icmp/icmp \114 $(USPACE_PATH)/srv/net/tl/udp/udp \115 $(USPACE_PATH)/srv/net/tl/tcp/tcp \116 $(USPACE_PATH)/srv/net/net/net \117 113 $(USPACE_PATH)/srv/devman/devman 118 114 … … 161 157 $(USPACE_PATH)/app/edit/edit \ 162 158 $(USPACE_PATH)/app/ext2info/ext2info \ 159 $(USPACE_PATH)/app/inetcfg/inetcfg \ 163 160 $(USPACE_PATH)/app/kill/kill \ 164 161 $(USPACE_PATH)/app/killall/killall \ … … 203 200 endif 204 201 205 ifneq ($(CONFIG_BAREBONE),y)206 NET_CFG = \207 $(USPACE_PATH)/srv/net/cfg/general \208 $(USPACE_PATH)/srv/net/cfg/lo.nic \209 $(USPACE_PATH)/srv/net/cfg/ne2k.nic \210 $(USPACE_PATH)/srv/net/cfg/e1k.nic211 endif212 213 202 COMPONENTS = \ 214 203 $(KERNEL_PATH)/kernel.bin \ -
uspace/Makefile
rd76a329 rb1213b0 42 42 app/getterm \ 43 43 app/init \ 44 app/inetcfg \ 44 45 app/kill \ 45 46 app/killall \ … … 74 75 srv/devman \ 75 76 srv/loader \ 77 srv/net/ethip \ 78 srv/net/inet \ 79 srv/net/tcp \ 80 srv/net/udp \ 76 81 srv/ns \ 77 82 srv/taskmon \ … … 96 101 srv/hid/remcons \ 97 102 srv/hw/char/s3c24xx_uart \ 98 srv/net/il/arp \99 srv/net/il/ip \100 srv/net/tl/icmp \101 srv/net/tl/udp \102 srv/net/tl/tcp \103 srv/net/nil/eth \104 srv/net/nil/nildummy \105 srv/net/net \106 103 drv/infrastructure/root \ 107 104 drv/infrastructure/rootvirt \ -
uspace/app/init/init.c
rd76a329 rb1213b0 305 305 srv_start("/srv/s3c24ts"); 306 306 307 spawn("/srv/net"); 307 spawn("/srv/ethip"); 308 spawn("/srv/inet"); 309 spawn("/srv/tcp"); 310 spawn("/srv/udp"); 308 311 309 312 spawn("/srv/fb"); -
uspace/app/netecho/netecho.c
rd76a329 rb1213b0 373 373 address_in.sin_family = AF_INET; 374 374 address_in.sin_port = htons(port); 375 address_in.sin_addr.s_addr = INADDR_ANY; 375 376 address = (struct sockaddr *) &address_in; 376 377 addrlen = sizeof(address_in); -
uspace/app/netecho/print_error.c
rd76a329 rb1213b0 40 40 #include <errno.h> 41 41 42 #include <net/icmp_codes.h>43 44 /** Prints the specific ICMP error description.45 *46 * @param[in] output The description output stream. May be NULL.47 * @param[in] error_code The ICMP error code.48 * @param[in] prefix The error description prefix. May be NULL.49 * @param[in] suffix The error description suffix. May be NULL.50 */51 void icmp_print_error(FILE *output, int error_code, const char *prefix, const char *suffix)52 {53 if (!output)54 return;55 56 if (prefix)57 fprintf(output, "%s", prefix);58 59 switch (error_code) {60 case ICMP_DEST_UNREACH:61 fprintf(output, "ICMP Destination Unreachable (%d) error", error_code);62 break;63 case ICMP_SOURCE_QUENCH:64 fprintf(output, "ICMP Source Quench (%d) error", error_code);65 break;66 case ICMP_REDIRECT:67 fprintf(output, "ICMP Redirect (%d) error", error_code);68 break;69 case ICMP_ALTERNATE_ADDR:70 fprintf(output, "ICMP Alternate Host Address (%d) error", error_code);71 break;72 case ICMP_ROUTER_ADV:73 fprintf(output, "ICMP Router Advertisement (%d) error", error_code);74 break;75 case ICMP_ROUTER_SOL:76 fprintf(output, "ICMP Router Solicitation (%d) error", error_code);77 break;78 case ICMP_TIME_EXCEEDED:79 fprintf(output, "ICMP Time Exceeded (%d) error", error_code);80 break;81 case ICMP_PARAMETERPROB:82 fprintf(output, "ICMP Paramenter Problem (%d) error", error_code);83 break;84 case ICMP_CONVERSION_ERROR:85 fprintf(output, "ICMP Datagram Conversion Error (%d) error", error_code);86 break;87 case ICMP_REDIRECT_MOBILE:88 fprintf(output, "ICMP Mobile Host Redirect (%d) error", error_code);89 break;90 case ICMP_SKIP:91 fprintf(output, "ICMP SKIP (%d) error", error_code);92 break;93 case ICMP_PHOTURIS:94 fprintf(output, "ICMP Photuris (%d) error", error_code);95 break;96 default:97 fprintf(output, "Other (%d) error", error_code);98 }99 100 if (suffix)101 fprintf(output, "%s", suffix);102 }103 104 42 /** Prints the error description. 105 43 * 106 * Supports ICMP andsocket error codes.44 * Supports socket error codes. 107 45 * 108 46 * @param[in] output The description output stream. May be NULL. … … 113 51 void print_error(FILE *output, int error_code, const char *prefix, const char *suffix) 114 52 { 115 if (IS_ICMP_ERROR(error_code)) 116 icmp_print_error(output, error_code, prefix, suffix); 117 else if(IS_SOCKET_ERROR(error_code)) 53 if(IS_SOCKET_ERROR(error_code)) 118 54 socket_print_error(output, error_code, prefix, suffix); 119 55 } -
uspace/app/ping/Makefile
rd76a329 rb1213b0 1 1 # 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 2 # Copyright (c) 2012 Jiri Svoboda 4 3 # All rights reserved. 5 4 # … … 29 28 30 29 USPACE_PREFIX = ../.. 31 LIBS =32 EXTRA_CFLAGS =33 30 BINARY = ping 34 31 35 32 SOURCES = \ 36 ping.c \ 37 print_error.c 33 ping.c 38 34 39 35 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/ping/ping.c
rd76a329 rb1213b0 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 30 30 * @{ 31 31 */ 32 33 /** @file 34 * Packet Internet Network Grouper. 32 /** @file ICMP echo utility. 35 33 */ 36 34 37 35 #include <async.h> 36 #include <bool.h> 37 #include <errno.h> 38 #include <fibril_synch.h> 39 #include <inet/inetping.h> 40 #include <io/console.h> 38 41 #include <stdio.h> 39 #include <str.h> 40 #include <task.h> 41 #include <time.h> 42 #include <ipc/services.h> 43 #include <str_error.h> 44 #include <errno.h> 45 #include <arg_parse.h> 46 47 #include <net/icmp_api.h> 48 #include <net/in.h> 49 #include <net/in6.h> 50 #include <net/inet.h> 51 #include <net/socket_parse.h> 52 #include <net/ip_codes.h> 53 54 #include "print_error.h" 55 56 #define NAME "ping" 57 58 #define CL_OK 0 59 #define CL_USAGE -1 60 #define CL_MISSING -2 61 #define CL_INVALID -3 62 #define CL_UNSUPPORTED -4 63 #define CL_ERROR -5 64 65 /** Ping configuration 66 * 67 */ 68 typedef struct { 69 bool verbose; /**< Verbose printouts. */ 70 size_t size; /**< Outgoing packet size. */ 71 unsigned int count; /**< Number of packets to send. */ 72 suseconds_t timeout; /**< Reply wait timeout. */ 73 int af; /**< Address family. */ 74 ip_tos_t tos; /**< Type of service. */ 75 ip_ttl_t ttl; /**< Time-to-live. */ 76 bool fragments; /**< Fragmentation. */ 77 78 char *dest_addr; /**< Destination address. */ 79 struct sockaddr_in dest; /**< IPv4 destionation. */ 80 struct sockaddr_in6 dest6; /**< IPv6 destionation. */ 81 82 struct sockaddr *dest_raw; /**< Raw destination address. */ 83 socklen_t dest_len; /**< Raw destination address length. */ 84 85 /** Converted address string. */ 86 char dest_str[INET6_ADDRSTRLEN]; 87 } ping_config_t; 88 89 90 static void usage(void) 91 { 92 printf( 93 "Usage: ping [-c count] [-s size] [-W timeout] [-f family] [-t ttl]\n" \ 94 " [-Q tos] [--dont_fragment] destination\n" \ 95 "\n" \ 96 "Options:\n" \ 97 "\t-c count\n" \ 98 "\t--count=count\n" \ 99 "\t\tNumber of outgoing packets (default: 4)\n" \ 100 "\n" \ 101 "\t-s size\n" \ 102 "\t--size=bytes\n" \ 103 "\t\tOutgoing packet size (default: 56 bytes)\n" \ 104 "\n" \ 105 "\t-W timeout\n" \ 106 "\t--timeout=ms\n" \ 107 "\t\tReply wait timeout (default: 3000 ms)\n" \ 108 "\n" \ 109 "\t-f family\n" \ 110 "\t--family=family\n" \ 111 "\t\tDestination address family, AF_INET or AF_INET6 (default: AF_INET)\n" \ 112 "\n" \ 113 "\t-t ttl\n" \ 114 "\t--ttl=ttl\n" \ 115 "\t\tOutgoing packet time-to-live (default: 0)\n" \ 116 "\n" \ 117 "\t-Q tos\n" \ 118 "\t--tos=tos\n" \ 119 "\t\tOutgoing packet type of service (default: 0)\n" \ 120 "\n" \ 121 "\t--dont_fragment\n" \ 122 "\t\tDisable packet fragmentation (default: enabled)\n" \ 123 "\n" \ 124 "\t-v\n" \ 125 "\t--verbose\n" \ 126 "\t\tVerbose operation\n" \ 127 "\n" \ 128 "\t-h\n" \ 129 "\t--help\n" \ 130 "\t\tPrint this usage information\n" 131 ); 132 } 133 134 static int args_parse(int argc, char *argv[], ping_config_t *config) 135 { 136 if (argc < 2) 137 return CL_USAGE; 138 42 #include <stdlib.h> 43 #include <sys/types.h> 44 45 #define NAME "ping" 46 47 /** Delay between subsequent ping requests in microseconds */ 48 #define PING_DELAY (1000 * 1000) 49 50 /** Ping request timeout in microseconds */ 51 #define PING_TIMEOUT (1000 * 1000) 52 53 static int ping_ev_recv(inetping_sdu_t *); 54 55 static bool done = false; 56 static FIBRIL_CONDVAR_INITIALIZE(done_cv); 57 static FIBRIL_MUTEX_INITIALIZE(done_lock); 58 59 static inetping_ev_ops_t ev_ops = { 60 .recv = ping_ev_recv 61 }; 62 63 static inet_addr_t src_addr; 64 static inet_addr_t dest_addr; 65 66 static bool ping_repeat = false; 67 68 static void print_syntax(void) 69 { 70 printf("syntax: " NAME " [-r] <addr>\n"); 71 } 72 73 static int addr_parse(const char *text, inet_addr_t *addr) 74 { 75 unsigned long a[4]; 76 char *cp = (char *)text; 139 77 int i; 140 int ret; 141 142 for (i = 1; i < argc; i++) { 143 144 /* Not an option */ 145 if (argv[i][0] != '-') 78 79 for (i = 0; i < 3; i++) { 80 a[i] = strtoul(cp, &cp, 10); 81 if (*cp != '.') 82 return EINVAL; 83 ++cp; 84 } 85 86 a[3] = strtoul(cp, &cp, 10); 87 if (*cp != '\0') 88 return EINVAL; 89 90 addr->ipv4 = 0; 91 for (i = 0; i < 4; i++) { 92 if (a[i] > 255) 93 return EINVAL; 94 addr->ipv4 = (addr->ipv4 << 8) | a[i]; 95 } 96 97 return EOK; 98 } 99 100 static int addr_format(inet_addr_t *addr, char **bufp) 101 { 102 int rc; 103 104 rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24, 105 (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff, 106 addr->ipv4 & 0xff); 107 108 if (rc < 0) 109 return ENOMEM; 110 111 return EOK; 112 } 113 114 static void ping_signal_done(void) 115 { 116 fibril_mutex_lock(&done_lock); 117 done = true; 118 fibril_mutex_unlock(&done_lock); 119 fibril_condvar_broadcast(&done_cv); 120 } 121 122 static int ping_ev_recv(inetping_sdu_t *sdu) 123 { 124 char *asrc, *adest; 125 int rc; 126 127 rc = addr_format(&sdu->src, &asrc); 128 if (rc != EOK) 129 return ENOMEM; 130 131 rc = addr_format(&sdu->dest, &adest); 132 if (rc != EOK) { 133 free(asrc); 134 return ENOMEM; 135 } 136 printf("Received ICMP echo reply: from %s to %s, seq. no %u, " 137 "payload size %zu\n", asrc, adest, sdu->seq_no, sdu->size); 138 139 if (!ping_repeat) { 140 ping_signal_done(); 141 } 142 143 free(asrc); 144 free(adest); 145 return EOK; 146 } 147 148 static int ping_send(uint16_t seq_no) 149 { 150 inetping_sdu_t sdu; 151 int rc; 152 153 sdu.src = src_addr; 154 sdu.dest = dest_addr; 155 sdu.seq_no = seq_no; 156 sdu.data = (void *) "foo"; 157 sdu.size = 3; 158 159 rc = inetping_send(&sdu); 160 if (rc != EOK) { 161 printf(NAME ": Failed sending echo request (%d).\n", rc); 162 return rc; 163 } 164 165 return EOK; 166 } 167 168 static int transmit_fibril(void *arg) 169 { 170 uint16_t seq_no = 0; 171 172 while (true) { 173 fibril_mutex_lock(&done_lock); 174 if (done) { 175 fibril_mutex_unlock(&done_lock); 176 return 0; 177 } 178 fibril_mutex_unlock(&done_lock); 179 180 (void) ping_send(++seq_no); 181 async_usleep(PING_DELAY); 182 } 183 184 return 0; 185 } 186 187 static int input_fibril(void *arg) 188 { 189 console_ctrl_t *con; 190 kbd_event_t ev; 191 192 con = console_init(stdin, stdout); 193 printf("[Press Ctrl-Q to quit]\n"); 194 195 while (true) { 196 if (!console_get_kbd_event(con, &ev)) 146 197 break; 147 148 /* Options terminator */ 149 if (str_cmp(argv[i], "--") == 0) { 150 i++; 151 break; 152 } 153 154 int off; 155 156 /* Usage */ 157 if ((off = arg_parse_short_long(argv[i], "-h", "--help")) != -1) 158 return CL_USAGE; 159 160 /* Verbose */ 161 if ((off = arg_parse_short_long(argv[i], "-v", "--verbose")) != -1) { 162 config->verbose = true; 163 continue; 164 } 165 166 /* Don't fragment */ 167 if (str_cmp(argv[i], "--dont_fragment") == 0) { 168 config->fragments = false; 169 continue; 170 } 171 172 /* Count */ 173 if ((off = arg_parse_short_long(argv[i], "-c", "--count=")) != -1) { 174 int tmp; 175 ret = arg_parse_int(argc, argv, &i, &tmp, off); 176 177 if ((ret != EOK) || (tmp < 0)) 178 return i; 179 180 config->count = (unsigned int) tmp; 181 continue; 182 } 183 184 /* Outgoing packet size */ 185 if ((off = arg_parse_short_long(argv[i], "-s", "--size=")) != -1) { 186 int tmp; 187 ret = arg_parse_int(argc, argv, &i, &tmp, off); 188 189 if ((ret != EOK) || (tmp < 0)) 190 return i; 191 192 config->size = (size_t) tmp; 193 continue; 194 } 195 196 /* Reply wait timeout */ 197 if ((off = arg_parse_short_long(argv[i], "-W", "--timeout=")) != -1) { 198 int tmp; 199 ret = arg_parse_int(argc, argv, &i, &tmp, off); 200 201 if ((ret != EOK) || (tmp < 0)) 202 return i; 203 204 config->timeout = (suseconds_t) tmp; 205 continue; 206 } 207 208 /* Address family */ 209 if ((off = arg_parse_short_long(argv[i], "-f", "--family=")) != -1) { 210 ret = arg_parse_name_int(argc, argv, &i, &config->af, off, 211 socket_parse_address_family); 212 213 if (ret != EOK) 214 return i; 215 216 continue; 217 } 218 219 /* Type of service */ 220 if ((off = arg_parse_short_long(argv[i], "-Q", "--tos=")) != -1) { 221 int tmp; 222 ret = arg_parse_name_int(argc, argv, &i, &tmp, off, 223 socket_parse_address_family); 224 225 if ((ret != EOK) || (tmp < 0)) 226 return i; 227 228 config->tos = (ip_tos_t) tmp; 229 continue; 230 } 231 232 /* Time to live */ 233 if ((off = arg_parse_short_long(argv[i], "-t", "--ttl=")) != -1) { 234 int tmp; 235 ret = arg_parse_name_int(argc, argv, &i, &tmp, off, 236 socket_parse_address_family); 237 238 if ((ret != EOK) || (tmp < 0)) 239 return i; 240 241 config->ttl = (ip_ttl_t) tmp; 242 continue; 243 } 244 } 245 246 if (i >= argc) 247 return CL_MISSING; 248 249 config->dest_addr = argv[i]; 250 251 /* Resolve destionation address */ 252 switch (config->af) { 253 case AF_INET: 254 config->dest_raw = (struct sockaddr *) &config->dest; 255 config->dest_len = sizeof(config->dest); 256 config->dest.sin_family = config->af; 257 ret = inet_pton(config->af, config->dest_addr, 258 (uint8_t *) &config->dest.sin_addr.s_addr); 259 break; 260 case AF_INET6: 261 config->dest_raw = (struct sockaddr *) &config->dest6; 262 config->dest_len = sizeof(config->dest6); 263 config->dest6.sin6_family = config->af; 264 ret = inet_pton(config->af, config->dest_addr, 265 (uint8_t *) &config->dest6.sin6_addr.s6_addr); 266 break; 267 default: 268 return CL_UNSUPPORTED; 269 } 270 271 if (ret != EOK) 272 return CL_INVALID; 273 274 /* Convert destination address back to string */ 275 switch (config->af) { 276 case AF_INET: 277 ret = inet_ntop(config->af, 278 (uint8_t *) &config->dest.sin_addr.s_addr, 279 config->dest_str, sizeof(config->dest_str)); 280 break; 281 case AF_INET6: 282 ret = inet_ntop(config->af, 283 (uint8_t *) &config->dest6.sin6_addr.s6_addr, 284 config->dest_str, sizeof(config->dest_str)); 285 break; 286 default: 287 return CL_UNSUPPORTED; 288 } 289 290 if (ret != EOK) 291 return CL_ERROR; 292 293 return CL_OK; 198 199 if (ev.type == KEY_PRESS && (ev.mods & (KM_ALT | KM_SHIFT)) == 200 0 && (ev.mods & KM_CTRL) != 0) { 201 /* Ctrl+key */ 202 if (ev.key == KC_Q) { 203 ping_signal_done(); 204 return 0; 205 } 206 } 207 } 208 209 return 0; 294 210 } 295 211 296 212 int main(int argc, char *argv[]) 297 213 { 298 ping_config_t config; 299 300 /* Default configuration */ 301 config.verbose = false; 302 config.size = 56; 303 config.count = 4; 304 config.timeout = 3000; 305 config.af = AF_INET; 306 config.tos = 0; 307 config.ttl = 0; 308 config.fragments = true; 309 310 int ret = args_parse(argc, argv, &config); 311 312 switch (ret) { 313 case CL_OK: 314 break; 315 case CL_USAGE: 316 usage(); 317 return 0; 318 case CL_MISSING: 319 fprintf(stderr, "%s: Destination address missing\n", NAME); 320 return 1; 321 case CL_INVALID: 322 fprintf(stderr, "%s: Destination address '%s' invalid or malformed\n", 323 NAME, config.dest_addr); 324 return 2; 325 case CL_UNSUPPORTED: 326 fprintf(stderr, "%s: Destination address '%s' unsupported\n", 327 NAME, config.dest_addr); 328 return 3; 329 case CL_ERROR: 330 fprintf(stderr, "%s: Destination address '%s' error\n", 331 NAME, config.dest_addr); 332 return 4; 333 default: 334 fprintf(stderr, "%s: Unknown or invalid option '%s'\n", NAME, 335 argv[ret]); 336 return 5; 337 } 338 339 printf("PING %s (%s) %zu(%zu) bytes of data\n", config.dest_addr, 340 config.dest_str, config.size, config.size); 341 342 async_sess_t *sess = icmp_connect_module(); 343 if (!sess) { 344 fprintf(stderr, "%s: Unable to connect to ICMP service (%s)\n", NAME, 345 str_error(errno)); 346 return errno; 347 } 348 349 unsigned int seq; 350 for (seq = 0; seq < config.count; seq++) { 351 struct timeval t0; 352 ret = gettimeofday(&t0, NULL); 353 if (ret != EOK) { 354 fprintf(stderr, "%s: gettimeofday failed (%s)\n", NAME, 355 str_error(ret)); 356 357 async_hangup(sess); 358 return ret; 359 } 360 361 /* Ping! */ 362 int result = icmp_echo_msg(sess, config.size, config.timeout, 363 config.ttl, config.tos, !config.fragments, config.dest_raw, 364 config.dest_len); 365 366 struct timeval t1; 367 ret = gettimeofday(&t1, NULL); 368 if (ret != EOK) { 369 fprintf(stderr, "%s: gettimeofday failed (%s)\n", NAME, 370 str_error(ret)); 371 372 async_hangup(sess); 373 return ret; 374 } 375 376 suseconds_t elapsed = tv_sub(&t1, &t0); 377 378 switch (result) { 379 case ICMP_ECHO: 380 printf("%zu bytes from ? (?): icmp_seq=%u ttl=? time=%ld.%04ld\n", 381 config.size, seq, elapsed / 1000, elapsed % 1000); 382 break; 383 case ETIMEOUT: 384 printf("%zu bytes from ? (?): icmp_seq=%u Timed out\n", 385 config.size, seq); 386 break; 387 default: 388 print_error(stdout, result, NULL, "\n"); 389 } 390 } 391 392 async_hangup(sess); 393 214 int rc; 215 int argi; 216 217 rc = inetping_init(&ev_ops); 218 if (rc != EOK) { 219 printf(NAME ": Failed connecting to internet ping service " 220 "(%d).\n", rc); 221 return 1; 222 } 223 224 argi = 1; 225 if (argi < argc && str_cmp(argv[argi], "-r") == 0) { 226 ping_repeat = true; 227 ++argi; 228 } else { 229 ping_repeat = false; 230 } 231 232 if (argc - argi != 1) { 233 print_syntax(); 234 return 1; 235 } 236 237 /* Parse destination address */ 238 rc = addr_parse(argv[argi], &dest_addr); 239 if (rc != EOK) { 240 printf(NAME ": Invalid address format.\n"); 241 print_syntax(); 242 return 1; 243 } 244 245 /* Determine source address */ 246 rc = inetping_get_srcaddr(&dest_addr, &src_addr); 247 if (rc != EOK) { 248 printf(NAME ": Failed determining source address.\n"); 249 return 1; 250 } 251 252 fid_t fid; 253 254 if (ping_repeat) { 255 fid = fibril_create(transmit_fibril, NULL); 256 if (fid == 0) { 257 printf(NAME ": Failed creating transmit fibril.\n"); 258 return 1; 259 } 260 261 fibril_add_ready(fid); 262 263 fid = fibril_create(input_fibril, NULL); 264 if (fid == 0) { 265 printf(NAME ": Failed creating input fibril.\n"); 266 return 1; 267 } 268 269 fibril_add_ready(fid); 270 } else { 271 ping_send(1); 272 } 273 274 fibril_mutex_lock(&done_lock); 275 rc = EOK; 276 while (!done && rc != ETIMEOUT) { 277 rc = fibril_condvar_wait_timeout(&done_cv, &done_lock, 278 ping_repeat ? 0 : PING_TIMEOUT); 279 } 280 fibril_mutex_unlock(&done_lock); 281 282 if (rc == ETIMEOUT) { 283 printf(NAME ": Echo request timed out.\n"); 284 return 1; 285 } 286 394 287 return 0; 395 288 } -
uspace/drv/nic/e1k/Makefile
rd76a329 rb1213b0 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBN ET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBN ET_PREFIX)/include -I$(LIBNIC_PREFIX)/include30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include 32 32 BINARY = e1k 33 33 -
uspace/drv/nic/e1k/e1k.c
rd76a329 rb1213b0 49 49 #include <device/pci.h> 50 50 #include <nic.h> 51 #include <nil_remote.h>52 51 #include <ops/nic.h> 53 52 #include "e1k.h" -
uspace/drv/nic/lo/Makefile
rd76a329 rb1213b0 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBN ET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBN ET_PREFIX)/include -I$(LIBNIC_PREFIX)/include30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include 32 32 BINARY = lo 33 33 -
uspace/drv/nic/ne2k/Makefile
rd76a329 rb1213b0 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBN ET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBN ET_PREFIX)/include -I$(LIBNIC_PREFIX)/include30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include 32 32 BINARY = ne2k 33 33 -
uspace/drv/nic/rtl8139/Makefile
rd76a329 rb1213b0 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBN ET_PREFIX)/libnet.a $(LIBNIC_PREFIX)/libnic.a31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBN ET_PREFIX)/include -I$(LIBNIC_PREFIX)/include30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNIC_PREFIX)/libnic.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBNIC_PREFIX)/include 32 32 BINARY = rtl8139 33 33 -
uspace/drv/nic/rtl8139/driver.c
rd76a329 rb1213b0 44 44 #include <sysinfo.h> 45 45 #include <ipc/ns.h> 46 47 #include <net_checksum.h>48 46 49 47 #include <str.h> -
uspace/lib/c/Makefile
rd76a329 rb1213b0 87 87 generic/task.c \ 88 88 generic/futex.c \ 89 generic/inet.c \ 90 generic/inetcfg.c \ 91 generic/inetping.c \ 89 92 generic/io/asprintf.c \ 90 93 generic/io/io.c \ … … 97 100 generic/io/printf_core.c \ 98 101 generic/io/console.c \ 102 generic/iplink.c \ 103 generic/iplink_srv.c \ 99 104 generic/malloc.c \ 100 105 generic/sysinfo.c \ … … 108 113 generic/adt/hash_set.c \ 109 114 generic/adt/dynamic_fifo.c \ 110 generic/adt/measured_strings.c \111 115 generic/adt/char_map.c \ 112 116 generic/adt/prodcons.c \ … … 118 122 generic/vfs/canonify.c \ 119 123 generic/net/inet.c \ 120 generic/net/icmp_common.c \121 generic/net/icmp_api.c \122 124 generic/net/modules.c \ 123 generic/net/packet.c \124 125 generic/net/socket_client.c \ 125 126 generic/net/socket_parse.c \ -
uspace/lib/c/include/ipc/services.h
rd76a329 rb1213b0 48 48 SERVICE_IRC = FOURCC('i', 'r', 'c', ' '), 49 49 SERVICE_CLIPBOARD = FOURCC('c', 'l', 'i', 'p'), 50 SERVICE_NETWORKING = FOURCC('n', 'e', 't', ' '),51 SERVICE_ETHERNET = FOURCC('e', 't', 'h', ' '),52 SERVICE_NILDUMMY = FOURCC('n', 'i', 'l', 'd'),53 SERVICE_IP = FOURCC('i', 'p', 'v', '4'),54 SERVICE_ARP = FOURCC('a', 'r', 'p', ' '),55 SERVICE_ICMP = FOURCC('i', 'c', 'm', 'p'),56 50 SERVICE_UDP = FOURCC('u', 'd', 'p', ' '), 57 51 SERVICE_TCP = FOURCC('t', 'c', 'p', ' ') 58 52 } services_t; 53 54 #define SERVICE_NAME_INET "net/inet" 55 #define SERVICE_NAME_INETCFG "net/inetcfg" 56 #define SERVICE_NAME_INETPING "net/inetping" 59 57 60 58 #endif -
uspace/lib/c/include/ipc/socket.h
rd76a329 rb1213b0 38 38 #define LIBC_SOCKET_MESSAGES_H_ 39 39 40 #include <ipc/net.h>41 42 40 /** Socket client messages. */ 43 41 typedef enum { 44 42 /** Creates a new socket. @see socket() */ 45 NET_SOCKET = NET_SOCKET_FIRST,43 NET_SOCKET = IPC_FIRST_USER_METHOD, 46 44 /** Binds the socket. @see bind() */ 47 45 NET_SOCKET_BIND, -
uspace/lib/c/include/net/in.h
rd76a329 rb1213b0 45 45 #define INET_ADDRSTRLEN (4 * 3 + 3 + 1) 46 46 47 #define INADDR_ANY 0 48 47 49 /** Type definition of the INET address. 48 50 * @see in_addr -
uspace/lib/net/Makefile
rd76a329 rb1213b0 33 33 34 34 SOURCES = \ 35 generic/generic.c \ 36 generic/net_remote.c \ 37 generic/net_checksum.c \ 38 generic/packet_client.c \ 39 generic/packet_remote.c \ 40 generic/protocol_map.c \ 41 adt/module_map.c \ 42 nil/nil_remote.c \ 43 nil/nil_skel.c \ 44 il/il_remote.c \ 45 il/il_skel.c \ 46 il/ip_remote.c \ 47 il/ip_client.c \ 48 il/arp_remote.c \ 49 tl/icmp_remote.c \ 50 tl/icmp_client.c \ 51 tl/socket_core.c \ 52 tl/tl_common.c \ 53 tl/tl_remote.c \ 54 tl/tl_skel.c 35 tl/socket_core.c 55 36 56 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/net/include/socket_core.h
rd76a329 rb1213b0 44 44 #include <net/in.h> 45 45 #include <net/device.h> 46 #include <net/packet.h>47 46 #include <async.h> 48 47 … … 80 79 /** Bound port. */ 81 80 int port; 82 /** Received packets queue. */83 dyn_fifo_t received;84 81 /** Sockets for acceptance queue. */ 85 82 dyn_fifo_t accepted; … … 118 115 extern int socket_destroy(async_sess_t *, int, socket_cores_t *, 119 116 socket_ports_t *, void (*)(socket_core_t *)); 120 extern int socket_reply_packets(packet_t *, size_t *);121 117 extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *, 122 118 size_t); -
uspace/lib/net/tl/socket_core.c
rd76a329 rb1213b0 36 36 37 37 #include <socket_core.h> 38 #include <packet_client.h>39 #include <packet_remote.h>40 38 #include <net/socket_codes.h> 41 39 #include <net/in.h> 42 40 #include <net/inet.h> 43 #include <net/packet.h>44 41 #include <net/modules.h> 45 42 #include <stdint.h> … … 92 89 } 93 90 94 /* Release all received packets */95 int packet_id;96 while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0)97 pq_release_remote(sess, packet_id);98 99 dyn_fifo_destroy(&socket->received);100 91 dyn_fifo_destroy(&socket->accepted); 101 92 … … 448 439 socket->key_length = 0; 449 440 socket->specific_data = specific_data; 450 rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE); 441 442 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE); 451 443 if (rc != EOK) { 452 444 free(socket); 453 445 return rc; 454 446 } 455 456 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);457 if (rc != EOK) {458 dyn_fifo_destroy(&socket->received);459 free(socket);460 return rc;461 }462 447 socket->socket_id = *socket_id; 463 448 rc = socket_cores_add(local_sockets, socket->socket_id, socket); 464 449 if (rc < 0) { 465 dyn_fifo_destroy(&socket->received);466 450 dyn_fifo_destroy(&socket->accepted); 467 451 free(socket); … … 506 490 socket_destroy_core(sess, socket, local_sockets, global_sockets, 507 491 socket_release); 508 509 return EOK;510 }511 512 /** Replies the packet or the packet queue data to the application via the513 * socket.514 *515 * Uses the current message processing fibril.516 *517 * @param[in] packet The packet to be transfered.518 * @param[out] length The total data length.519 * @return EOK on success.520 * @return EBADMEM if the length parameter is NULL.521 * @return ENOMEM if there is not enough memory left.522 * @return Other error codes as defined for the data_reply()523 * function.524 */525 int socket_reply_packets(packet_t *packet, size_t *length)526 {527 packet_t *next_packet;528 size_t fragments;529 size_t *lengths;530 size_t index;531 int rc;532 533 if (!length)534 return EBADMEM;535 536 next_packet = pq_next(packet);537 if (!next_packet) {538 /* Write all if only one fragment */539 rc = data_reply(packet_get_data(packet),540 packet_get_data_length(packet));541 if (rc != EOK)542 return rc;543 /* Store the total length */544 *length = packet_get_data_length(packet);545 } else {546 /* Count the packet fragments */547 fragments = 1;548 next_packet = pq_next(packet);549 while ((next_packet = pq_next(next_packet)))550 ++fragments;551 552 /* Compute and store the fragment lengths */553 lengths = (size_t *) malloc(sizeof(size_t) * fragments +554 sizeof(size_t));555 if (!lengths)556 return ENOMEM;557 558 lengths[0] = packet_get_data_length(packet);559 lengths[fragments] = lengths[0];560 next_packet = pq_next(packet);561 562 for (index = 1; index < fragments; ++index) {563 lengths[index] = packet_get_data_length(next_packet);564 lengths[fragments] += lengths[index];565 next_packet = pq_next(packet);566 }567 568 /* Write the fragment lengths */569 rc = data_reply(lengths, sizeof(int) * (fragments + 1));570 if (rc != EOK) {571 free(lengths);572 return rc;573 }574 next_packet = packet;575 576 /* Write the fragments */577 for (index = 0; index < fragments; ++index) {578 rc = data_reply(packet_get_data(next_packet),579 lengths[index]);580 if (rc != EOK) {581 free(lengths);582 return rc;583 }584 next_packet = pq_next(next_packet);585 }586 587 /* Store the total length */588 *length = lengths[fragments];589 free(lengths);590 }591 492 592 493 return EOK; -
uspace/srv/loc/loc.c
rd76a329 rb1213b0 1296 1296 categ_dir_add_cat(&cdir, cat); 1297 1297 1298 cat = category_new("iplink"); 1299 categ_dir_add_cat(&cdir, cat); 1300 1298 1301 cat = category_new("keyboard"); 1299 1302 categ_dir_add_cat(&cdir, cat);
Note:
See TracChangeset
for help on using the changeset viewer.