Преглед изворни кода

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

tags/v0.9.6
Michael Brown пре 16 година
родитељ
комит
cbf9003d66
1 измењених фајлова са 16 додато и 7 уклоњено
  1. 16
    7
      src/net/udp/tftp.c

+ 16
- 7
src/net/udp/tftp.c Прегледај датотеку

@@ -45,6 +45,15 @@
45 45
 
46 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 58
  * A TFTP request
50 59
  *
@@ -504,7 +513,7 @@ static int tftp_process_blksize ( struct tftp_request *tftp,
504 513
 	if ( *end ) {
505 514
 		DBGC ( tftp, "TFTP %p got invalid blksize \"%s\"\n",
506 515
 		       tftp, value );
507
-		return -EINVAL;
516
+		return -( EINVAL | ETFTP_INVALID_BLKSIZE );
508 517
 	}
509 518
 	DBGC ( tftp, "TFTP %p blksize=%d\n", tftp, tftp->blksize );
510 519
 
@@ -526,7 +535,7 @@ static int tftp_process_tsize ( struct tftp_request *tftp,
526 535
 	if ( *end ) {
527 536
 		DBGC ( tftp, "TFTP %p got invalid tsize \"%s\"\n",
528 537
 		       tftp, value );
529
-		return -EINVAL;
538
+		return -( EINVAL | ETFTP_INVALID_TSIZE );
530 539
 	}
531 540
 	DBGC ( tftp, "TFTP %p tsize=%ld\n", tftp, tftp->tsize );
532 541
 
@@ -560,13 +569,13 @@ static int tftp_process_multicast ( struct tftp_request *tftp,
560 569
 	port = strchr ( addr, ',' );
561 570
 	if ( ! port ) {
562 571
 		DBGC ( tftp, "TFTP %p multicast missing port,mc\n", tftp );
563
-		return -EINVAL;
572
+		return -( EINVAL | ETFTP_MC_NO_PORT );
564 573
 	}
565 574
 	*(port++) = '\0';
566 575
 	mc = strchr ( port, ',' );
567 576
 	if ( ! mc ) {
568 577
 		DBGC ( tftp, "TFTP %p multicast missing mc\n", tftp );
569
-		return -EINVAL;
578
+		return -( EINVAL | ETFTP_MC_NO_MC );
570 579
 	}
571 580
 	*(mc++) = '\0';
572 581
 
@@ -575,7 +584,7 @@ static int tftp_process_multicast ( struct tftp_request *tftp,
575 584
 		tftp->flags &= ~TFTP_FL_SEND_ACK;
576 585
 	if ( *mc_end ) {
577 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 589
 	DBGC ( tftp, "TFTP %p is%s the master client\n",
581 590
 	       tftp, ( ( tftp->flags & TFTP_FL_SEND_ACK ) ? "" : " not" ) );
@@ -584,7 +593,7 @@ static int tftp_process_multicast ( struct tftp_request *tftp,
584 593
 		if ( inet_aton ( addr, &socket.sin.sin_addr ) == 0 ) {
585 594
 			DBGC ( tftp, "TFTP %p multicast invalid IP address "
586 595
 			       "%s\n", tftp, addr );
587
-			return -EINVAL;
596
+			return -( EINVAL | ETFTP_MC_INVALID_IP );
588 597
 		}
589 598
 		DBGC ( tftp, "TFTP %p multicast IP address %s\n",
590 599
 		       tftp, inet_ntoa ( socket.sin.sin_addr ) );
@@ -592,7 +601,7 @@ static int tftp_process_multicast ( struct tftp_request *tftp,
592 601
 		if ( *port_end ) {
593 602
 			DBGC ( tftp, "TFTP %p multicast invalid port %s\n",
594 603
 			       tftp, port );
595
-			return -EINVAL;
604
+			return -( EINVAL | ETFTP_MC_INVALID_PORT );
596 605
 		}
597 606
 		DBGC ( tftp, "TFTP %p multicast port %d\n",
598 607
 		       tftp, ntohs ( socket.sin.sin_port ) );

Loading…
Откажи
Сачувај