Bläddra i källkod

TFTP API changed.

tags/v0.9.3
Michael Brown 19 år sedan
förälder
incheckning
0780ecf1b6
1 ändrade filer med 26 tillägg och 16 borttagningar
  1. 26
    16
      src/core/pxe_export.c

+ 26
- 16
src/core/pxe_export.c Visa fil

@@ -760,30 +760,30 @@ PXENV_EXIT_t pxenv_stop_undi ( t_PXENV_STOP_UNDI *stop_undi ) {
760 760
  * Status: working
761 761
  */
762 762
 PXENV_EXIT_t pxenv_tftp_open ( t_PXENV_TFTP_OPEN *tftp_open ) {
763
+	struct sockaddr_in tftp_server;
763 764
 	struct tftpreq_info_t request;
764 765
 	struct tftpblk_info_t block;
765 766
 
766 767
 	DBG ( "PXENV_TFTP_OPEN" );
767 768
 	ENSURE_READY ( tftp_open );
768 769
 
769
-	/* Change server address if different */
770
-	if ( tftp_open->ServerIPAddress && 
771
-	     tftp_open->ServerIPAddress!=arptable[ARP_SERVER].ipaddr.s_addr ) {
772
-		memset(arptable[ARP_SERVER].node, 0, ETH_ALEN ); /* kill arp */
773
-		arptable[ARP_SERVER].ipaddr.s_addr=tftp_open->ServerIPAddress;
774
-	}
775
-	/* Ignore gateway address; we can route properly */
776
-	/* Fill in request structure */
777
-	request.name = tftp_open->FileName;
778
-	request.port = ntohs(tftp_open->TFTPPort);
770
+	/* Set server address and port */
771
+	tftp_server.sin_addr.s_addr = tftp_open->ServerIPAddress
772
+		? tftp_open->ServerIPAddress
773
+		: arptable[ARP_SERVER].ipaddr.s_addr;
774
+	tftp_server.sin_port = ntohs ( tftp_open->TFTPPort );
779 775
 #ifdef WORK_AROUND_BPBATCH_BUG        
780 776
 	/* Force use of port 69; BpBatch tries to use port 4 for some         
781 777
 	* bizarre reason.         */        
782
-	request.port = TFTP_PORT;
778
+	tftp_server.sin_port = TFTP_PORT;
783 779
 #endif
780
+	/* Ignore gateway address; we can route properly */
781
+	/* Fill in request structure */
782
+	request.server = &tftp_server;
783
+	request.name = tftp_open->FileName;
784 784
 	request.blksize = tftp_open->PacketSize;
785 785
 	DBG ( " %@:%d/%s (%d)", tftp_open->ServerIPAddress,
786
-	      request.port, request.name, request.blksize );
786
+	      tftp_open->TFTPPort, request.name, request.blksize );
787 787
 	if ( !request.blksize ) request.blksize = TFTP_DEFAULTSIZE_PACKET;
788 788
 	/* Make request and get first packet */
789 789
 	if ( !tftp_block ( &request, &block ) ) {
@@ -853,7 +853,8 @@ PXENV_EXIT_t pxenv_tftp_read ( t_PXENV_TFTP_READ *tftp_read ) {
853 853
  * Status: working
854 854
  */
855 855
 
856
-int pxe_tftp_read_block ( unsigned char *data, unsigned int block __unused, unsigned int len, int eof ) {
856
+int pxe_tftp_read_block ( unsigned char *data, unsigned int block __unused,
857
+			  unsigned int len, int eof ) {
857 858
 	if ( pxe_stack->readfile.buffer ) {
858 859
 		if ( pxe_stack->readfile.offset + len >=
859 860
 		     pxe_stack->readfile.bufferlen ) return -1;
@@ -865,10 +866,12 @@ int pxe_tftp_read_block ( unsigned char *data, unsigned int block __unused, unsi
865 866
 }
866 867
 
867 868
 PXENV_EXIT_t pxenv_tftp_read_file ( t_PXENV_TFTP_READ_FILE *tftp_read_file ) {
869
+	struct sockaddr_in tftp_server;
868 870
 	int rc;
869 871
 
870 872
 	DBG ( "PXENV_TFTP_READ_FILE %s to [%x,%x)", tftp_read_file->FileName,
871
-	      tftp_read_file->Buffer, tftp_read_file->Buffer + tftp_read_file->BufferSize );
873
+	      tftp_read_file->Buffer,
874
+	      tftp_read_file->Buffer + tftp_read_file->BufferSize );
872 875
 	ENSURE_READY ( tftp_read_file );
873 876
 
874 877
 	/* inserted by Klaus Wittemeier */
@@ -877,11 +880,18 @@ PXENV_EXIT_t pxenv_tftp_read_file ( t_PXENV_TFTP_READ_FILE *tftp_read_file ) {
877 880
 	memcpy(KERNEL_BUF, tftp_read_file->FileName, sizeof(KERNEL_BUF));
878 881
 	/* end of insertion */
879 882
 
883
+	/* Set server address and port */
884
+	tftp_server.sin_addr.s_addr = tftp_read_file->ServerIPAddress
885
+		? tftp_read_file->ServerIPAddress
886
+		: arptable[ARP_SERVER].ipaddr.s_addr;
887
+	tftp_server.sin_port = ntohs ( tftp_read_file->TFTPSrvPort );
888
+
880 889
 	pxe_stack->readfile.buffer = phys_to_virt ( tftp_read_file->Buffer );
881 890
 	pxe_stack->readfile.bufferlen = tftp_read_file->BufferSize;
882 891
 	pxe_stack->readfile.offset = 0;
883 892
 
884
-	rc = tftp ( tftp_read_file->FileName, pxe_tftp_read_block );
893
+	rc = tftp ( NULL, &tftp_server, tftp_read_file->FileName,
894
+		    pxe_tftp_read_block );
885 895
 	if ( rc ) {
886 896
 		tftp_read_file->Status = PXENV_STATUS_FAILURE;
887 897
 		return PXENV_EXIT_FAILURE;
@@ -906,7 +916,7 @@ PXENV_EXIT_t pxenv_tftp_get_fsize ( t_PXENV_TFTP_GET_FSIZE *tftp_get_fsize ) {
906 916
 	pxe_stack->readfile.bufferlen = 0;
907 917
 	pxe_stack->readfile.offset = 0;
908 918
 
909
-	rc = tftp ( tftp_get_fsize->FileName, pxe_tftp_read_block );
919
+#warning "Rewrite pxenv_tftp_get_fsize, please"
910 920
 	if ( rc ) {
911 921
 		tftp_get_fsize->FileSize = 0;
912 922
 		tftp_get_fsize->Status = PXENV_STATUS_FAILURE;

Laddar…
Avbryt
Spara