需增加的程式如下(紅色部份):
if ( ioctl( Sock, SIOCGIFFLAGS, &IfReq ) < 0 )
my_log( LOG_ERR, errno, "ioctl SIOCGIFFLAGS" );
IfDescEp->Flags = IfReq.ifr_flags;
// aimwang: when pppx get dstaddr for use
if (0x10d1 == IfDescEp->Flags) // when pppx
{
if ( ioctl( Sock, SIOCGIFDSTADDR, &IfReq ) < 0 ) // get dstaddr
my_log(LOG_ERR, errno, "ioctl SIOCGIFDSTADDR for %s", IfReq.ifr_name);
addr = ((struct sockaddr_in *)&IfReq.ifr_dstaddr)->sin_addr.s_addr; // rewrite addr
subnet = addr & mask; // recalc subnet
}
// Insert the verified subnet as an allowed net...
IfDescEp->allowednets = (struct SubnetList *)malloc(sizeof(struct SubnetList));
if(IfDescEp->allowednets == NULL) my_log(LOG_ERR, 0, "Out of memory !");
這樣就能取得遠端 ip 來進行 igmpproxy 該有的行為
沒有留言:
張貼留言