@@ -118,7 +118,7 @@ static pcap_t* checkpcap(lua_State* L)
118118{
119119 pcap_t * * cap = luaL_checkudata (L , 1 , L_PCAP_REGID );
120120
121- luaL_argcheck (L , * cap , 1 , "pcap has been destroyed " );
121+ luaL_argcheck (L , * cap , 1 , "pcap has been closed " );
122122
123123 return * cap ;
124124}
@@ -172,6 +172,25 @@ static int lpcap_open_live(lua_State *L)
172172}
173173
174174
175+ /*-
176+ -- dumper:close()
177+
178+ Manually close a dumper object, freeing it's resources (this will happen on
179+ garbage collection if not done explicitly).
180+ */
181+ static int lpcap_dump_close (lua_State * L )
182+ {
183+ pcap_dumper_t * * dumper = luaL_checkudata (L , 1 , L_PCAP_DUMPER_REGID );
184+
185+ if (* dumper )
186+ pcap_dump_close (* dumper );
187+
188+ * dumper = NULL ;
189+
190+ return 0 ;
191+ }
192+
193+
175194/*-
176195-- pcap.DLT = { EN10MB=DLT_EN10MB, [DLT_EN10MB] = "EN10MB", ... }
177196
@@ -388,12 +407,12 @@ static int lpcap_next(lua_State* L)
388407}
389408
390409/*-
391- -- cap:destroy ()
410+ -- cap:close ()
392411
393- Manually destroy a cap object, freeing it's resources (this will happen on
412+ Manually close a cap object, freeing it's resources (this will happen on
394413garbage collection if not done explicitly).
395414*/
396- static int lpcap_destroy (lua_State * L )
415+ static int lpcap_close (lua_State * L )
397416{
398417 pcap_t * * cap = luaL_checkudata (L , 1 , L_PCAP_REGID );
399418
@@ -411,7 +430,7 @@ static pcap_dumper_t* checkdumper(lua_State* L)
411430{
412431 pcap_dumper_t * * dumper = luaL_checkudata (L , 1 , L_PCAP_DUMPER_REGID );
413432
414- luaL_argcheck (L , * dumper , 1 , "pcap dumper has been destroyed " );
433+ luaL_argcheck (L , * dumper , 1 , "pcap dumper has been closed " );
415434
416435 return * dumper ;
417436}
@@ -488,25 +507,6 @@ static int lpcap_flush(lua_State* L)
488507 return 2 ;
489508}
490509
491- /*-
492- -- dumper:destroy()
493-
494- Manually destroy a dumper object, freeing it's resources (this will happen on
495- garbage collection if not done explicitly).
496- */
497- static int lpcap_dump_destroy (lua_State * L )
498- {
499- pcap_dumper_t * * dumper = luaL_checkudata (L , 1 , L_PCAP_DUMPER_REGID );
500-
501- if (* dumper )
502- pcap_dump_close (* dumper );
503-
504- * dumper = NULL ;
505-
506- return 0 ;
507- }
508-
509-
510510/* timeval to second conversions */
511511/* These don't need to be external, but are useful to test timeval conversion from lua. */
512512/*-
@@ -552,19 +552,19 @@ static const luaL_reg pcap_module[] =
552552
553553static const luaL_reg pcap_methods [] =
554554{
555+ {"__gc" , lpcap_close },
556+ {"close" , lpcap_close },
555557 {"dump_open" , lpcap_dump_open },
556558 {"set_filter" , lpcap_set_filter },
557559 {"datalink" , lpcap_datalink },
558560 {"next" , lpcap_next },
559- {"__gc" , lpcap_destroy },
560- {"close" , lpcap_destroy },
561561 {NULL , NULL }
562562};
563563
564564static const luaL_reg dumper_methods [] =
565565{
566- {"__gc" , lpcap_dump_destroy },
567- {"close" , lpcap_dump_destroy },
566+ {"__gc" , lpcap_dump_close },
567+ {"close" , lpcap_dump_close },
568568 {"dump" , lpcap_dump },
569569 {"flush" , lpcap_flush },
570570 {NULL , NULL }
0 commit comments