1275 icmp->icmp_ip.ip_len = htons(icmp->icmp_ip.ip_len);
1276 icmp->icmp_ip.ip_off = htons(icmp->icmp_ip.ip_off);
1277 icmp->icmp_cksum = ipf_cksum((u_short *)icmp,
1278 sz - sizeof(ip_t));
1279 }
1280
1281 /*
1282 * Need to exit out of these so we don't recursively call rw_enter
1283 * from fr_qout.
1284 */
1285 return fr_send_ip(fin, m, &m);
1286 }
1287
1288 #include <sys/time.h>
1289 #include <sys/varargs.h>
1290
1291 #ifndef _KERNEL
1292 #include <stdio.h>
1293 #endif
1294
1295 #define NULLADDR_RATE_LIMIT 10 /* 10 seconds */
1296
1297
1298 /*
1299 * Print out warning message at rate-limited speed.
1300 */
1301 static void rate_limit_message(ipf_stack_t *ifs,
1302 int rate, const char *message, ...)
1303 {
1304 static time_t last_time = 0;
1305 time_t now;
1306 va_list args;
1307 char msg_buf[256];
1308 int need_printed = 0;
1309
1310 now = ddi_get_time();
1311
1312 /* make sure, no multiple entries */
1313 ASSERT(MUTEX_NOT_HELD(&(ifs->ifs_ipf_rw.ipf_lk)));
1314 MUTEX_ENTER(&ifs->ifs_ipf_rw);
1315 if (now - last_time >= rate) {
1316 need_printed = 1;
1317 last_time = now;
1318 }
1319 MUTEX_EXIT(&ifs->ifs_ipf_rw);
1320
1321 if (need_printed) {
1322 va_start(args, message);
1323 (void)vsnprintf(msg_buf, 255, message, args);
1324 va_end(args);
1325 #ifdef _KERNEL
1326 cmn_err(CE_WARN, msg_buf);
1327 #else
1328 fprintf(std_err, msg_buf);
1329 #endif
1330 }
1331 }
1332
1333 /*
1334 * Return the first IP Address associated with an interface
1335 * For IPv6, we walk through the list of logical interfaces and return
1336 * the address of the first one that isn't a link-local interface.
1337 * We can't assume that it is :1 because another link-local address
1338 * may have been assigned there.
1339 */
1340 /*ARGSUSED*/
1341 int fr_ifpaddr(v, atype, ifptr, inp, inpmask, ifs)
1342 int v, atype;
1343 void *ifptr;
1344 struct in_addr *inp, *inpmask;
1345 ipf_stack_t *ifs;
1346 {
1347 struct sockaddr_in6 v6addr[2];
1348 struct sockaddr_in v4addr[2];
1349 net_ifaddr_t type[2];
1350 net_handle_t net_data;
1351 phy_if_t phyif;
1352 void *array;
|
1275 icmp->icmp_ip.ip_len = htons(icmp->icmp_ip.ip_len);
1276 icmp->icmp_ip.ip_off = htons(icmp->icmp_ip.ip_off);
1277 icmp->icmp_cksum = ipf_cksum((u_short *)icmp,
1278 sz - sizeof(ip_t));
1279 }
1280
1281 /*
1282 * Need to exit out of these so we don't recursively call rw_enter
1283 * from fr_qout.
1284 */
1285 return fr_send_ip(fin, m, &m);
1286 }
1287
1288 #include <sys/time.h>
1289 #include <sys/varargs.h>
1290
1291 #ifndef _KERNEL
1292 #include <stdio.h>
1293 #endif
1294
1295 /*
1296 * Return the first IP Address associated with an interface
1297 * For IPv6, we walk through the list of logical interfaces and return
1298 * the address of the first one that isn't a link-local interface.
1299 * We can't assume that it is :1 because another link-local address
1300 * may have been assigned there.
1301 */
1302 /*ARGSUSED*/
1303 int fr_ifpaddr(v, atype, ifptr, inp, inpmask, ifs)
1304 int v, atype;
1305 void *ifptr;
1306 struct in_addr *inp, *inpmask;
1307 ipf_stack_t *ifs;
1308 {
1309 struct sockaddr_in6 v6addr[2];
1310 struct sockaddr_in v4addr[2];
1311 net_ifaddr_t type[2];
1312 net_handle_t net_data;
1313 phy_if_t phyif;
1314 void *array;
|