Parcourir la source

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

tags/v0.9.3
Michael Brown il y a 17 ans
Parent
révision
a1210e4fca
3 fichiers modifiés avec 43 ajouts et 50 suppressions
  1. 11
    13
      src/core/open.c
  2. 11
    7
      src/include/gpxe/open.h
  3. 21
    30
      src/include/gpxe/socket.h

+ 11
- 13
src/core/open.c Voir le fichier

@@ -75,30 +75,29 @@ int xfer_open_uri ( struct xfer_interface *xfer, const char *uri_string ) {
75 75
  * Open socket
76 76
  *
77 77
  * @v xfer		Data transfer interface
78
- * @v domain		Communication domain (e.g. PF_INET)
79
- * @v type		Communication semantics (e.g. SOCK_STREAM)
78
+ * @v semantics		Communication semantics (e.g. SOCK_STREAM)
80 79
  * @v peer		Peer socket address
81 80
  * @v local		Local socket address, or NULL
82 81
  * @ret rc		Return status code
83 82
  */
84
-int xfer_open_socket ( struct xfer_interface *xfer,
85
-		       int domain, int type, struct sockaddr *peer,
86
-		       struct sockaddr *local ) {
83
+int xfer_open_socket ( struct xfer_interface *xfer, int semantics,
84
+		       struct sockaddr *peer, struct sockaddr *local ) {
87 85
 	struct socket_opener *opener;
88 86
 
89 87
 	DBGC ( xfer, "XFER %p opening (%s,%s) socket\n", xfer,
90
-	       socket_domain_name ( domain ), socket_type_name ( type ) );
88
+	       socket_semantics_name ( semantics ),
89
+	       socket_family_name ( peer->sa_family ) );
91 90
 
92 91
 	for ( opener = socket_openers; opener < socket_openers_end; opener++ ){
93
-		if ( ( opener->domain == domain ) &&
94
-		     ( opener->type == type ) ) {
92
+		if ( ( opener->semantics == semantics ) &&
93
+		     ( opener->family == peer->sa_family ) ) {
95 94
 			return opener->open ( xfer, peer, local );
96 95
 		}
97 96
 	}
98 97
 
99 98
 	DBGC ( xfer, "XFER %p attempted to open unsupported socket type "
100
-	       "(%s,%s)\n", xfer, socket_domain_name ( domain ),
101
-	       socket_type_name ( type ) );
99
+	       "(%s,%s)\n", xfer, socket_semantics_name ( semantics ),
100
+	       socket_family_name ( peer->sa_family ) );
102 101
 	return -ENOTSUP;
103 102
 }
104 103
 
@@ -117,12 +116,11 @@ int xfer_vopen ( struct xfer_interface *xfer, int type, va_list args ) {
117 116
 
118 117
 		return xfer_open_uri ( xfer, uri_string ); }
119 118
 	case LOCATION_SOCKET: {
120
-		int domain = va_arg ( args, int );
121
-		int type = va_arg ( args, int );
119
+		int semantics = va_arg ( args, int );
122 120
 		struct sockaddr *peer = va_arg ( args, struct sockaddr * );
123 121
 		struct sockaddr *local = va_arg ( args, struct sockaddr * );
124 122
 
125
-		return xfer_open_socket ( xfer, domain, type, peer, local ); }
123
+		return xfer_open_socket ( xfer, semantics, peer, local ); }
126 124
 	default:
127 125
 		DBGC ( xfer, "XFER %p attempted to open unsupported location "
128 126
 		       "type %d\n", xfer, type );

+ 11
- 7
src/include/gpxe/open.h Voir le fichier

@@ -26,7 +26,9 @@ enum {
26 26
 	 *
27 27
 	 * Parameter list for open() is:
28 28
 	 *
29
-	 * 
29
+	 * int semantics;
30
+	 * struct sockaddr *peer;
31
+	 * struct sockaddr *local;
30 32
 	 */
31 33
 	LOCATION_SOCKET,
32 34
 };
@@ -56,10 +58,10 @@ struct uri_opener {
56 58
 
57 59
 /** A socket opener */
58 60
 struct socket_opener {
59
-	/** Communication domain (e.g. PF_INET) */
60
-	int domain;
61 61
 	/** Communication semantics (e.g. SOCK_STREAM) */
62
-	int type;
62
+	int semantics;
63
+	/** Address family (e.g. AF_INET) */
64
+	int family;
63 65
 	/** Open socket
64 66
 	 *
65 67
 	 * @v xfer		Data transfer interface
@@ -76,9 +78,11 @@ struct socket_opener {
76 78
 
77 79
 extern int xfer_open_uri ( struct xfer_interface *xfer,
78 80
 			   const char *uri_string );
79
-extern int xfer_open_socket ( struct xfer_interface *xfer,
80
-			      int domain, int type, struct sockaddr *peer,
81
-			      struct sockaddr *local );
81
+extern int xfer_open_named_socket ( struct xfer_interface *xfer,
82
+				    int semantics, struct sockaddr *peer,
83
+				    const char *name, struct sockaddr *local );
84
+extern int xfer_open_socket ( struct xfer_interface *xfer, int semantics,
85
+			      struct sockaddr *peer, struct sockaddr *local );
82 86
 extern int xfer_vopen ( struct xfer_interface *xfer, int type, va_list args );
83 87
 extern int xfer_open ( struct xfer_interface *xfer, int type, ... );
84 88
 

+ 21
- 30
src/include/gpxe/socket.h Voir le fichier

@@ -8,31 +8,7 @@
8 8
  */
9 9
 
10 10
 /**
11
- * @defgroup commdomains Communication domains
12
- *
13
- * @{
14
- */
15
-#define PF_INET		1	/**< IPv4 Internet protocols */
16
-#define PF_INET6	2	/**< IPv6 Internet protocols */
17
-/** @} */
18
-
19
-/**
20
- * Name communication domain
21
- *
22
- * @v domain		Communication domain (e.g. PF_INET)
23
- * @ret name		Name of communication domain
24
- */
25
-static inline __attribute__ (( always_inline )) const char *
26
-socket_domain_name ( int domain ) {
27
-	switch ( domain ) {
28
-	case PF_INET:		return "PF_INET";
29
-	case PF_INET6:		return "PF_INET6";
30
-	default:		return "PF_UNKNOWN";
31
-	}
32
-}
33
-
34
-/**
35
- * @defgroup commtypes Communication types
11
+ * @defgroup commtypes Communication semantics
36 12
  *
37 13
  * @{
38 14
  */
@@ -41,14 +17,14 @@ socket_domain_name ( int domain ) {
41 17
 /** @} */
42 18
 
43 19
 /**
44
- * Name communication type
20
+ * Name communication semantics
45 21
  *
46
- * @v type		Communication type (e.g. SOCK_STREAM)
47
- * @ret name		Name of communication type
22
+ * @v semantics		Communication semantics (e.g. SOCK_STREAM)
23
+ * @ret name		Name of communication semantics
48 24
  */
49 25
 static inline __attribute__ (( always_inline )) const char *
50
-socket_type_name ( int type ) {
51
-	switch ( type ) {
26
+socket_semantics_name ( int semantics ) {
27
+	switch ( semantics ) {
52 28
 	case SOCK_STREAM:	return "SOCK_STREAM";
53 29
 	case SOCK_DGRAM:	return "SOCK_DGRAM";
54 30
 	default:		return "SOCK_UNKNOWN";
@@ -64,6 +40,21 @@ socket_type_name ( int type ) {
64 40
 #define AF_INET6	2	/**< IPv6 Internet addresses */
65 41
 /** @} */
66 42
 
43
+/**
44
+ * Name address family
45
+ *
46
+ * @v family		Address family (e.g. AF_INET)
47
+ * @ret name		Name of address family
48
+ */
49
+static inline __attribute__ (( always_inline )) const char *
50
+socket_family_name ( int family ) {
51
+	switch ( family ) {
52
+	case AF_INET:		return "AF_INET";
53
+	case AF_INET6:		return "AF_INET6";
54
+	default:		return "AF_UNKNOWN";
55
+	}
56
+}
57
+
67 58
 /** A socket address family */
68 59
 typedef uint16_t sa_family_t;
69 60
 

Chargement…
Annuler
Enregistrer