View | Details | Raw Unified | Return to bug 25847
Collapse All | Expand All

(-)nos-tun.c (-3 / +18 lines)
Lines 239-249 Link Here
239
  char *point_to = NULL;
239
  char *point_to = NULL;
240
  char *to_point = NULL;
240
  char *to_point = NULL;
241
  char *target;
241
  char *target;
242
  char *source = NULL;
242
  char *protocol = NULL;
243
  char *protocol = NULL;
243
  int protnum;
244
  int protnum;
244
245
245
  struct sockaddr t_laddr;          /* Source address of tunnel */
246
  struct sockaddr t_laddr;          /* Source address of tunnel */
246
  struct sockaddr whereto;          /* Destination of tunnel */
247
  struct sockaddr whereto;          /* Destination of tunnel */
248
  struct sockaddr wherefrom;        /* Source of tunnel */
247
  struct sockaddr_in *to;
249
  struct sockaddr_in *to;
248
250
249
  char buf[0x2000];                 /* Packets buffer */
251
  char buf[0x2000];                 /* Packets buffer */
Lines 272-278 Link Here
272
  argc -= optind;
274
  argc -= optind;
273
  argv += optind;
275
  argv += optind;
274
276
275
  if (argc != 1 || (devname == NULL) ||
277
  if ((argc != 1 && argc != 2) || (devname == NULL) ||
276
      (point_to == NULL) || (to_point == NULL)) {
278
      (point_to == NULL) || (to_point == NULL)) {
277
    usage();
279
    usage();
278
  }
280
  }
Lines 282-288 Link Here
282
  else
284
  else
283
      protnum = atoi(protocol);
285
      protnum = atoi(protocol);
284
286
285
  target = *argv;
287
  if (argc == 1) {
288
      target = *argv;
289
  } else {
290
      source = *argv++; target = *argv;
291
  }
286
292
287
  /* Establish logging through 'syslog' */
293
  /* Establish logging through 'syslog' */
288
  openlog("nos-tun", LOG_PID, LOG_DAEMON);
294
  openlog("nos-tun", LOG_PID, LOG_DAEMON);
Lines 306-311 Link Here
306
    Finish(5);
312
    Finish(5);
307
  }
313
  }
308
314
315
  if (source) { 
316
	if (Set_address(source, (struct sockaddr_in *)&wherefrom))
317
	  Finish(9);
318
    if (bind(net, &wherefrom, sizeof(wherefrom)) < 0) {
319
	  syslog(LOG_ERR, "can't bind source address - %m");
320
	  Finish(10);
321
	}
322
  }
323
309
  if (connect(net,&whereto,sizeof(struct sockaddr_in)) < 0 ) {
324
  if (connect(net,&whereto,sizeof(struct sockaddr_in)) < 0 ) {
310
    syslog(LOG_ERR,"can't connect to target - %m");
325
    syslog(LOG_ERR,"can't connect to target - %m");
311
    close(net);
326
    close(net);
Lines 365-371 Link Here
365
usage()
380
usage()
366
{
381
{
367
	fprintf(stderr,
382
	fprintf(stderr,
368
"usage: nos-tun -t <tun_name> -s <source_addr> -d <dest_addr> -p <protocol_number> <target_addr>\n");
383
"usage: nos-tun -t <tun_name> -s <source_addr> -d <dest_addr> -p <protocol_number> [<source_addr>] <target_addr>\n");
369
	exit(1);
384
	exit(1);
370
}
385
}

Return to bug 25847