File tree Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -236,14 +236,16 @@ function down(interface, callback) {
236
236
* };
237
237
*
238
238
* ifconfig.up(options, function(err) {
239
- * // the interface is up
239
+ * // the interface is up
240
240
* });
241
241
*
242
+ * ipv4_address, ipv4_broadcast and ipv4_subnet_mask are optional
242
243
*/
243
244
function up ( options , callback ) {
244
245
return this . exec ( 'ifconfig ' + options . interface +
245
- ' ' + options . ipv4_address +
246
- ' netmask ' + options . ipv4_subnet_mask +
247
- ' broadcast ' + options . ipv4_broadcast +
246
+ ' ' +
247
+ ( options . ipv4_address ? options . ipv4_address : '0.0.0.0' ) +
248
+ ( options . ipv4_subnet_mask ? ' netmask ' + options . ipv4_subnet_mask : '' ) +
249
+ ( options . ipv4_broadcast ? ' broadcast ' + options . ipv4_broadcast : '' ) +
248
250
' up' , callback ) ;
249
251
}
Original file line number Diff line number Diff line change @@ -180,6 +180,39 @@ describe('ifconfig', function() {
180
180
} ) ;
181
181
} )
182
182
183
+ it ( 'should bring up the interface without broadcast nor subnet' , function ( done ) {
184
+ ifconfig . exec = function ( command , callback ) {
185
+ should ( command ) . eql ( 'ifconfig wlan0 192.168.10.1 up' ) ;
186
+ callback ( null , '' , '' ) ;
187
+ } ;
188
+
189
+ var options = {
190
+ interface : 'wlan0' ,
191
+ ipv4_address : '192.168.10.1' ,
192
+ } ;
193
+
194
+ ifconfig . up ( options , function ( err ) {
195
+ should ( err ) . not . be . ok ;
196
+ done ( ) ;
197
+ } ) ;
198
+ } )
199
+
200
+ it ( 'should bring up the interface without ip/broadcast nor subnet' , function ( done ) {
201
+ ifconfig . exec = function ( command , callback ) {
202
+ should ( command ) . eql ( 'ifconfig wlan0 0.0.0.0 up' ) ;
203
+ callback ( null , '' , '' ) ;
204
+ } ;
205
+
206
+ var options = {
207
+ interface : 'wlan0'
208
+ } ;
209
+
210
+ ifconfig . up ( options , function ( err ) {
211
+ should ( err ) . not . be . ok ;
212
+ done ( ) ;
213
+ } ) ;
214
+ } )
215
+
183
216
it ( 'should handle errors' , function ( done ) {
184
217
ifconfig . exec = function ( command , callback ) {
185
218
callback ( 'error' ) ;
You can’t perform that action at this time.
0 commit comments