@@ -195,6 +195,55 @@ static int luaskb_forward(lua_State *L)
195195 return 0 ;
196196}
197197
198+ static int luaskb_getmark (lua_State * L )
199+ {
200+ luaskb_t * lskb = luaskb_check (L , 1 );
201+ lua_pushinteger (L , lskb -> skb -> mark );
202+ return 1 ;
203+ }
204+
205+ static int luaskb_setmark (lua_State * L )
206+ {
207+ luaskb_t * lskb = luaskb_check (L , 1 );
208+ lskb -> skb -> mark = (u32 )luaL_checkinteger (L , 2 );
209+ return 0 ;
210+ }
211+
212+ static int luaskb_getpriority (lua_State * L )
213+ {
214+ luaskb_t * lskb = luaskb_check (L , 1 );
215+ lua_pushinteger (L , lskb -> skb -> priority );
216+ return 1 ;
217+ }
218+
219+ static int luaskb_setpriority (lua_State * L )
220+ {
221+ luaskb_t * lskb = luaskb_check (L , 1 );
222+ lskb -> skb -> priority = (u32 )luaL_checkinteger (L , 2 );
223+ return 0 ;
224+ }
225+
226+ static int luaskb_protocol (lua_State * L )
227+ {
228+ luaskb_t * lskb = luaskb_check (L , 1 );
229+ lua_pushinteger (L , ntohs (lskb -> skb -> protocol ));
230+ return 1 ;
231+ }
232+
233+ static int luaskb_proto (lua_State * L )
234+ {
235+ luaskb_t * lskb = luaskb_check (L , 1 );
236+ struct sk_buff * skb = lskb -> skb ;
237+
238+ if (skb -> protocol == htons (ETH_P_IP ))
239+ lua_pushinteger (L , ip_hdr (skb )-> protocol );
240+ else if (skb -> protocol == htons (ETH_P_IPV6 ))
241+ lua_pushinteger (L , ipv6_hdr (skb )-> nexthdr );
242+ else
243+ lua_pushnil (L );
244+ return 1 ;
245+ }
246+
198247static int luaskb_copy (lua_State * L );
199248
200249static void luaskb_release (void * private )
@@ -211,18 +260,25 @@ static const luaL_Reg luaskb_lib[] = {
211260};
212261
213262static const luaL_Reg luaskb_mt [] = {
214- {"__gc" , lunatik_deleteobject },
215- {"__len" , luaskb_len },
216- {"ifindex" , luaskb_ifindex },
217- {"vlan" , luaskb_vlan },
218- {"data" , luaskb_data },
219- {"resize" , luaskb_resize },
220- {"checksum" , luaskb_checksum },
221- {"forward" , luaskb_forward },
222- {"copy" , luaskb_copy },
263+ {"__gc" , lunatik_deleteobject },
264+ {"__len" , luaskb_len },
265+ {"ifindex" , luaskb_ifindex },
266+ {"vlan" , luaskb_vlan },
267+ {"data" , luaskb_data },
268+ {"resize" , luaskb_resize },
269+ {"checksum" , luaskb_checksum },
270+ {"forward" , luaskb_forward },
271+ {"copy" , luaskb_copy },
272+ {"protocol" , luaskb_protocol },
273+ {"proto" , luaskb_proto },
274+ {"getmark" , luaskb_getmark },
275+ {"getpriority" , luaskb_getpriority },
276+ {"setmark" , luaskb_setmark },
277+ {"setpriority" , luaskb_setpriority },
223278 {NULL , NULL }
224279};
225280
281+
226282LUNATIK_OPENER (skb );
227283static const lunatik_class_t luaskb_class = {
228284 .name = "skb" ,
0 commit comments