diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2016-12-10 20:44:29 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2016-12-10 20:46:11 +0300 |
commit | af82c18fe8985b706740614d5ed738026ae68878 (patch) | |
tree | 09189cd838df82dcc0bedce9c441a1978c32a8d9 /accel-pppd | |
parent | 3f148920318c8eb169d88b800c64272bd1518880 (diff) | |
download | accel-ppp-af82c18fe8985b706740614d5ed738026ae68878.tar.gz accel-ppp-af82c18fe8985b706740614d5ed738026ae68878.zip |
ipoe: implemented support for freeradius dhcp attributes
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcp_attr_defs.h | 311 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcpv4.c | 42 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcpv4.h | 2 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 51 | ||||
-rw-r--r-- | accel-pppd/memdebug.c | 3 |
5 files changed, 396 insertions, 13 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcp_attr_defs.h b/accel-pppd/ctrl/ipoe/dhcp_attr_defs.h new file mode 100644 index 00000000..c68111c1 --- /dev/null +++ b/accel-pppd/ctrl/ipoe/dhcp_attr_defs.h @@ -0,0 +1,311 @@ +#define VENDOR_DHCP 54 +#define DHCP_Opcode 256 +#define DHCP_Hardware_Type 257 +#define DHCP_Hardware_Address_Length 258 +#define DHCP_Hop_Count 259 +#define DHCP_Transaction_Id 260 +#define DHCP_Number_of_Seconds 261 +#define DHCP_Flags 262 +#define DHCP_Client_IP_Address 263 +#define DHCP_Your_IP_Address 264 +#define DHCP_Server_IP_Address 265 +#define DHCP_Gateway_IP_Address 266 +#define DHCP_Client_Hardware_Address 267 +#define DHCP_Server_Host_Name 268 +#define DHCP_Boot_Filename 269 +#define DHCP_Relay_To_IP_Address 270 +#define DHCP_Relay_Max_Hop_Count 271 +#define DHCP_Relay_IP_Address 272 +#define DHCP_Flags_Broadcast 0x8000 +#define DHCP_Hardware_Type_Ethernet 1 +#define DHCP_Hardware_Type_Experiemental_Ethernet 2 +#define DHCP_Hardware_Type_AX_25 3 +#define DHCP_Hardware_Type_Proteon_Token_Ring 4 +#define DHCP_Hardware_Type_Chaos 5 +#define DHCP_Hardware_Type_IEEE_802 6 +#define DHCP_Hardware_Type_Arcnet 7 +#define DHCP_Hardware_Type_Hyperchannel 8 +#define DHCP_Hardware_Type_Lanstar 9 +#define DHCP_Hardware_Type_Autonet_Short_Address 10 +#define DHCP_Hardware_Type_LocalTalk 11 +#define DHCP_Hardware_Type_LocalNet 12 +#define DHCP_Hardware_Type_Ultra_Link 13 +#define DHCP_Hardware_Type_SMDS 14 +#define DHCP_Hardware_Type_Frame_Relay 15 +#define DHCP_Hardware_Type_ATM_16 16 +#define DHCP_Hardware_Type_HDLC 17 +#define DHCP_Hardware_Type_Fibre_Channel 18 +#define DHCP_Hardware_Type_ATM_19 19 +#define DHCP_Hardware_Type_Serial_Line 20 +#define DHCP_Hardware_Type_ATM_21 21 +#define DHCP_Hardware_Type_MIL_STD_188_220 22 +#define DHCP_Hardware_Type_Metricom 23 +#define DHCP_Hardware_Type_IEEE_1394 24 +#define DHCP_Hardware_Type_MAPOS 25 +#define DHCP_Hardware_Type_Twinaxial 26 +#define DHCP_Hardware_Type_EUI_64 27 +#define DHCP_Hardware_Type_HIPARP 28 +#define DHCP_Hardware_Type_IP_Over_ISO_7816_3 29 +#define DHCP_Hardware_Type_ARPSec 30 +#define DHCP_Hardware_Type_IPSec_Tunnel 31 +#define DHCP_Hardware_Type_Infiniband 32 +#define DHCP_Hardware_Type_CAI_TIA_102 33 +#define DHCP_Subnet_Mask 1 +#define DHCP_Time_Offset 2 +#define DHCP_Router_Address 3 +#define DHCP_Time_Server 4 +#define DHCP_IEN_116_Name_Server 5 +#define DHCP_Domain_Name_Server 6 +#define DHCP_Log_Server 7 +#define DHCP_Quotes_Server 8 +#define DHCP_LPR_Server 9 +#define DHCP_Impress_Server 10 +#define DHCP_RLP_Server 11 +#define DHCP_Hostname 12 +#define DHCP_Boot_File_Size 13 +#define DHCP_Merit_Dump_File 14 +#define DHCP_Domain_Name 15 +#define DHCP_Swap_Server 16 +#define DHCP_Root_Path 17 +#define DHCP_Bootp_Extensions_Path 18 +#define DHCP_IP_Forward_Enable 19 +#define DHCP_Source_Route_Enable 20 +#define DHCP_Policy_Filter 21 +#define DHCP_Max_Datagram_Reassembly_Sz 22 +#define DHCP_Default_IP_TTL 23 +#define DHCP_Path_MTU_Aging_Timeout 24 +#define DHCP_Path_MTU_Plateau_Table 25 +#define DHCP_Interface_MTU_Size 26 +#define DHCP_All_Subnets_Are_Local 27 +#define DHCP_Broadcast_Address 28 +#define DHCP_Perform_Mask_Discovery 29 +#define DHCP_Provide_Mask_To_Others 30 +#define DHCP_Perform_Router_Discovery 31 +#define DHCP_Router_Solicitation_Address 32 +#define DHCP_Static_Routes 33 +#define DHCP_Trailer_Encapsulation 34 +#define DHCP_ARP_Cache_Timeout 35 +#define DHCP_Ethernet_Encapsulation 36 +#define DHCP_Default_TCP_TTL 37 +#define DHCP_Keep_Alive_Interval 38 +#define DHCP_Keep_Alive_Garbage 39 +#define DHCP_NIS_Domain_Name 40 +#define DHCP_NIS_Servers 41 +#define DHCP_NTP_Servers 42 +#define DHCP_Vendor 43 +#define DHCP_NETBIOS_Name_Servers 44 +#define DHCP_NETBIOS_Dgm_Dist_Servers 45 +#define DHCP_NETBIOS_Node_Type 46 +#define DHCP_NETBIOS 47 +#define DHCP_X_Window_Font_Server 48 +#define DHCP_X_Window_Display_Mgr 49 +#define DHCP_Requested_IP_Address 50 +#define DHCP_IP_Address_Lease_Time 51 +#define DHCP_Overload 52 +#define DHCP_Message_Type 53 +#define DHCP_DHCP_Server_Identifier 54 +#define DHCP_Parameter_Request_List 55 +#define DHCP_DHCP_Error_Message 56 +#define DHCP_DHCP_Maximum_Msg_Size 57 +#define DHCP_Renewal_Time 58 +#define DHCP_Rebinding_Time 59 +#define DHCP_Vendor_Class_Identifier 60 +#define DHCP_Client_Identifier 61 +#define DHCP_Netware_Domain_Name 62 +#define DHCP_Netware_Sub_Options 63 +#define DHCP_NIS_Client_Domain_Name 64 +#define DHCP_NIS_Server_Address 65 +#define DHCP_TFTP_Server_Name 66 +#define DHCP_Boot_File_Name 67 +#define DHCP_Home_Agent_Address 68 +#define DHCP_SMTP_Server_Address 69 +#define DHCP_POP3_Server_Address 70 +#define DHCP_NNTP_Server_Address 71 +#define DHCP_WWW_Server_Address 72 +#define DHCP_Finger_Server_Address 73 +#define DHCP_IRC_Server_Address 74 +#define DHCP_StreetTalk_Server_Address 75 +#define DHCP_STDA_Server_Address 76 +#define DHCP_User_Class 77 +#define DHCP_Directory_Agent 78 +#define DHCP_Service_Scope 79 +#define DHCP_Rapid_Commit 80 +#define DHCP_Client_FQDN 81 +#define DHCP_Relay_Agent_Information 82 +#define DHCP_Agent_Circuit_Id 1 +#define DHCP_Agent_Remote_Id 2 +#define DHCP_Relay_Circuit_Id 1 +#define DHCP_Relay_Remote_Id 2 +#define DHCP_Docsis_Device_Class 4 +#define DHCP_Relay_Link_Selection 5 +#define DHCP_Subscriber_Id 6 +#define DHCP_RADIUS_Attributes 7 +#define DHCP_Authentication_Information 8 +#define DHCP_Vendor_Specific_Information 9 +#define DHCP_Relay_Agent_Flags 10 +#define DHCP_Server_Identifier_Override 11 +#define DHCP_iSNS 83 +#define DHCP_NDS_Servers 85 +#define DHCP_NDS_Tree_Name 86 +#define DHCP_NDS_Context 87 +#define DHCP_Authentication 90 +#define DHCP_Client_Last_Txn_Time 91 +#define DHCP_associated_ip 92 +#define DHCP_Client_System 93 +#define DHCP_Client_NDI 94 +#define DHCP_LDAP 95 +#define DHCP_UUID GUID +#define DHCP_User_Auth 98 +#define DHCP_Netinfo_Address 112 +#define DHCP_Netinfo_Tag 113 +#define DHCP_URL 114 +#define DHCP_Auto_Config 116 +#define DHCP_Name_Service_Search 117 +#define DHCP_Subnet_Selection_Option 118 +#define DHCP_Domain_Search 119 +#define DHCP_SIP_Servers_DHCP_Option 120 +#define DHCP_Classless_Static_Route 121 +#define DHCP_CCC 122 +#define DHCP_GeoConf_Option 123 +#define DHCP_V_I_Vendor_Class 124 +#define DHCP_V_I_Vendor_Specific 125 +#define DHCP_Etherboot 128 +#define DHCP_TFTP_Server_IP_Address 128 +#define DHCP_Call_Server_IP_address 129 +#define DHCP_Ethernet_Interface 130 +#define DHCP_Vendor_Discrimination_Str 130 +#define DHCP_Remote_Stats_Svr_IP_Address 131 +#define DHCP_IEEE_802_1Q_L2_Priority 132 +#define DHCP_IEEE_802_1P_VLAN_ID 133 +#define DHCP_Diffserv_Code_Point 134 +#define DHCP_HTTP_Proxy 135 +#define DHCP_Cisco_TFTP_Server_IP_Addresses 150 +#define DHCP_End_Of_Options 255 +#define DHCP_Opcode_Client_Message 1 +#define DHCP_Opcode_Server_Message 2 +#define DHCP_Message_Type_DHCP_Discover 1 +#define DHCP_Message_Type_DHCP_Offer 2 +#define DHCP_Message_Type_DHCP_Request 3 +#define DHCP_Message_Type_DHCP_Decline 4 +#define DHCP_Message_Type_DHCP_Ack 5 +#define DHCP_Message_Type_DHCP_NAK 6 +#define DHCP_Message_Type_DHCP_Release 7 +#define DHCP_Message_Type_DHCP_Inform 8 +#define DHCP_Message_Type_DHCP_Force_Renew 9 +#define DHCP_Parameter_Request_List_DHCP_Subnet_Mask 1 +#define DHCP_Parameter_Request_List_DHCP_Time_Offset 2 +#define DHCP_Parameter_Request_List_DHCP_Router_Address 3 +#define DHCP_Parameter_Request_List_DHCP_Time_Server 4 +#define DHCP_Parameter_Request_List_DHCP_IEN_116_Name_Server 5 +#define DHCP_Parameter_Request_List_DHCP_Domain_Name_Server 6 +#define DHCP_Parameter_Request_List_DHCP_Log_Server 7 +#define DHCP_Parameter_Request_List_DHCP_Quotes_Server 8 +#define DHCP_Parameter_Request_List_DHCP_LPR_Server 9 +#define DHCP_Parameter_Request_List_DHCP_Impress_Server 10 +#define DHCP_Parameter_Request_List_DHCP_RLP_Server 11 +#define DHCP_Parameter_Request_List_DHCP_Hostname 12 +#define DHCP_Parameter_Request_List_DHCP_Boot_File_Size 13 +#define DHCP_Parameter_Request_List_DHCP_Merit_Dump_File 14 +#define DHCP_Parameter_Request_List_DHCP_Domain_Name 15 +#define DHCP_Parameter_Request_List_DHCP_Swap_Server 16 +#define DHCP_Parameter_Request_List_DHCP_Root_Path 17 +#define DHCP_Parameter_Request_List_DHCP_Bootp_Extensions_Path 18 +#define DHCP_Parameter_Request_List_DHCP_IP_Forward_Enable 19 +#define DHCP_Parameter_Request_List_DHCP_Source_Route_Enable 20 +#define DHCP_Parameter_Request_List_DHCP_Policy_Filter 21 +#define DHCP_Parameter_Request_List_DHCP_Max_Datagram_Reassembly_Sz 22 +#define DHCP_Parameter_Request_List_DHCP_Default_IP_TTL 23 +#define DHCP_Parameter_Request_List_DHCP_Path_MTU_Aging_Timeout 24 +#define DHCP_Parameter_Request_List_DHCP_Path_MTU_Plateau_Table 25 +#define DHCP_Parameter_Request_List_DHCP_Interface_MTU_Size 26 +#define DHCP_Parameter_Request_List_DHCP_All_Subnets_Are_Local 27 +#define DHCP_Parameter_Request_List_DHCP_Broadcast_Address 28 +#define DHCP_Parameter_Request_List_DHCP_Perform_Mask_Discovery 29 +#define DHCP_Parameter_Request_List_DHCP_Provide_Mask_To_Others 30 +#define DHCP_Parameter_Request_List_DHCP_Perform_Router_Discovery 31 +#define DHCP_Parameter_Request_List_DHCP_Router_Solicitation_Address 32 +#define DHCP_Parameter_Request_List_DHCP_Static_Routes 33 +#define DHCP_Parameter_Request_List_DHCP_Trailer_Encapsulation 34 +#define DHCP_Parameter_Request_List_DHCP_ARP_Cache_Timeout 35 +#define DHCP_Parameter_Request_List_DHCP_Ethernet_Encapsulation 36 +#define DHCP_Parameter_Request_List_DHCP_Default_TCP_TTL 37 +#define DHCP_Parameter_Request_List_DHCP_Keep_Alive_Interval 38 +#define DHCP_Parameter_Request_List_DHCP_Keep_Alive_Garbage 39 +#define DHCP_Parameter_Request_List_DHCP_NIS_Domain_Name 40 +#define DHCP_Parameter_Request_List_DHCP_NIS_Servers 41 +#define DHCP_Parameter_Request_List_DHCP_NTP_Servers 42 +#define DHCP_Parameter_Request_List_DHCP_Vendor 43 +#define DHCP_Parameter_Request_List_DHCP_NETBIOS_Name_Servers 44 +#define DHCP_Parameter_Request_List_DHCP_NETBIOS_Dgm_Dist_Servers 45 +#define DHCP_Parameter_Request_List_DHCP_NETBIOS_Node_Type 46 +#define DHCP_Parameter_Request_List_DHCP_NETBIOS 47 +#define DHCP_Parameter_Request_List_DHCP_X_Window_Font_Server 48 +#define DHCP_Parameter_Request_List_DHCP_X_Window_Display_Mgr 49 +#define DHCP_Parameter_Request_List_DHCP_Requested_IP_Address 50 +#define DHCP_Parameter_Request_List_DHCP_IP_Address_Lease_Time 51 +#define DHCP_Parameter_Request_List_DHCP_Overload 52 +#define DHCP_Parameter_Request_List_DHCP_Message_Type 53 +#define DHCP_Parameter_Request_List_DHCP_DHCP_Server_Identifier 54 +#define DHCP_Parameter_Request_List_DHCP_Parameter_Request_List 55 +#define DHCP_Parameter_Request_List_DHCP_DHCP_Error_Message 56 +#define DHCP_Parameter_Request_List_DHCP_DHCP_Maximum_Msg_Size 57 +#define DHCP_Parameter_Request_List_DHCP_Renewal_Time 58 +#define DHCP_Parameter_Request_List_DHCP_Rebinding_Time 59 +#define DHCP_Parameter_Request_List_DHCP_Class_Identifier 60 +#define DHCP_Parameter_Request_List_DHCP_Client_Identifier 61 +#define DHCP_Parameter_Request_List_DHCP_Netware_Domain_Name 62 +#define DHCP_Parameter_Request_List_DHCP_Netware_Sub_Options 63 +#define DHCP_Parameter_Request_List_DHCP_NIS_Client_Domain_Name 64 +#define DHCP_Parameter_Request_List_DHCP_NIS_Server_Address 65 +#define DHCP_Parameter_Request_List_DHCP_TFTP_Server_Name 66 +#define DHCP_Parameter_Request_List_DHCP_Boot_File_Name 67 +#define DHCP_Parameter_Request_List_DHCP_Home_Agent_Address 68 +#define DHCP_Parameter_Request_List_DHCP_SMTP_Server_Address 69 +#define DHCP_Parameter_Request_List_DHCP_POP3_Server_Address 70 +#define DHCP_Parameter_Request_List_DHCP_NNTP_Server_Address 71 +#define DHCP_Parameter_Request_List_DHCP_WWW_Server_Address 72 +#define DHCP_Parameter_Request_List_DHCP_Finger_Server_Address 73 +#define DHCP_Parameter_Request_List_DHCP_IRC_Server_Address 74 +#define DHCP_Parameter_Request_List_DHCP_StreetTalk_Server_Address 75 +#define DHCP_Parameter_Request_List_DHCP_STDA_Server_Address 76 +#define DHCP_Parameter_Request_List_DHCP_User_Class 77 +#define DHCP_Parameter_Request_List_DHCP_Directory_Agent 78 +#define DHCP_Parameter_Request_List_DHCP_Service_Scope 79 +#define DHCP_Parameter_Request_List_DHCP_Rapid_Commit 80 +#define DHCP_Parameter_Request_List_DHCP_Client_FQDN 81 +#define DHCP_Parameter_Request_List_DHCP_Relay_Agent_Information 82 +#define DHCP_Parameter_Request_List_DHCP_iSNS 83 +#define DHCP_Parameter_Request_List_DHCP_NDS_Servers 85 +#define DHCP_Parameter_Request_List_DHCP_NDS_Tree_Name 86 +#define DHCP_Parameter_Request_List_DHCP_NDS_Context 87 +#define DHCP_Parameter_Request_List_DHCP_Authentication 90 +#define DHCP_Parameter_Request_List_DHCP_Client_Last_Txn_Time 91 +#define DHCP_Parameter_Request_List_DHCP_associated_ip 92 +#define DHCP_Parameter_Request_List_DHCP_Client_System 93 +#define DHCP_Parameter_Request_List_DHCP_Client_NDI 94 +#define DHCP_Parameter_Request_List_DHCP_LDAP 95 +#define DHCP_Parameter_Request_List_DHCP_UUID GUID +#define DHCP_Parameter_Request_List_DHCP_User_Auth 98 +#define DHCP_Parameter_Request_List_DHCP_Netinfo_Address 112 +#define DHCP_Parameter_Request_List_DHCP_Netinfo_Tag 113 +#define DHCP_Parameter_Request_List_DHCP_URL 114 +#define DHCP_Parameter_Request_List_DHCP_Auto_Config 116 +#define DHCP_Parameter_Request_List_DHCP_Name_Service_Search 117 +#define DHCP_Parameter_Request_List_DHCP_Subnet_Selection_Option 118 +#define DHCP_Parameter_Request_List_DHCP_Domain_Search 119 +#define DHCP_Parameter_Request_List_DHCP_SIP_Servers_DHCP_Option 120 +#define DHCP_Parameter_Request_List_DHCP_Classless_Static_Route 121 +#define DHCP_Parameter_Request_List_DHCP_CCC 122 +#define DHCP_Parameter_Request_List_DHCP_GeoConf_Option 123 +#define DHCP_Parameter_Request_List_DHCP_V_I_Vendor_Class 124 +#define DHCP_Parameter_Request_List_DHCP_V_I_Vendor_Specific 125 +#define DHCP_Parameter_Request_List_DHCP_Etherboot 128 +#define DHCP_Parameter_Request_List_DHCP_TFTP_Server_IP_Address 128 +#define DHCP_Parameter_Request_List_DHCP_Call_Server_IP_address 129 +#define DHCP_Parameter_Request_List_DHCP_Ethernet_Interface 130 +#define DHCP_Parameter_Request_List_DHCP_Vendor_Discrimination_Str 130 +#define DHCP_Parameter_Request_List_DHCP_Remote_Stats_Svr_IP_Address 131 +#define DHCP_Parameter_Request_List_DHCP_IEEE_802_1P_VLAN_ID 132 +#define DHCP_Parameter_Request_List_DHCP_IEEE_802_1Q_L2_Priority 133 +#define DHCP_Parameter_Request_List_DHCP_Diffserv_Code_Point 134 +#define DHCP_Parameter_Request_List_DHCP_HTTP_Proxy 135 diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index 6d0d1c9c..ccad3182 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.c +++ b/accel-pppd/ctrl/ipoe/dhcpv4.c @@ -22,6 +22,8 @@ #include "memdebug.h" #include "ap_session.h" #include "ipdb.h" +#include "radius.h" +#include "dhcp_attr_defs.h" #include "dhcpv4.h" @@ -1126,6 +1128,46 @@ void dhcpv4_reserve_ip(struct dhcpv4_serv *serv, uint32_t ip) pthread_mutex_unlock(&serv->range->lock); } +struct dhcpv4_packet *dhcpv4_clone_radius(struct rad_packet_t *rad) +{ + struct dhcpv4_packet *pkt = dhcpv4_packet_alloc(); + uint8_t *ptr = pkt->data, *endptr = ptr + BUF_SIZE; + struct dhcpv4_option *opt; + struct rad_attr_t *attr; + + if (!pkt) + return NULL; + + pkt->refs = 1; + + list_for_each_entry(attr, &rad->attrs, entry) { + if (attr->vendor && attr->vendor->id == VENDOR_DHCP && attr->attr->id < 256) { + if (ptr + attr->len >= endptr) + goto out; + + opt = mempool_alloc(opt_pool); + if (!opt) { + log_emerg("out of memory\n"); + goto out; + } + memset(opt, 0, sizeof(*opt)); + opt->type = attr->attr->id; + opt->len = attr->len; + opt->data = ptr; + memcpy(ptr, attr->raw, attr->len); + ptr += attr->len; + + list_add_tail(&opt->entry, &pkt->options); + } + } + + return pkt; + +out: + dhcpv4_packet_free(pkt); + return NULL; +} + static void load_config() { const char *opt; diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.h b/accel-pppd/ctrl/ipoe/dhcpv4.h index 58473036..a7fa5a90 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.h +++ b/accel-pppd/ctrl/ipoe/dhcpv4.h @@ -101,6 +101,7 @@ struct dhcpv4_relay { }; struct ap_session; +struct rad_packet_t; struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifname, const char *opt); void dhcpv4_free(struct dhcpv4_serv *); @@ -120,6 +121,7 @@ void dhcpv4_packet_ref(struct dhcpv4_packet *pack); struct dhcpv4_option *dhcpv4_packet_find_opt(struct dhcpv4_packet *pack, int type); int dhcpv4_packet_insert_opt82(struct dhcpv4_packet *pack, const char *agent_circuit_id, const char *agent_remote_id); void dhcpv4_packet_free(struct dhcpv4_packet *pack); +struct dhcpv4_packet *dhcpv4_clone_radius(struct rad_packet_t *); int dhcpv4_check_options(struct dhcpv4_packet *); void dhcpv4_print_options(struct dhcpv4_packet *, void (*)(const char *, ...)); diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 46bf68d0..1e84b07a 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -30,6 +30,7 @@ #include "ap_session.h" #include "pwdb.h" #include "ipdb.h" +#include "dhcp_attr_defs.h" #include "iputils.h" #include "ipset.h" @@ -2089,6 +2090,19 @@ void ipoe_serv_recv_arp(struct ipoe_serv *serv, struct _arphdr *arph) } #ifdef RADIUS + +static int ipaddr_to_prefix(in_addr_t ipaddr) +{ + if (ipaddr == 0xffffffff) + return 32; + +#if __BYTE_ORDER == __LITTLE_ENDIAN + return 31 - ffs(htonl(ipaddr)); +#else + return 31 - ffs(ipaddr); +#endif +} + static void ev_radius_access_accept(struct ev_radius_t *ev) { struct ipoe_session *ses = container_of(ev->ses, typeof(*ses), ses); @@ -2107,16 +2121,8 @@ static void ev_radius_access_accept(struct ev_radius_t *ev) if (attr->attr->type == ATTR_TYPE_INTEGER) { if (attr->val.integer > 0 && attr->val.integer < 31) ses->mask = attr->val.integer; - } else if (attr->attr->type == ATTR_TYPE_IPADDR) { - if (attr->val.ipaddr == 0xffffffff) - ses->mask = 32; - else -#if __BYTE_ORDER == __LITTLE_ENDIAN - ses->mask = 31 - ffs(htonl(attr->val.ipaddr)); -#else - ses->mask = 31 - ffs(attr->val.ipaddr); -#endif - } + } else if (attr->attr->type == ATTR_TYPE_IPADDR) + ses->mask = ipaddr_to_prefix(attr->val.ipaddr); } else if (attr->attr->id == conf_attr_l4_redirect) { if (attr->attr->type == ATTR_TYPE_STRING) { if (attr->len && attr->val.string[0] != '0') @@ -2134,6 +2140,31 @@ static void ev_radius_access_accept(struct ev_radius_t *ev) else if (attr->attr->id == conf_attr_l4_redirect_ipset) { if (attr->attr->type == ATTR_TYPE_STRING) ses->l4_redirect_ipset = _strdup(attr->val.string); + } else if (attr->vendor && attr->vendor->id == VENDOR_DHCP) { + ses->dhcpv4_relay_reply = dhcpv4_clone_radius(ev->reply); + + switch (attr->attr->id) { + case DHCP_Your_IP_Address: + ses->yiaddr = attr->val.ipaddr; + break; + case DHCP_Server_IP_Address: + ses->yiaddr = attr->val.ipaddr; + break; + case DHCP_Router_Address: + ses->router = *(in_addr_t *)attr->raw; + break; + case DHCP_Subnet_Mask: + ses->mask = ipaddr_to_prefix(attr->val.ipaddr); + break; + case DHCP_IP_Address_Lease_Time: + ses->lease_time = attr->val.integer; + lease_time_set = 1; + break; + case DHCP_Renewal_Time: + ses->renew_time = attr->val.integer; + renew_time_set = 1; + break; + } } } diff --git a/accel-pppd/memdebug.c b/accel-pppd/memdebug.c index 08c6ad05..5353e572 100644 --- a/accel-pppd/memdebug.c +++ b/accel-pppd/memdebug.c @@ -49,9 +49,6 @@ static struct mem_t *_md_malloc(size_t size, const char *fname, int line) if (mem == NULL) return NULL; - if (size > 4096) - line = 0; - mem->fname = fname; mem->line = line; mem->size = size; |