Browse Source

Improve debug messages

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
bcdb6fad3e
1 changed files with 21 additions and 2 deletions
  1. 21
    2
      src/net/udp.c

+ 21
- 2
src/net/udp.c View File

@@ -64,8 +64,11 @@ int udp_open ( struct udp_connection *conn, uint16_t local_port ) {
64 64
 	}
65 65
 
66 66
 	/* Attempt bind to local port */
67
-	if ( ( rc = udp_bind ( conn, local_port ) ) != 0 )
67
+	if ( ( rc = udp_bind ( conn, local_port ) ) != 0 ) {
68
+		DBGC ( conn, "UDP %p could not bind to local port %d: %s\n",
69
+		       conn, local_port, strerror ( rc ) );
68 70
 		return rc;
71
+	}
69 72
 
70 73
 	/* Add to UDP connection list */
71 74
 	list_add ( &conn->list, &udp_conns );
@@ -122,6 +125,10 @@ int udp_senddata ( struct udp_connection *conn ) {
122 125
 
123 126
 	rc = conn->udp_op->senddata ( conn, conn->tx_pkb->data, 
124 127
 				      pkb_tailroom ( conn->tx_pkb ) );
128
+	if ( rc != 0 ) {
129
+		DBGC ( conn, "UDP %p application could not send packet: %s\n",
130
+		       conn, strerror ( rc ) );
131
+	}
125 132
 
126 133
 	if ( conn->tx_pkb ) {
127 134
 		free_pkb ( conn->tx_pkb );
@@ -146,6 +153,7 @@ int udp_sendto_via ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
146 153
 		     size_t len ) {
147 154
        	struct udp_header *udphdr;
148 155
 	struct pk_buff *pkb;
156
+	int rc;
149 157
 
150 158
 	/* Use precreated packet buffer if one is available */
151 159
 	if ( conn->tx_pkb ) {
@@ -183,7 +191,14 @@ int udp_sendto_via ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
183 191
 	       ntohs ( udphdr->len ) );
184 192
 
185 193
 	/* Send it to the next layer for processing */
186
-	return tcpip_tx ( pkb, &udp_protocol, peer, netdev, &udphdr->chksum );
194
+	if ( ( rc = tcpip_tx ( pkb, &udp_protocol, peer, netdev,
195
+			       &udphdr->chksum ) ) != 0 ) {
196
+		DBGC ( conn, "UDP %p could not transmit packet: %s\n",
197
+		       conn, strerror ( rc ) );
198
+		return rc;
199
+	}
200
+
201
+	return 0;
187 202
 }
188 203
 
189 204
 /**
@@ -301,6 +316,10 @@ static int udp_rx ( struct pk_buff *pkb, struct sockaddr_tcpip *st_src,
301 316
 	/* Pass data to application */
302 317
 	rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ),
303 318
 				     st_src, st_dest );
319
+	if ( rc != 0 ) {
320
+		DBGC ( conn, "UDP %p application rejected packet: %s\n",
321
+		       conn, strerror ( rc ) );
322
+	}
304 323
 
305 324
  done:
306 325
 	free_pkb ( pkb );

Loading…
Cancel
Save