aboutsummaryrefslogtreecommitdiff
path: root/networking/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/interface.c')
-rw-r--r--networking/interface.c55
1 files changed, 1 insertions, 54 deletions
diff --git a/networking/interface.c b/networking/interface.c
index 9ae8b3f03..3dc5b3640 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -722,68 +722,15 @@ static char* FAST_FUNC ether_print(unsigned char *ptr)
722 return buff; 722 return buff;
723} 723}
724 724
725static int FAST_FUNC ether_input(const char *bufp, struct sockaddr *sap);
726
727static const struct hwtype ether_hwtype = { 725static const struct hwtype ether_hwtype = {
728 .name = "ether", 726 .name = "ether",
729 .title = "Ethernet", 727 .title = "Ethernet",
730 .type = ARPHRD_ETHER, 728 .type = ARPHRD_ETHER,
731 .alen = ETH_ALEN, 729 .alen = ETH_ALEN,
732 .print = ether_print, 730 .print = ether_print,
733 .input = ether_input 731 .input = in_ether
734}; 732};
735 733
736static unsigned hexchar2int(char c)
737{
738 if (isdigit(c))
739 return c - '0';
740 c &= ~0x20; /* a -> A */
741 if ((unsigned)(c - 'A') <= 5)
742 return c - ('A' - 10);
743 return ~0U;
744}
745
746/* Input an Ethernet address and convert to binary. */
747static int FAST_FUNC ether_input(const char *bufp, struct sockaddr *sap)
748{
749 unsigned char *ptr;
750 char c;
751 int i;
752 unsigned val;
753
754 sap->sa_family = ether_hwtype.type;
755 ptr = (unsigned char*) sap->sa_data;
756
757 i = 0;
758 while ((*bufp != '\0') && (i < ETH_ALEN)) {
759 val = hexchar2int(*bufp++) * 0x10;
760 if (val > 0xff) {
761 errno = EINVAL;
762 return -1;
763 }
764 c = *bufp;
765 if (c == ':' || c == 0)
766 val >>= 4;
767 else {
768 val |= hexchar2int(c);
769 if (val > 0xff) {
770 errno = EINVAL;
771 return -1;
772 }
773 }
774 if (c != 0)
775 bufp++;
776 *ptr++ = (unsigned char) val;
777 i++;
778
779 /* We might get a semicolon here - not required. */
780 if (*bufp == ':') {
781 bufp++;
782 }
783 }
784 return 0;
785}
786
787static const struct hwtype ppp_hwtype = { 734static const struct hwtype ppp_hwtype = {
788 .name = "ppp", 735 .name = "ppp",
789 .title = "Point-to-Point Protocol", 736 .title = "Point-to-Point Protocol",