]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/GetServByPort/GetServByPort.c
2 Translate the port number into a service name
4 Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include <Library/DebugLib.h>
21 #include <Library/UefiLib.h>
23 #include <sys/socket.h>
28 /** Translate the port number into a service name
30 @param[in] Argc The number of arguments
31 @param[in] Argv The argument value array
33 @retval 0 The application exited normally.
34 @retval Other An error occurred.
43 struct servent
* pService
;
45 // Determine if the service name is specified
47 || ( 1 != sscanf ( Argv
[1], "%d", &PortNumber
))) {
48 Print ( L
"%a <port number>\r\n", Argv
[0]);
51 // Translate the port number
52 pService
= getservbyport ( htons ( PortNumber
), NULL
);
53 if ( NULL
== pService
) {
54 Print ( L
"ERROR - service not found, errno: %d\r\n", errno
);
57 Print ( L
"%a: %d, %a\r\n",