* Data has arrived. */
| 257 | * Data has arrived. |
| 258 | */ |
| 259 | static int |
| 260 | ng_car_rcvdata(hook_p hook, item_p item ) |
| 261 | { |
| 262 | struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook); |
| 263 | struct mbuf *m; |
| 264 | int error = 0; |
| 265 | u_int len; |
| 266 | |
| 267 | /* If queue is not empty now then enqueue packet. */ |
| 268 | if (hinfo->q_first != hinfo->q_last) { |
| 269 | ng_car_enqueue(hinfo, item); |
| 270 | return (0); |
| 271 | } |
| 272 | |
| 273 | m = NGI_M(item); |
| 274 | |
| 275 | #define NG_CAR_PERFORM_MATCH_ACTION(a) \ |
| 276 | do { \ |
| 277 | switch (a) { \ |
| 278 | case NG_CAR_ACTION_FORWARD: \ |
| 279 | /* Do nothing. */ \ |
| 280 | break; \ |
| 281 | case NG_CAR_ACTION_MARK: \ |
| 282 | /* XXX find a way to mark packets (mbuf tag?) */ \ |
| 283 | ++hinfo->stats.errors; \ |
| 284 | break; \ |
| 285 | case NG_CAR_ACTION_DROP: \ |
| 286 | default: \ |
| 287 | /* Drop packet and return. */ \ |
| 288 | NG_FREE_ITEM(item); \ |
| 289 | ++hinfo->stats.dropped_pkts; \ |
| 290 | return (0); \ |
| 291 | } \ |
| 292 | } while (0) |
| 293 | |
| 294 | /* Packet is counted as 128 tokens for better resolution */ |
nothing calls this directly
no test coverage detected