Skip to content

Commit

Permalink
Merge pull request #425 from zmap/patch/s7-version-number
Browse files Browse the repository at this point in the history
patch: getVersionNumber function
  • Loading branch information
phillip-stephens authored May 21, 2024
2 parents e6c519f + a1571dc commit 51c2ff1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/siemens/s7.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,13 @@ func parseModuleIDDataRecord(data []byte) (*moduleIDData, error) {

// Constructs the version number from a moduleIDData record.
func getVersionNumber(record *moduleIDData) string {
lastByteAusbg1 := record.Ausbg1 & 0xFF
return fmt.Sprintf("V%d.%d", lastByteAusbg1, record.Ausbg2)
// The major, minor, and patch versions are stored in the lower 8 bits of Ausbg1,
// the upper 8 bits of Ausbg2, and the lower 8 bits of Ausbg2, respectively.
major := record.Ausbg1 & 0xFF
minor := record.Ausbg2 >> 8
patch := record.Ausbg2 & 0xFF

return fmt.Sprintf("%d.%d.%d", major, minor, patch)
}

func parseModuleIdentificationRequest(logStruct *S7Log, s7Packet *S7Packet) error {
Expand Down

0 comments on commit 51c2ff1

Please sign in to comment.