rendered paste bodydiff -urN mpd-5.3.orig/src/iface.c mpd-5.3/src/iface.c
--- mpd-5.3.orig/src/iface.c 2009-04-11 18:24:19.000000000 -0300
+++ mpd-5.3/src/iface.c 2009-08-08 19:54:00.000000000 -0300
@@ -142,7 +142,7 @@
#ifdef USE_IPFW
static int IfaceAllocACL (struct acl_pool ***ap, int start, char * ifname, int number);
static int IfaceFindACL (struct acl_pool *ap, char * ifname, int number);
- static char * IFaceParseACL (char * src, char * ifname);
+ static char * IFaceParseACL (char * src, IfaceState iface);
#endif
/*
@@ -481,22 +481,24 @@
}
acls = b->params.acl_queue;
while (acls != NULL) {
- buf = IFaceParseACL(acls->rule,iface->ifname);
+ buf = IFaceParseACL(acls->rule,iface);
ExecCmd(LG_IFACE2, b->name, "%s queue %d config %s", PATH_IPFW, acls->real_number, buf);
Freee(buf);
acls = acls->next;
}
acls = b->params.acl_table;
while (acls != NULL) {
+ buf = IFaceParseACL(acls->rule, iface);
acl = Mdup(MB_IFACE, acls, sizeof(struct acl) + strlen(acls->rule));
acl->next = iface->tables;
iface->tables = acl;
- ExecCmd(LG_IFACE2, b->name, "%s table %d add %s", PATH_IPFW, acls->real_number, acls->rule);
+ ExecCmd(LG_IFACE2, b->name, "%s table %d add %s", PATH_IPFW, acls->real_number, buf);
+ Freee(buf);
acls = acls->next;
};
acls = b->params.acl_rule;
while (acls != NULL) {
- buf = IFaceParseACL(acls->rule, iface->ifname);
+ buf = IFaceParseACL(acls->rule, iface);
ExecCmd(LG_IFACE2, b->name, "%s add %d %s via %s", PATH_IPFW, acls->real_number, buf, iface->ifname);
Freee(buf);
acls = acls->next;
@@ -569,7 +571,7 @@
acl = iface->tables;
while (acl != NULL) {
ExecCmd(LG_IFACE2, b->name, "%s table %d delete %s",
- PATH_IPFW, acl->real_number, acl->rule);
+ PATH_IPFW, acl->real_number, IFaceParseACL(acl->rule,iface));
aclnext = acl->next;
Freee(acl);
acl = aclnext;
@@ -704,13 +706,15 @@
*/
static char *
-IFaceParseACL (char * src, char * ifname)
+IFaceParseACL (char * src, IfaceState iface)
{
char *buf,*buf1;
char *begin,*param,*end;
char t;
int num,real_number;
struct acl_pool *ap;
+ char hisaddr[20];
+ int ipmode=0; // 0 - normal macro, 1 - IP address macro
buf = Malloc(MB_IFACE, ACL_LEN);
buf1 = Malloc(MB_IFACE, ACL_LEN);
@@ -735,14 +739,34 @@
case 't':
ap = table_pool;
break;
+ case 'a':
+ ipmode = 1;
+ if (num==1)
+ u_addrtoa(&iface->peer_addr,hisaddr,sizeof(hisaddr));
+ else if (num==2)
+ u_rangetoa(&iface->self_addr,hisaddr,sizeof(hisaddr));
+ else
+ ipmode = 0;
+ ap = NULL;
+ break;
default:
ap = NULL;
};
- real_number = IfaceFindACL(ap,ifname,num);
- if (end != NULL) {
- snprintf(buf1, ACL_LEN, "%s%d %s", begin, real_number, end);
- } else {
- snprintf(buf1, ACL_LEN, "%s%d", begin, real_number);
+ if (ipmode)
+ {
+ if (end != NULL)
+ snprintf(buf1, ACL_LEN, "%s%s %s", begin, hisaddr, end);
+ else
+ snprintf(buf1, ACL_LEN, "%s%s", begin, hisaddr);
+ ipmode = 0;
+ }
+ else
+ {
+ real_number = IfaceFindACL(ap,iface->ifname,num);
+ if (end != NULL)
+ snprintf(buf1, ACL_LEN, "%s%d %s", begin, real_number, end);
+ else
+ snprintf(buf1, ACL_LEN, "%s%d", begin, real_number);
};
strlcpy(buf, buf1, ACL_LEN);
};