Changeset 49689 in vbox for trunk/src/VBox/NetworkServices
- Timestamp:
- Nov 28, 2013 2:34:48 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 90959
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r49688 r49689 64 64 # include <sys/socket.h> 65 65 # include <netinet/in.h> 66 # ifdef RT_OS_LINUX 67 # include <linux/icmp.h> /* ICMP_FILTER */ 68 # endif 69 # include <netinet/icmp6.h> 66 70 #endif 67 71 … … 151 155 friend class NATNetworkListener; 152 156 public: 153 VBoxNetLwipNAT( );157 VBoxNetLwipNAT(SOCKET icmpsock4, SOCKET icmpsock6); 154 158 virtual ~VBoxNetLwipNAT(); 155 159 void usage(){ /* @todo: should be implemented */ }; … … 758 762 759 763 760 VBoxNetLwipNAT::VBoxNetLwipNAT( )764 VBoxNetLwipNAT::VBoxNetLwipNAT(SOCKET icmpsock4, SOCKET icmpsock6) 761 765 { 762 766 LogFlowFuncEnter(); … … 764 768 m_ProxyOptions.ipv6_enabled = 0; 765 769 m_ProxyOptions.ipv6_defroute = 0; 770 m_ProxyOptions.icmpsock4 = icmpsock4; 771 m_ProxyOptions.icmpsock6 = icmpsock6; 766 772 m_ProxyOptions.tftp_root = NULL; 767 773 m_ProxyOptions.src4 = NULL; … … 1208 1214 #endif 1209 1215 1216 SOCKET icmpsock4 = INVALID_SOCKET; 1217 SOCKET icmpsock6 = INVALID_SOCKET; 1218 #ifndef RT_OS_DARWIN 1219 const int icmpstype = SOCK_RAW; 1220 #else 1221 /* on OS X it's not privileged */ 1222 const int icmpstype = SOCK_DGRAM; 1223 #endif 1224 1225 icmpsock4 = socket(AF_INET, icmpstype, IPPROTO_ICMP); 1226 if (icmpsock4 == INVALID_SOCKET) 1227 { 1228 perror("IPPROTO_ICMP"); 1229 } 1230 1231 if (icmpsock4 != INVALID_SOCKET) 1232 { 1233 #ifdef ICMP_FILTER // Linux specific; NB: privileged! 1234 struct icmp_filter flt = { 1235 ~(uint32_t)( 1236 (1U << ICMP_ECHOREPLY) 1237 | (1U << ICMP_DEST_UNREACH) 1238 | (1U << ICMP_TIME_EXCEEDED) 1239 ) 1240 }; 1241 1242 int status = setsockopt(icmpsock4, icmpstype, ICMP_FILTER, 1243 &flt, sizeof(flt)); 1244 if (status < 0) 1245 { 1246 perror("ICMP_FILTER"); 1247 } 1248 #endif 1249 } 1250 1251 icmpsock6 = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); 1252 if (icmpsock6 == INVALID_SOCKET) 1253 { 1254 perror("IPPROTO_ICMPV6"); 1255 } 1256 1257 if (icmpsock6 != INVALID_SOCKET) 1258 { 1259 #ifdef ICMP6_FILTER // Windows doesn't support RFC 3542 API 1260 /* 1261 * XXX: We do this here for now, not in pxping.c, to avoid 1262 * name clashes between lwIP and system headers. 1263 */ 1264 struct icmp6_filter flt; 1265 ICMP6_FILTER_SETBLOCKALL(&flt); 1266 1267 ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &flt); 1268 1269 ICMP6_FILTER_SETPASS(ICMP6_DST_UNREACH, &flt); 1270 ICMP6_FILTER_SETPASS(ICMP6_PACKET_TOO_BIG, &flt); 1271 ICMP6_FILTER_SETPASS(ICMP6_TIME_EXCEEDED, &flt); 1272 ICMP6_FILTER_SETPASS(ICMP6_PARAM_PROB, &flt); 1273 1274 int status = setsockopt(icmpsock6, IPPROTO_ICMPV6, ICMP6_FILTER, 1275 &flt, sizeof(flt)); 1276 if (status < 0) 1277 { 1278 perror("ICMP6_FILTER"); 1279 } 1280 #endif 1281 } 1282 1210 1283 HRESULT hrc = com::Initialize(); 1211 1284 #ifdef VBOX_WITH_XPCOM … … 1221 1294 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize COM!"); 1222 1295 1223 g_pLwipNat = new VBoxNetLwipNAT( );1296 g_pLwipNat = new VBoxNetLwipNAT(icmpsock4, icmpsock6); 1224 1297 1225 1298 Log2(("NAT: initialization\n"));
Note:
See TracChangeset
for help on using the changeset viewer.