@@ -837,7 +837,20 @@ static int sockopt_set_packet_membership(struct eco_socket *sock, lua_State *L,
837
837
}
838
838
839
839
lua_getfield (L , 3 , "type" );
840
- mreq .mr_type = luaL_checkinteger (L , -1 );
840
+ mreq .mr_type = luaL_optinteger (L , -1 , 0 );
841
+ lua_pop (L , 1 );
842
+
843
+ lua_getfield (L , 3 , "address" );
844
+ if (!lua_isnil (L , -1 )) {
845
+ size_t alen ;
846
+ const char * address = luaL_checklstring (L , -1 , & alen );
847
+
848
+ if (alen > sizeof (mreq .mr_address ))
849
+ return luaL_argerror (L , 3 , "address too long" );
850
+
851
+ mreq .mr_alen = alen ;
852
+ memcpy (mreq .mr_address , address , alen );
853
+ }
841
854
lua_pop (L , 1 );
842
855
843
856
return sockopt_set (sock , L , o , & mreq , sizeof (mreq ));
@@ -1143,7 +1156,10 @@ int luaopen_eco_core_socket(lua_State *L)
1143
1156
lua_add_constant (L , "ARPOP_REQUEST" , ARPOP_REQUEST );
1144
1157
lua_add_constant (L , "ARPOP_REPLY" , ARPOP_REPLY );
1145
1158
1159
+ lua_add_constant (L , "PACKET_MR_MULTICAST" , PACKET_MR_MULTICAST );
1146
1160
lua_add_constant (L , "PACKET_MR_PROMISC" , PACKET_MR_PROMISC );
1161
+ lua_add_constant (L , "PACKET_MR_ALLMULTI" , PACKET_MR_ALLMULTI );
1162
+ lua_add_constant (L , "PACKET_MR_UNICAST" , PACKET_MR_UNICAST );
1147
1163
1148
1164
lua_add_constant (L , "ICMP_ECHOREPLY" , ICMP_ECHOREPLY );
1149
1165
lua_add_constant (L , "ICMP_ECHO" , ICMP_ECHO );
0 commit comments