Browse Source

hoffmeis: Fixing situation where absence of a newdata() handler for UDP

connections might break things. Only-sending applications like syslog()
do not need a newdata() handler, so added a check if that handler exists.
tags/v0.9.3
Anselm Martin Hoffmeister 17 years ago
parent
commit
ff5aac826a
1 changed files with 10 additions and 5 deletions
  1. 10
    5
      src/net/udp.c

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

260
 	struct udp_connection *conn;
260
 	struct udp_connection *conn;
261
 	size_t ulen;
261
 	size_t ulen;
262
 	uint16_t csum;
262
 	uint16_t csum;
263
-	int rc;
263
+	int rc = 0;
264
 
264
 
265
 	/* Sanity check packet */
265
 	/* Sanity check packet */
266
 	if ( pkb_len ( pkb ) < sizeof ( *udphdr ) ) {
266
 	if ( pkb_len ( pkb ) < sizeof ( *udphdr ) ) {
314
 	}
314
 	}
315
 
315
 
316
 	/* Pass data to application */
316
 	/* Pass data to application */
317
-	rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ),
317
+	if ( conn->udp_op->newdata ) {
318
+		rc = conn->udp_op->newdata ( conn, pkb->data, pkb_len ( pkb ),
318
 				     st_src, st_dest );
319
 				     st_src, st_dest );
319
-	if ( rc != 0 ) {
320
-		DBGC ( conn, "UDP %p application rejected packet: %s\n",
321
-		       conn, strerror ( rc ) );
320
+		if ( rc != 0 ) {
321
+			DBGC ( conn, "UDP %p application rejected packet: %s\n",
322
+			       conn, strerror ( rc ) );
323
+		}
324
+	} else {
325
+		DBGC ( conn, "UDP %p application has no newdata handler for " \
326
+			"incoming packet\n", conn );
322
 	}
327
 	}
323
 
328
 
324
  done:
329
  done:

Loading…
Cancel
Save