| 701 | function_name = "dhcpd" |
| 702 | |
| 703 | def make_reply(self, req): |
| 704 | resp = BOOTP_am.make_reply(self, req) |
| 705 | if DHCP in req: |
| 706 | dhcp_options = [ |
| 707 | (op[0], {1: 2, 3: 5}.get(op[1], op[1])) |
| 708 | for op in req[DHCP].options |
| 709 | if isinstance(op, tuple) and op[0] == "message-type" |
| 710 | ] |
| 711 | dhcp_options += [ |
| 712 | x for x in [ |
| 713 | ("server_id", self.gw), |
| 714 | ("domain", self.domain), |
| 715 | ("router", self.gw), |
| 716 | ("name_server", *self.nameserver), |
| 717 | ("broadcast_address", self.broadcast), |
| 718 | ("subnet_mask", self.netmask), |
| 719 | ("renewal_time", self.renewal_time), |
| 720 | ("lease_time", self.lease_time), |
| 721 | ] |
| 722 | if x[1] is not None |
| 723 | ] |
| 724 | if self.kwargs: |
| 725 | dhcp_options += self.kwargs.items() |
| 726 | dhcp_options.append("end") |
| 727 | resp /= DHCP(options=dhcp_options) |
| 728 | return resp |