@@ -72,24 +72,32 @@ EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
72
72
73
73
#if defined(DEBUG ) || defined(CONFIG_DYNAMIC_DEBUG )
74
74
/* PptpControlMessageType names */
75
- const char * const pptp_msg_name [ ] = {
76
- "UNKNOWN_MESSAGE" ,
77
- "START_SESSION_REQUEST" ,
78
- "START_SESSION_REPLY" ,
79
- "STOP_SESSION_REQUEST" ,
80
- "STOP_SESSION_REPLY" ,
81
- "ECHO_REQUEST" ,
82
- "ECHO_REPLY" ,
83
- "OUT_CALL_REQUEST" ,
84
- "OUT_CALL_REPLY" ,
85
- "IN_CALL_REQUEST" ,
86
- "IN_CALL_REPLY" ,
87
- "IN_CALL_CONNECT" ,
88
- "CALL_CLEAR_REQUEST" ,
89
- "CALL_DISCONNECT_NOTIFY" ,
90
- "WAN_ERROR_NOTIFY" ,
91
- "SET_LINK_INFO"
75
+ static const char * const pptp_msg_name_array [ PPTP_MSG_MAX + 1 ] = {
76
+ [ 0 ] = "UNKNOWN_MESSAGE" ,
77
+ [ PPTP_START_SESSION_REQUEST ] = "START_SESSION_REQUEST" ,
78
+ [ PPTP_START_SESSION_REPLY ] = "START_SESSION_REPLY" ,
79
+ [ PPTP_STOP_SESSION_REQUEST ] = "STOP_SESSION_REQUEST" ,
80
+ [ PPTP_STOP_SESSION_REPLY ] = "STOP_SESSION_REPLY" ,
81
+ [ PPTP_ECHO_REQUEST ] = "ECHO_REQUEST" ,
82
+ [ PPTP_ECHO_REPLY ] = "ECHO_REPLY" ,
83
+ [ PPTP_OUT_CALL_REQUEST ] = "OUT_CALL_REQUEST" ,
84
+ [ PPTP_OUT_CALL_REPLY ] = "OUT_CALL_REPLY" ,
85
+ [ PPTP_IN_CALL_REQUEST ] = "IN_CALL_REQUEST" ,
86
+ [ PPTP_IN_CALL_REPLY ] = "IN_CALL_REPLY" ,
87
+ [ PPTP_IN_CALL_CONNECT ] = "IN_CALL_CONNECT" ,
88
+ [ PPTP_CALL_CLEAR_REQUEST ] = "CALL_CLEAR_REQUEST" ,
89
+ [ PPTP_CALL_DISCONNECT_NOTIFY ] = "CALL_DISCONNECT_NOTIFY" ,
90
+ [ PPTP_WAN_ERROR_NOTIFY ] = "WAN_ERROR_NOTIFY" ,
91
+ [ PPTP_SET_LINK_INFO ] = "SET_LINK_INFO"
92
92
};
93
+
94
+ const char * const pptp_msg_name (u_int16_t msg )
95
+ {
96
+ if (msg > PPTP_MSG_MAX )
97
+ return pptp_msg_name_array [0 ];
98
+
99
+ return pptp_msg_name_array [msg ];
100
+ }
93
101
EXPORT_SYMBOL (pptp_msg_name );
94
102
#endif
95
103
@@ -276,7 +284,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff,
276
284
typeof (nf_nat_pptp_hook_inbound ) nf_nat_pptp_inbound ;
277
285
278
286
msg = ntohs (ctlh -> messageType );
279
- pr_debug ("inbound control message %s\n" , pptp_msg_name [ msg ] );
287
+ pr_debug ("inbound control message %s\n" , pptp_msg_name ( msg ) );
280
288
281
289
switch (msg ) {
282
290
case PPTP_START_SESSION_REPLY :
@@ -311,7 +319,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff,
311
319
pcid = pptpReq -> ocack .peersCallID ;
312
320
if (info -> pns_call_id != pcid )
313
321
goto invalid ;
314
- pr_debug ("%s, CID=%X, PCID=%X\n" , pptp_msg_name [ msg ] ,
322
+ pr_debug ("%s, CID=%X, PCID=%X\n" , pptp_msg_name ( msg ) ,
315
323
ntohs (cid ), ntohs (pcid ));
316
324
317
325
if (pptpReq -> ocack .resultCode == PPTP_OUTCALL_CONNECT ) {
@@ -328,7 +336,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff,
328
336
goto invalid ;
329
337
330
338
cid = pptpReq -> icreq .callID ;
331
- pr_debug ("%s, CID=%X\n" , pptp_msg_name [ msg ] , ntohs (cid ));
339
+ pr_debug ("%s, CID=%X\n" , pptp_msg_name ( msg ) , ntohs (cid ));
332
340
info -> cstate = PPTP_CALL_IN_REQ ;
333
341
info -> pac_call_id = cid ;
334
342
break ;
@@ -347,7 +355,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff,
347
355
if (info -> pns_call_id != pcid )
348
356
goto invalid ;
349
357
350
- pr_debug ("%s, PCID=%X\n" , pptp_msg_name [ msg ] , ntohs (pcid ));
358
+ pr_debug ("%s, PCID=%X\n" , pptp_msg_name ( msg ) , ntohs (pcid ));
351
359
info -> cstate = PPTP_CALL_IN_CONF ;
352
360
353
361
/* we expect a GRE connection from PAC to PNS */
@@ -357,7 +365,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff,
357
365
case PPTP_CALL_DISCONNECT_NOTIFY :
358
366
/* server confirms disconnect */
359
367
cid = pptpReq -> disc .callID ;
360
- pr_debug ("%s, CID=%X\n" , pptp_msg_name [ msg ] , ntohs (cid ));
368
+ pr_debug ("%s, CID=%X\n" , pptp_msg_name ( msg ) , ntohs (cid ));
361
369
info -> cstate = PPTP_CALL_NONE ;
362
370
363
371
/* untrack this call id, unexpect GRE packets */
@@ -384,7 +392,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff,
384
392
invalid :
385
393
pr_debug ("invalid %s: type=%d cid=%u pcid=%u "
386
394
"cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n" ,
387
- msg <= PPTP_MSG_MAX ? pptp_msg_name [ msg ] : pptp_msg_name [ 0 ] ,
395
+ pptp_msg_name ( msg ) ,
388
396
msg , ntohs (cid ), ntohs (pcid ), info -> cstate , info -> sstate ,
389
397
ntohs (info -> pns_call_id ), ntohs (info -> pac_call_id ));
390
398
return NF_ACCEPT ;
@@ -404,7 +412,7 @@ pptp_outbound_pkt(struct sk_buff *skb, unsigned int protoff,
404
412
typeof (nf_nat_pptp_hook_outbound ) nf_nat_pptp_outbound ;
405
413
406
414
msg = ntohs (ctlh -> messageType );
407
- pr_debug ("outbound control message %s\n" , pptp_msg_name [ msg ] );
415
+ pr_debug ("outbound control message %s\n" , pptp_msg_name ( msg ) );
408
416
409
417
switch (msg ) {
410
418
case PPTP_START_SESSION_REQUEST :
@@ -426,7 +434,7 @@ pptp_outbound_pkt(struct sk_buff *skb, unsigned int protoff,
426
434
info -> cstate = PPTP_CALL_OUT_REQ ;
427
435
/* track PNS call id */
428
436
cid = pptpReq -> ocreq .callID ;
429
- pr_debug ("%s, CID=%X\n" , pptp_msg_name [ msg ] , ntohs (cid ));
437
+ pr_debug ("%s, CID=%X\n" , pptp_msg_name ( msg ) , ntohs (cid ));
430
438
info -> pns_call_id = cid ;
431
439
break ;
432
440
@@ -440,7 +448,7 @@ pptp_outbound_pkt(struct sk_buff *skb, unsigned int protoff,
440
448
pcid = pptpReq -> icack .peersCallID ;
441
449
if (info -> pac_call_id != pcid )
442
450
goto invalid ;
443
- pr_debug ("%s, CID=%X PCID=%X\n" , pptp_msg_name [ msg ] ,
451
+ pr_debug ("%s, CID=%X PCID=%X\n" , pptp_msg_name ( msg ) ,
444
452
ntohs (cid ), ntohs (pcid ));
445
453
446
454
if (pptpReq -> icack .resultCode == PPTP_INCALL_ACCEPT ) {
@@ -480,7 +488,7 @@ pptp_outbound_pkt(struct sk_buff *skb, unsigned int protoff,
480
488
invalid :
481
489
pr_debug ("invalid %s: type=%d cid=%u pcid=%u "
482
490
"cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n" ,
483
- msg <= PPTP_MSG_MAX ? pptp_msg_name [ msg ] : pptp_msg_name [ 0 ] ,
491
+ pptp_msg_name ( msg ) ,
484
492
msg , ntohs (cid ), ntohs (pcid ), info -> cstate , info -> sstate ,
485
493
ntohs (info -> pns_call_id ), ntohs (info -> pac_call_id ));
486
494
return NF_ACCEPT ;
0 commit comments