Browse Source

Eliminate PF_INET; just use the AF_INET from the struct sockaddr instead.

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
1311b4194c
1 changed files with 20 additions and 12 deletions
  1. 20
    12
      src/net/tcp.c

+ 20
- 12
src/net/tcp.c View File

11
 #include <gpxe/refcnt.h>
11
 #include <gpxe/refcnt.h>
12
 #include <gpxe/xfer.h>
12
 #include <gpxe/xfer.h>
13
 #include <gpxe/open.h>
13
 #include <gpxe/open.h>
14
+#include <gpxe/uri.h>
14
 #include <gpxe/tcpip.h>
15
 #include <gpxe/tcpip.h>
15
 #include <gpxe/tcp.h>
16
 #include <gpxe/tcp.h>
16
 
17
 
962
  ***************************************************************************
963
  ***************************************************************************
963
  */
964
  */
964
 
965
 
965
-#warning "Placeholder URI opener"
966
+/** TCP socket opener */
967
+struct socket_opener tcp_socket_opener __socket_opener = {
968
+	.semantics	= SOCK_STREAM,
969
+	.family		= AF_INET,
970
+	.open		= tcp_open,
971
+};
972
+
973
+/**
974
+ * Open TCP URI
975
+ *
976
+ * @v xfer		Data transfer interface
977
+ * @v uri		URI
978
+ * @ret rc		Return status code
979
+ */
966
 static int tcp_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
980
 static int tcp_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
967
-	struct sockaddr_in peer;
981
+	struct sockaddr_tcpip peer;
968
 
982
 
969
 	memset ( &peer, 0, sizeof ( peer ) );
983
 	memset ( &peer, 0, sizeof ( peer ) );
970
-	peer.sin_family = AF_INET;
971
-	peer.sin_addr.s_addr = htonl ( 0x0afefe02 );
972
-	peer.sin_port = htons ( 12345 );
973
-	return tcp_open ( xfer, &peer, NULL );
984
+	peer.st_port = htons ( uri_port ( uri, 0 ) );
985
+	return xfer_open_named_socket ( xfer, SOCK_STREAM,
986
+					( struct sockaddr * ) &peer,
987
+					uri->host, NULL );
974
 }
988
 }
975
 
989
 
976
 /** TCP URI opener */
990
 /** TCP URI opener */
979
 	.open		= tcp_open_uri,
993
 	.open		= tcp_open_uri,
980
 };
994
 };
981
 
995
 
982
-/** TCP socket opener */
983
-struct socket_opener tcp_socket_opener __socket_opener = {
984
-	.domain		= PF_INET,
985
-	.type		= SOCK_STREAM,
986
-	.open		= tcp_open,
987
-};

Loading…
Cancel
Save