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
 	}
64
 	}
65
 
65
 
66
 	/* Attempt bind to local port */
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
 		return rc;
70
 		return rc;
71
+	}
69
 
72
 
70
 	/* Add to UDP connection list */
73
 	/* Add to UDP connection list */
71
 	list_add ( &conn->list, &udp_conns );
74
 	list_add ( &conn->list, &udp_conns );
122
 
125
 
123
 	rc = conn->udp_op->senddata ( conn, conn->tx_pkb->data, 
126
 	rc = conn->udp_op->senddata ( conn, conn->tx_pkb->data, 
124
 				      pkb_tailroom ( conn->tx_pkb ) );
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
 	if ( conn->tx_pkb ) {
133
 	if ( conn->tx_pkb ) {
127
 		free_pkb ( conn->tx_pkb );
134
 		free_pkb ( conn->tx_pkb );
146
 		     size_t len ) {
153
 		     size_t len ) {
147
        	struct udp_header *udphdr;
154
        	struct udp_header *udphdr;
148
 	struct pk_buff *pkb;
155
 	struct pk_buff *pkb;
156
+	int rc;
149
 
157
 
150
 	/* Use precreated packet buffer if one is available */
158
 	/* Use precreated packet buffer if one is available */
151
 	if ( conn->tx_pkb ) {
159
 	if ( conn->tx_pkb ) {
183
 	       ntohs ( udphdr->len ) );
191
 	       ntohs ( udphdr->len ) );
184
 
192
 
185
 	/* Send it to the next layer for processing */
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
 	/* Pass data to application */
316
 	/* Pass data to application */
302
 	rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ),
317
 	rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ),
303
 				     st_src, st_dest );
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
  done:
324
  done:
306
 	free_pkb ( pkb );
325
 	free_pkb ( pkb );

Loading…
Cancel
Save