Skip to content

Refactor: 중복된 DHCP 메시지 파싱 로직 공통 메서드로 추출 #12

@column-wise

Description

@column-wise

현 상황

Computer.handleUDP()와 DHCPServer.handleUDP() 내부에 DHCP 메시지를 파싱하는 중복된 코드 블록이 존재합니다.

EthernetFrame frame = (EthernetFrame) dataUnit;
String destinationMAC = frame.getDestinationMAC();
String sourceMAC = frame.getSourceMAC();

IPPacket ipPacket = frame.getIPPacket();
String destinationIP = ipPacket.getDestinationIP();
String sourceIP = ipPacket.getSourceIP();

UDPDatagram udpDatagram = (UDPDatagram) ipPacket.getTransportDataUnit();
Map<String, String> payload = PayloadParser.parsePayload(udpDatagram.getPayload());
String dhcpMessageType = payload.get("DHCP Message Type");

제안

  • 중복된 로직을 Node 또는 별도의 유틸 클래스에서 공통 메서드로 추출
  • 예: DHCPUtil.extractPayload(DataUnit data) 또는 Node.parseDHCPPayload(DataUnit) 형태

기대 효과

  • 중복 제거로 코드 유지보수 용이성 향상
  • 향후 DHCP 메시지 포맷 변경 시 수정 범위 최소화

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions