Browse Source

[tftp] Add EUNIQ_xx values to differentiate the many EINVAL errors

tags/v0.9.6
Michael Brown 16 years ago
parent
commit
cbf9003d66
1 changed files with 16 additions and 7 deletions
  1. 16
    7
      src/net/udp/tftp.c

+ 16
- 7
src/net/udp/tftp.c View File

45
 
45
 
46
 FEATURE ( FEATURE_PROTOCOL, "TFTP", DHCP_EB_FEATURE_TFTP, 1 );
46
 FEATURE ( FEATURE_PROTOCOL, "TFTP", DHCP_EB_FEATURE_TFTP, 1 );
47
 
47
 
48
+/* TFTP-specific error codes */
49
+#define ETFTP_INVALID_BLKSIZE	EUNIQ_01
50
+#define ETFTP_INVALID_TSIZE	EUNIQ_02
51
+#define ETFTP_MC_NO_PORT	EUNIQ_03
52
+#define ETFTP_MC_NO_MC		EUNIQ_04
53
+#define ETFTP_MC_INVALID_MC	EUNIQ_05
54
+#define ETFTP_MC_INVALID_IP	EUNIQ_06
55
+#define ETFTP_MC_INVALID_PORT	EUNIQ_07
56
+
48
 /**
57
 /**
49
  * A TFTP request
58
  * A TFTP request
50
  *
59
  *
504
 	if ( *end ) {
513
 	if ( *end ) {
505
 		DBGC ( tftp, "TFTP %p got invalid blksize \"%s\"\n",
514
 		DBGC ( tftp, "TFTP %p got invalid blksize \"%s\"\n",
506
 		       tftp, value );
515
 		       tftp, value );
507
-		return -EINVAL;
516
+		return -( EINVAL | ETFTP_INVALID_BLKSIZE );
508
 	}
517
 	}
509
 	DBGC ( tftp, "TFTP %p blksize=%d\n", tftp, tftp->blksize );
518
 	DBGC ( tftp, "TFTP %p blksize=%d\n", tftp, tftp->blksize );
510
 
519
 
526
 	if ( *end ) {
535
 	if ( *end ) {
527
 		DBGC ( tftp, "TFTP %p got invalid tsize \"%s\"\n",
536
 		DBGC ( tftp, "TFTP %p got invalid tsize \"%s\"\n",
528
 		       tftp, value );
537
 		       tftp, value );
529
-		return -EINVAL;
538
+		return -( EINVAL | ETFTP_INVALID_TSIZE );
530
 	}
539
 	}
531
 	DBGC ( tftp, "TFTP %p tsize=%ld\n", tftp, tftp->tsize );
540
 	DBGC ( tftp, "TFTP %p tsize=%ld\n", tftp, tftp->tsize );
532
 
541
 
560
 	port = strchr ( addr, ',' );
569
 	port = strchr ( addr, ',' );
561
 	if ( ! port ) {
570
 	if ( ! port ) {
562
 		DBGC ( tftp, "TFTP %p multicast missing port,mc\n", tftp );
571
 		DBGC ( tftp, "TFTP %p multicast missing port,mc\n", tftp );
563
-		return -EINVAL;
572
+		return -( EINVAL | ETFTP_MC_NO_PORT );
564
 	}
573
 	}
565
 	*(port++) = '\0';
574
 	*(port++) = '\0';
566
 	mc = strchr ( port, ',' );
575
 	mc = strchr ( port, ',' );
567
 	if ( ! mc ) {
576
 	if ( ! mc ) {
568
 		DBGC ( tftp, "TFTP %p multicast missing mc\n", tftp );
577
 		DBGC ( tftp, "TFTP %p multicast missing mc\n", tftp );
569
-		return -EINVAL;
578
+		return -( EINVAL | ETFTP_MC_NO_MC );
570
 	}
579
 	}
571
 	*(mc++) = '\0';
580
 	*(mc++) = '\0';
572
 
581
 
575
 		tftp->flags &= ~TFTP_FL_SEND_ACK;
584
 		tftp->flags &= ~TFTP_FL_SEND_ACK;
576
 	if ( *mc_end ) {
585
 	if ( *mc_end ) {
577
 		DBGC ( tftp, "TFTP %p multicast invalid mc %s\n", tftp, mc );
586
 		DBGC ( tftp, "TFTP %p multicast invalid mc %s\n", tftp, mc );
578
-		return -EINVAL;
587
+		return -( EINVAL | ETFTP_MC_INVALID_MC );
579
 	}
588
 	}
580
 	DBGC ( tftp, "TFTP %p is%s the master client\n",
589
 	DBGC ( tftp, "TFTP %p is%s the master client\n",
581
 	       tftp, ( ( tftp->flags & TFTP_FL_SEND_ACK ) ? "" : " not" ) );
590
 	       tftp, ( ( tftp->flags & TFTP_FL_SEND_ACK ) ? "" : " not" ) );
584
 		if ( inet_aton ( addr, &socket.sin.sin_addr ) == 0 ) {
593
 		if ( inet_aton ( addr, &socket.sin.sin_addr ) == 0 ) {
585
 			DBGC ( tftp, "TFTP %p multicast invalid IP address "
594
 			DBGC ( tftp, "TFTP %p multicast invalid IP address "
586
 			       "%s\n", tftp, addr );
595
 			       "%s\n", tftp, addr );
587
-			return -EINVAL;
596
+			return -( EINVAL | ETFTP_MC_INVALID_IP );
588
 		}
597
 		}
589
 		DBGC ( tftp, "TFTP %p multicast IP address %s\n",
598
 		DBGC ( tftp, "TFTP %p multicast IP address %s\n",
590
 		       tftp, inet_ntoa ( socket.sin.sin_addr ) );
599
 		       tftp, inet_ntoa ( socket.sin.sin_addr ) );
592
 		if ( *port_end ) {
601
 		if ( *port_end ) {
593
 			DBGC ( tftp, "TFTP %p multicast invalid port %s\n",
602
 			DBGC ( tftp, "TFTP %p multicast invalid port %s\n",
594
 			       tftp, port );
603
 			       tftp, port );
595
-			return -EINVAL;
604
+			return -( EINVAL | ETFTP_MC_INVALID_PORT );
596
 		}
605
 		}
597
 		DBGC ( tftp, "TFTP %p multicast port %d\n",
606
 		DBGC ( tftp, "TFTP %p multicast port %d\n",
598
 		       tftp, ntohs ( socket.sin.sin_port ) );
607
 		       tftp, ntohs ( socket.sin.sin_port ) );

Loading…
Cancel
Save