@@ -146,24 +146,7 @@ func New(modifiers ...Modifier) (*DHCPv4, error) {
146
146
if err != nil {
147
147
return nil , err
148
148
}
149
- d := DHCPv4 {
150
- OpCode : OpcodeBootRequest ,
151
- HWType : iana .HWTypeEthernet ,
152
- ClientHWAddr : make (net.HardwareAddr , 6 ),
153
- HopCount : 0 ,
154
- TransactionID : xid ,
155
- NumSeconds : 0 ,
156
- Flags : 0 ,
157
- ClientIPAddr : net .IPv4zero ,
158
- YourIPAddr : net .IPv4zero ,
159
- ServerIPAddr : net .IPv4zero ,
160
- GatewayIPAddr : net .IPv4zero ,
161
- Options : make (Options ),
162
- }
163
- for _ , mod := range modifiers {
164
- mod (& d )
165
- }
166
- return & d , nil
149
+ return newDHCPv4 (xid , modifiers ), nil
167
150
}
168
151
169
152
// NewWithContext creates a new DHCPv4 structure and fill it up with default
@@ -175,6 +158,10 @@ func NewWithContext(ctx context.Context, modifiers ...Modifier) (*DHCPv4, error)
175
158
if err != nil {
176
159
return nil , err
177
160
}
161
+ return newDHCPv4 (xid , modifiers ), nil
162
+ }
163
+
164
+ func newDHCPv4 (xid TransactionID , modifiers ... Modifier ) * DHCPv4 {
178
165
d := DHCPv4 {
179
166
OpCode : OpcodeBootRequest ,
180
167
HWType : iana .HWTypeEthernet ,
@@ -192,7 +179,7 @@ func NewWithContext(ctx context.Context, modifiers ...Modifier) (*DHCPv4, error)
192
179
for _ , mod := range modifiers {
193
180
mod (& d )
194
181
}
195
- return & d , nil
182
+ return & d
196
183
}
197
184
198
185
// NewDiscoveryForInterface builds a new DHCPv4 Discovery message, with a default
0 commit comments