Browse Source

Minor edits

tags/v0.9.3
Nikhil Chandru Rao 18 years ago
parent
commit
13dbf5494d
2 changed files with 11 additions and 4 deletions
  1. 1
    1
      src/include/gpxe/udp.h
  2. 10
    3
      src/net/udp.c

+ 1
- 1
src/include/gpxe/udp.h View File

@@ -75,7 +75,7 @@ struct udp_operations {
75 75
  */
76 76
 struct udp_connection {
77 77
        /** Address of the remote end of the connection */
78
-	struct sockaddr sin;
78
+	struct sockaddr sa;
79 79
 	/** Local port on which the connection receives packets */
80 80
 	port_t local_port;
81 81
 	/** Transmit buffer */

+ 10
- 3
src/net/udp.c View File

@@ -65,7 +65,7 @@ void udp_dump ( struct udp_header *udphdr ) {
65 65
  * This function stores the socket address within the connection
66 66
  */
67 67
 void udp_connect ( struct udp_connection *conn, struct sockaddr *peer ) {
68
-	copy_sockaddr ( peer, &conn->sin );
68
+	copy_sockaddr ( peer, &conn->sa );
69 69
 
70 70
 	/* Not sure if this should add the connection to udp_conns; If it does,
71 71
 	 * uncomment the following code
@@ -142,8 +142,15 @@ int udp_sendto ( struct udp_connection *conn, struct sockaddr *peer,
142 142
 	udphdr->dest_port = *dest;
143 143
 	udphdr->source_port = conn->local_port;
144 144
 	udphdr->len = htons ( pkb_len ( conn->tx_pkb ) );
145
-	udphdr->chksum = htons ( calc_chksum ( udphdr, sizeof ( *udphdr ) ) );
145
+	/**
146
+	 * Calculate the partial checksum. Note this is stored in host byte
147
+	 * order.
148
+	 */
149
+	udphdr->chksum = calc_chksum ( udphdr, sizeof ( *udphdr ) + len );
146 150
 
151
+	/**
152
+	 * Dump the contents of the UDP header
153
+	 */
147 154
 	udp_dump ( udphdr );
148 155
 
149 156
 	/* Send it to the next layer for processing */
@@ -158,7 +165,7 @@ int udp_sendto ( struct udp_connection *conn, struct sockaddr *peer,
158 165
  * @v len       Length of data
159 166
  */
160 167
 int udp_send ( struct udp_connection *conn, const void *data, size_t len ) {
161
-	return udp_sendto ( conn, &conn->sin, data, len );
168
+	return udp_sendto ( conn, &conn->sa, data, len );
162 169
 }
163 170
 
164 171
 /**

Loading…
Cancel
Save