Here you are, patch this with the chillispot source, i found it here http://coova.org/phpBB3/viewtopic.php?f=4&t=60&sid=f4f80d1d7fdcb659fa8db141288bfe6b&start=0
---------------------------------------------------------------------------------------------
diff -urNp old/chilli.c new/chilli.c
--- old/chilli.c 2007-01-04 10:22:03.000000000 +0100
+++ new/chilli.c 2007-01-04 10:22:15.000000000 +0100
@@ -3072,6 +3072,15 @@ int cb_dhcp_request(struct dhcp_conn_t *
if (appconn->dnprot == DNPROT_DHCP_NONE)
appconn->dnprot = DNPROT_UAM;
+ /* ALPAPAD */
+ /* Add routing entry ;-) */
+ if(ipm->inuse == 2)
+ {
+ struct in_addr mask;
+ mask.s_addr = 0xffffffff;
+ printf("Adding route: %d\n", tun_addroute(tun,addr,&appconn->ourip,&mask));
+ }
+
return 0;
}
@@ -3150,11 +3159,20 @@ int cb_dhcp_disconnect(struct dhcp_conn_
conn->authstate = DHCP_AUTH_NONE; /* TODO: Redundant */
- if (appconn->uplink)
+ /* ALPAPAD */
+ if (appconn->uplink) {
+ struct ippoolm_t *member;
+ member = (struct ippoolm_t *) appconn->uplink;
+ if(member->inuse == 2) {
+ struct in_addr mask;
+ mask.s_addr = 0xffffffff;
+ printf("Removing route: %d\n", tun_delroute(tun,&member->addr,&appconn->ourip,&mask,1));
+ }
if (ippool_freeip(ippool, (struct ippoolm_t *) appconn->uplink)) {
sys_err(LOG_ERR, __FILE__, __LINE__, 0,
"ippool_freeip() failed!");
}
+ }
(void) freeconn(appconn);
diff -urNp old/dhcp.c new/dhcp.c
--- old/dhcp.c 2007-01-04 10:22:03.000000000 +0100
+++ new/dhcp.c 2007-01-04 10:22:15.000000000 +0100
@@ -2027,16 +2027,26 @@ int dhcp_receive_ip(struct dhcp_t *this,
ourip.s_addr = conn->ourip.s_addr;
}
else {
- if (this->debug) printf("Address not found\n");
+ /* ALPAPAD */
+ struct in_addr reqaddr;
+ /* Get local copy */
+ memcpy(&reqaddr.s_addr, &pack->iph.saddr, DHCP_IP_ALEN);
+ if (this->debug) printf("Address not found (%s)\n",inet_ntoa(reqaddr));
+ /* Allocate new connection */
+ if (dhcp_newconn(this, &conn, pack->ethh.src))
+ return 0; /* Out of connections */
+
+ /* Request an IP address */
+ if (conn->authstate == DHCP_AUTH_NONE) {
+ this->cb_request(conn,&reqaddr);
+ }
+
+
ourip.s_addr = this->ourip.s_addr;
/* Do we allow dynamic allocation of IP addresses? */
if (!this->allowdyn)
return 0;
-
- /* Allocate new connection */
- if (dhcp_newconn(this, &conn, pack->ethh.src))
- return 0; /* Out of connections */
}
/* Request an IP address */
@@ -2207,10 +2217,11 @@ int dhcp_sendARP(struct dhcp_conn_t *con
if (conn->hisip.s_addr == reqaddr.s_addr)
return 0;
+ /* aNt1X: Commented out, we don't know his mask, we have to answer to every ARP request (AnyIP)
/* If ARP request outside of mask: Ignore */
- if ((conn->hisip.s_addr & conn->hismask.s_addr) !=
+ /*if ((conn->hisip.s_addr & conn->hismask.s_addr) !=
(reqaddr.s_addr & conn->hismask.s_addr))
- return 0;
+ return 0;*/
/* Get packet default values */
memset(&packet, 0, sizeof(packet));
@@ -2255,23 +2266,33 @@ int dhcp_receive_arp(struct dhcp_t *this
}
+ /* aNt1X: Commented out, so that Chillispot answers to every ARP request (AnyIP)
/* Check that MAC address is our MAC or Broadcast */
- if ((memcmp(pack->ethh.dst, this->hwaddr, DHCP_ETH_ALEN)) && (memcmp(pack->ethh.dst, bmac, DHCP_ETH_ALEN))) {
+ /*if ((memcmp(pack->ethh.dst, this->hwaddr, DHCP_ETH_ALEN)) && (memcmp(pack->ethh.dst, bmac, DHCP_ETH_ALEN))) {
if (this->debug) printf("Received ARP request for other destination!\n");
return 0;
- }
+ }*/
/* Check to see if we know MAC address. */
if (dhcp_hashget(this, &conn, pack->ethh.src)) {
- if (this->debug) printf("Address not found\n");
+ /* ALPAPAD */
+ struct in_addr reqaddr;
+ /* Get local copy */
+ memcpy(&reqaddr.s_addr, &pack->arp.spa, DHCP_IP_ALEN);
+ if (this->debug) printf("Address not found (%s)\n",inet_ntoa(reqaddr));
+ /* Allocate new connection */
+ if (dhcp_newconn(this, &conn, pack->ethh.src))
+ return 0; /* Out of connections */
+
+ /* Request an IP address */
+ if (conn->authstate == DHCP_AUTH_NONE) {
+ this->cb_request(conn,&reqaddr);
+ }
+
/* Do we allow dynamic allocation of IP addresses? */
if (!this->allowdyn) /* TODO: Experimental */
return 0;
-
- /* Allocate new connection */
- if (dhcp_newconn(this, &conn, pack->ethh.src)) /* TODO: Experimental */
- return 0; /* Out of connections */
}
@@ -2282,7 +2303,7 @@ int dhcp_receive_arp(struct dhcp_t *this
return 0; /* Only reply if he was allocated an address */
}
- if (memcmp(&conn->ourip.s_addr, pack->arp.tpa, 4)) {
+ if (!memcmp(&conn->hisip.s_addr, pack->arp.tpa, 4)) {
if (this->debug) printf("Did not ask for router address: %.8x - %.2x%.2x%.2x%.2x\n", conn->ourip.s_addr,
pack->arp.tpa[0],
pack->arp.tpa[1],
diff -urNp old/ippool.c new/ippool.c
--- old/ippool.c 2007-01-04 10:22:03.000000000 +0100
+++ new/ippool.c 2007-01-04 10:22:15.000000000 +0100
@@ -393,7 +393,7 @@ int ippool_newip(struct ippool_t *this,
}
/* If not found yet and dynamic IP then allocate dynamic IP */
- if ((!p2) && (!statip)) {
+if ((!p2) && (!statip) && (!addr->s_addr)) {
if (!this ->firstdyn) {
sys_err(LOG_ERR, __FILE__, __LINE__, 0,
"No more IP addresses available");
@@ -431,7 +431,7 @@ int ippool_newip(struct ippool_t *this,
/* It was not possible to allocate from dynamic address pool */
/* Try to allocate from static address space */
- if ((addr) && (addr->s_addr) && (statip)) { /* IP address given */
+ if ((addr) && (addr->s_addr)) { /* IP address given */
if (!this->firststat) {
sys_err(LOG_ERR, __FILE__, __LINE__, 0,
"No more IP addresses available");
---------------------------------------------------------------------------------------------