Modify

Opened 3 years ago

#18842 new defect

Interface protocol DHCP add option 33/121/249 supported

Reported by: zhuxianfeng Owned by: developers
Priority: normal Milestone:
Component: packages Version: Trunk
Keywords: DHCP Cc:

Description

1.DHCP setup: /lib/netifd/proto/dhcp.sh

proto_dhcp_setup() {
        proto_run_command "$config" udhcpc \
                -p /var/run/udhcpc-$iface.pid \
                -s /lib/netifd/dhcp.script \
+               -O 33 -O 121 -O 249 \
                -f -R -a -t 0 -i "$iface" \
                ${ipaddr:+-r $ipaddr} \
                ${hostname:+-H $hostname} \

2.DHCP UP ubus action: /lib/netifd/dhcp.script

+set_static_routes() {                      
+       local max=128                       
+       local target=                                        
+       local oldstr=                                        
+       local newstr=                                        
+       local mask=                                          
+                                                            
+       while [ -n "$1" -a $max -gt 0 ]; do                  
+               target=${1%%/*}                              
+               mask=32                                      
+               oldstr=$target                                                  
+               while [ $mask -ge 0 ]; do                                       
+                       newstr=${oldstr%%.0}                                    
+                       if [ "X$newstr" != "X$oldstr" ]; then                   
+                               mask=$((mask-8))                                
+                               oldstr=$newstr                                  
+                       else                                                    
+                               break                                           
+                       fi                                                      
+               done                                                            
+                                                                               
+               echo "proto_add_ipv4_route $target $mask ${1##*/}" >/dev/console
+               proto_add_ipv4_route "$target" $mask "${1##*/}"
+               max=$(($max-1))                                
+               shift 1                                        
+       done                                                   
+} 

setup_interface () {                                           
        proto_init_update "*" 1                                
        proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}"
        # TODO: apply $broadcast                               
                                                               
        for i in $router; do                                   
                proto_add_ipv4_route 0.0.0.0 0 "$i"            
        done                                                   
                                                               
+       # option 33                                            
+       [ -n "$routes" ] && set_static_routes $routes          
                                                               
        # CIDR STATIC ROUTES (rfc3442)                         
        [ -n "$staticroutes" ] && set_classless_routes $staticroutes

Attachments (0)

Change History (0)

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.