Changeset 4a9b897 in rtems
- Timestamp:
- 01/21/00 15:11:40 (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- d7f33012
- Parents:
- c941a98
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/libnetworking/rtems/rtems_glue.c
rc941a98 r4a9b897 124 124 * Do the initializations required by the BSD code 125 125 */ 126 static void127 bsd_init ( )126 static int 127 bsd_init (void) 128 128 { 129 129 int i; … … 135 135 p = malloc ((nmbclusters*MCLBYTES)+MCLBYTES-1); 136 136 p = (char *)(((unsigned long)p + (MCLBYTES-1)) & ~(MCLBYTES-1)); 137 if (p == NULL) 138 rtems_panic ("Can't get network cluster memory."); 137 if (p == NULL) { 138 printf ("Can't get network cluster memory.\n"); 139 return -1; 140 } 139 141 mbutl = (struct mbuf *)p; 140 142 for (i = 0; i < nmbclusters; i++) { … … 146 148 mbstat.m_clusters = nmbclusters; 147 149 mclrefcnt = malloc (nmbclusters); 148 if (mclrefcnt == NULL) 149 rtems_panic ("Can't get mbuf cluster reference counts memory."); 150 if (mclrefcnt == NULL) { 151 printf ("Can't get mbuf cluster reference counts memory.\n"); 152 return -1; 153 } 150 154 memset (mclrefcnt, '\0', nmbclusters); 151 155 … … 156 160 p = malloc(nmbuf * MSIZE + MSIZE - 1); 157 161 p = (char *)(((unsigned int)p + MSIZE - 1) & ~(MSIZE - 1)); 158 if (p == NULL) 159 rtems_panic ("Can't get network memory."); 162 if (p == NULL) { 163 printf ("Can't get network memory.\n"); 164 return -1; 165 } 160 166 for (i = 0; i < nmbuf; i++) { 161 167 ((struct mbuf *)p)->m_next = mmbfree; … … 184 190 */ 185 191 ifinit (NULL); 192 return 0; 186 193 } 187 194 … … 189 196 * Initialize and start network operations 190 197 */ 191 static void198 static int 192 199 rtems_bsdnet_initialize (void) 193 200 { … … 222 229 0, 223 230 &networkSemaphore); 224 if (sc != RTEMS_SUCCESSFUL) 225 rtems_panic ("Can't create network seamphore: `%s'\n", rtems_status_text (sc)); 231 if (sc != RTEMS_SUCCESSFUL) { 232 printf ("Can't create network seamphore: `%s'\n", rtems_status_text (sc)); 233 return -1; 234 } 226 235 227 236 /* … … 241 250 * Set up BSD-style sockets 242 251 */ 243 bsd_init (); 252 if (bsd_init () < 0) 253 return -1; 244 254 245 255 /* … … 252 262 */ 253 263 rtems_bsdnet_semaphore_release (); 254 } 255 256 rtems_id TaskWithSemaphore; 264 return 0; 265 } 266 257 267 /* 258 268 * Obtain network mutex … … 264 274 265 275 sc = rtems_semaphore_obtain (networkSemaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); 266 rtems_task_ident (RTEMS_SELF, 0, &TaskWithSemaphore);267 276 if (sc != RTEMS_SUCCESSFUL) 268 277 rtems_panic ("Can't obtain network semaphore: `%s'\n", rtems_status_text (sc)); … … 277 286 rtems_status_code sc; 278 287 279 TaskWithSemaphore = 0;280 288 sc = rtems_semaphore_release (networkSemaphore); 281 289 if (sc != RTEMS_SUCCESSFUL) … … 727 735 } 728 736 729 static void737 static int 730 738 rtems_bsdnet_setup (void) 731 739 { … … 771 779 */ 772 780 s = socket (AF_INET, SOCK_DGRAM, 0); 773 if (s < 0) 774 rtems_panic ("Can't create initial socket: %s", strerror (errno)); 781 if (s < 0) { 782 printf ("Can't create initial socket: %s\n", strerror (errno)); 783 return -1; 784 } 775 785 for (ifp = rtems_bsdnet_config.ifconfig ; ifp ; ifp = ifp->next) { 776 786 if (ifp->ip_address == NULL) … … 781 791 */ 782 792 strcpy (ifreq.ifr_name, ifp->name); 783 if (ioctl (s, SIOCGIFFLAGS, &ifreq) < 0) 784 rtems_panic ("Can't get %s flags: %s", ifp->name, strerror (errno)); 793 if (ioctl (s, SIOCGIFFLAGS, &ifreq) < 0) { 794 printf ("Can't get %s flags: %s\n", ifp->name, strerror (errno)); 795 return -1; 796 } 785 797 786 798 /* … … 788 800 */ 789 801 ifreq.ifr_flags |= IFF_UP; 790 if (ioctl (s, SIOCSIFFLAGS, &ifreq) < 0) 791 rtems_panic ("Can't bring %s up: %s", ifp->name, strerror (errno)); 802 if (ioctl (s, SIOCSIFFLAGS, &ifreq) < 0) { 803 printf ("Can't bring %s up: %s\n", ifp->name, strerror (errno)); 804 return -1; 805 } 792 806 793 807 /* … … 799 813 netmask.sin_addr.s_addr = inet_addr (ifp->ip_netmask); 800 814 memcpy (&ifreq.ifr_addr, &netmask, sizeof netmask); 801 if (ioctl (s, SIOCSIFNETMASK, &ifreq) < 0) 802 rtems_panic ("Can't set %s netmask: %s", ifp->name, strerror (errno)); 815 if (ioctl (s, SIOCSIFNETMASK, &ifreq) < 0) { 816 printf ("Can't set %s netmask: %s\n", ifp->name, strerror (errno)); 817 return -1; 818 } 803 819 804 820 /* … … 810 826 address.sin_addr.s_addr = inet_addr (ifp->ip_address); 811 827 memcpy (&ifreq.ifr_addr, &address, sizeof address); 812 if (ioctl (s, SIOCSIFADDR, &ifreq) < 0) 813 rtems_panic ("Can't set %s address: %s", ifp->name, strerror (errno)); 828 if (ioctl (s, SIOCSIFADDR, &ifreq) < 0) { 829 printf ("Can't set %s address: %s\n", ifp->name, strerror (errno)); 830 return -1; 831 } 814 832 815 833 /* … … 845 863 (struct sockaddr *)&gateway, 846 864 (struct sockaddr *)&netmask, 847 (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL) < 0) 848 rtems_panic ("Can't set default route: %s", strerror (errno)); 849 } 865 (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL) < 0) { 866 printf ("Can't set default route: %s\n", strerror (errno)); 867 return -1; 868 } 869 } 870 return 0; 850 871 } 851 872 … … 862 883 * Initialize BSD network data structures. 863 884 */ 864 rtems_bsdnet_initialize (); 885 if (rtems_bsdnet_initialize () < 0) 886 return -1; 865 887 866 888 /* … … 876 898 * Bring up the network 877 899 */ 878 rtems_bsdnet_setup (); 900 if (rtems_bsdnet_setup () < 0) 901 return -1; 879 902 if (rtems_bsdnet_config.bootp) 880 903 (*rtems_bsdnet_config.bootp)(); … … 893 916 894 917 if (cp == NULL) { 895 printf ("No network driver name ");918 printf ("No network driver name.\n"); 896 919 return -1; 897 920 } … … 907 930 char *unitName = malloc (len); 908 931 if (unitName == NULL) { 909 printf ("No memory ");932 printf ("No memory.\n"); 910 933 return -1; 911 934 } … … 921 944 } 922 945 } 923 printf ("Bad network driver name `%s' ", config->name);946 printf ("Bad network driver name `%s'.\n", config->name); 924 947 return -1; 925 948 } -
c/src/libnetworking/rtems/rtems_glue.c
rc941a98 r4a9b897 124 124 * Do the initializations required by the BSD code 125 125 */ 126 static void127 bsd_init ( )126 static int 127 bsd_init (void) 128 128 { 129 129 int i; … … 135 135 p = malloc ((nmbclusters*MCLBYTES)+MCLBYTES-1); 136 136 p = (char *)(((unsigned long)p + (MCLBYTES-1)) & ~(MCLBYTES-1)); 137 if (p == NULL) 138 rtems_panic ("Can't get network cluster memory."); 137 if (p == NULL) { 138 printf ("Can't get network cluster memory.\n"); 139 return -1; 140 } 139 141 mbutl = (struct mbuf *)p; 140 142 for (i = 0; i < nmbclusters; i++) { … … 146 148 mbstat.m_clusters = nmbclusters; 147 149 mclrefcnt = malloc (nmbclusters); 148 if (mclrefcnt == NULL) 149 rtems_panic ("Can't get mbuf cluster reference counts memory."); 150 if (mclrefcnt == NULL) { 151 printf ("Can't get mbuf cluster reference counts memory.\n"); 152 return -1; 153 } 150 154 memset (mclrefcnt, '\0', nmbclusters); 151 155 … … 156 160 p = malloc(nmbuf * MSIZE + MSIZE - 1); 157 161 p = (char *)(((unsigned int)p + MSIZE - 1) & ~(MSIZE - 1)); 158 if (p == NULL) 159 rtems_panic ("Can't get network memory."); 162 if (p == NULL) { 163 printf ("Can't get network memory.\n"); 164 return -1; 165 } 160 166 for (i = 0; i < nmbuf; i++) { 161 167 ((struct mbuf *)p)->m_next = mmbfree; … … 184 190 */ 185 191 ifinit (NULL); 192 return 0; 186 193 } 187 194 … … 189 196 * Initialize and start network operations 190 197 */ 191 static void198 static int 192 199 rtems_bsdnet_initialize (void) 193 200 { … … 222 229 0, 223 230 &networkSemaphore); 224 if (sc != RTEMS_SUCCESSFUL) 225 rtems_panic ("Can't create network seamphore: `%s'\n", rtems_status_text (sc)); 231 if (sc != RTEMS_SUCCESSFUL) { 232 printf ("Can't create network seamphore: `%s'\n", rtems_status_text (sc)); 233 return -1; 234 } 226 235 227 236 /* … … 241 250 * Set up BSD-style sockets 242 251 */ 243 bsd_init (); 252 if (bsd_init () < 0) 253 return -1; 244 254 245 255 /* … … 252 262 */ 253 263 rtems_bsdnet_semaphore_release (); 254 } 255 256 rtems_id TaskWithSemaphore; 264 return 0; 265 } 266 257 267 /* 258 268 * Obtain network mutex … … 264 274 265 275 sc = rtems_semaphore_obtain (networkSemaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); 266 rtems_task_ident (RTEMS_SELF, 0, &TaskWithSemaphore);267 276 if (sc != RTEMS_SUCCESSFUL) 268 277 rtems_panic ("Can't obtain network semaphore: `%s'\n", rtems_status_text (sc)); … … 277 286 rtems_status_code sc; 278 287 279 TaskWithSemaphore = 0;280 288 sc = rtems_semaphore_release (networkSemaphore); 281 289 if (sc != RTEMS_SUCCESSFUL) … … 727 735 } 728 736 729 static void737 static int 730 738 rtems_bsdnet_setup (void) 731 739 { … … 771 779 */ 772 780 s = socket (AF_INET, SOCK_DGRAM, 0); 773 if (s < 0) 774 rtems_panic ("Can't create initial socket: %s", strerror (errno)); 781 if (s < 0) { 782 printf ("Can't create initial socket: %s\n", strerror (errno)); 783 return -1; 784 } 775 785 for (ifp = rtems_bsdnet_config.ifconfig ; ifp ; ifp = ifp->next) { 776 786 if (ifp->ip_address == NULL) … … 781 791 */ 782 792 strcpy (ifreq.ifr_name, ifp->name); 783 if (ioctl (s, SIOCGIFFLAGS, &ifreq) < 0) 784 rtems_panic ("Can't get %s flags: %s", ifp->name, strerror (errno)); 793 if (ioctl (s, SIOCGIFFLAGS, &ifreq) < 0) { 794 printf ("Can't get %s flags: %s\n", ifp->name, strerror (errno)); 795 return -1; 796 } 785 797 786 798 /* … … 788 800 */ 789 801 ifreq.ifr_flags |= IFF_UP; 790 if (ioctl (s, SIOCSIFFLAGS, &ifreq) < 0) 791 rtems_panic ("Can't bring %s up: %s", ifp->name, strerror (errno)); 802 if (ioctl (s, SIOCSIFFLAGS, &ifreq) < 0) { 803 printf ("Can't bring %s up: %s\n", ifp->name, strerror (errno)); 804 return -1; 805 } 792 806 793 807 /* … … 799 813 netmask.sin_addr.s_addr = inet_addr (ifp->ip_netmask); 800 814 memcpy (&ifreq.ifr_addr, &netmask, sizeof netmask); 801 if (ioctl (s, SIOCSIFNETMASK, &ifreq) < 0) 802 rtems_panic ("Can't set %s netmask: %s", ifp->name, strerror (errno)); 815 if (ioctl (s, SIOCSIFNETMASK, &ifreq) < 0) { 816 printf ("Can't set %s netmask: %s\n", ifp->name, strerror (errno)); 817 return -1; 818 } 803 819 804 820 /* … … 810 826 address.sin_addr.s_addr = inet_addr (ifp->ip_address); 811 827 memcpy (&ifreq.ifr_addr, &address, sizeof address); 812 if (ioctl (s, SIOCSIFADDR, &ifreq) < 0) 813 rtems_panic ("Can't set %s address: %s", ifp->name, strerror (errno)); 828 if (ioctl (s, SIOCSIFADDR, &ifreq) < 0) { 829 printf ("Can't set %s address: %s\n", ifp->name, strerror (errno)); 830 return -1; 831 } 814 832 815 833 /* … … 845 863 (struct sockaddr *)&gateway, 846 864 (struct sockaddr *)&netmask, 847 (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL) < 0) 848 rtems_panic ("Can't set default route: %s", strerror (errno)); 849 } 865 (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL) < 0) { 866 printf ("Can't set default route: %s\n", strerror (errno)); 867 return -1; 868 } 869 } 870 return 0; 850 871 } 851 872 … … 862 883 * Initialize BSD network data structures. 863 884 */ 864 rtems_bsdnet_initialize (); 885 if (rtems_bsdnet_initialize () < 0) 886 return -1; 865 887 866 888 /* … … 876 898 * Bring up the network 877 899 */ 878 rtems_bsdnet_setup (); 900 if (rtems_bsdnet_setup () < 0) 901 return -1; 879 902 if (rtems_bsdnet_config.bootp) 880 903 (*rtems_bsdnet_config.bootp)(); … … 893 916 894 917 if (cp == NULL) { 895 printf ("No network driver name ");918 printf ("No network driver name.\n"); 896 919 return -1; 897 920 } … … 907 930 char *unitName = malloc (len); 908 931 if (unitName == NULL) { 909 printf ("No memory ");932 printf ("No memory.\n"); 910 933 return -1; 911 934 } … … 921 944 } 922 945 } 923 printf ("Bad network driver name `%s' ", config->name);946 printf ("Bad network driver name `%s'.\n", config->name); 924 947 return -1; 925 948 } -
cpukit/libnetworking/rtems/rtems_glue.c
rc941a98 r4a9b897 124 124 * Do the initializations required by the BSD code 125 125 */ 126 static void127 bsd_init ( )126 static int 127 bsd_init (void) 128 128 { 129 129 int i; … … 135 135 p = malloc ((nmbclusters*MCLBYTES)+MCLBYTES-1); 136 136 p = (char *)(((unsigned long)p + (MCLBYTES-1)) & ~(MCLBYTES-1)); 137 if (p == NULL) 138 rtems_panic ("Can't get network cluster memory."); 137 if (p == NULL) { 138 printf ("Can't get network cluster memory.\n"); 139 return -1; 140 } 139 141 mbutl = (struct mbuf *)p; 140 142 for (i = 0; i < nmbclusters; i++) { … … 146 148 mbstat.m_clusters = nmbclusters; 147 149 mclrefcnt = malloc (nmbclusters); 148 if (mclrefcnt == NULL) 149 rtems_panic ("Can't get mbuf cluster reference counts memory."); 150 if (mclrefcnt == NULL) { 151 printf ("Can't get mbuf cluster reference counts memory.\n"); 152 return -1; 153 } 150 154 memset (mclrefcnt, '\0', nmbclusters); 151 155 … … 156 160 p = malloc(nmbuf * MSIZE + MSIZE - 1); 157 161 p = (char *)(((unsigned int)p + MSIZE - 1) & ~(MSIZE - 1)); 158 if (p == NULL) 159 rtems_panic ("Can't get network memory."); 162 if (p == NULL) { 163 printf ("Can't get network memory.\n"); 164 return -1; 165 } 160 166 for (i = 0; i < nmbuf; i++) { 161 167 ((struct mbuf *)p)->m_next = mmbfree; … … 184 190 */ 185 191 ifinit (NULL); 192 return 0; 186 193 } 187 194 … … 189 196 * Initialize and start network operations 190 197 */ 191 static void198 static int 192 199 rtems_bsdnet_initialize (void) 193 200 { … … 222 229 0, 223 230 &networkSemaphore); 224 if (sc != RTEMS_SUCCESSFUL) 225 rtems_panic ("Can't create network seamphore: `%s'\n", rtems_status_text (sc)); 231 if (sc != RTEMS_SUCCESSFUL) { 232 printf ("Can't create network seamphore: `%s'\n", rtems_status_text (sc)); 233 return -1; 234 } 226 235 227 236 /* … … 241 250 * Set up BSD-style sockets 242 251 */ 243 bsd_init (); 252 if (bsd_init () < 0) 253 return -1; 244 254 245 255 /* … … 252 262 */ 253 263 rtems_bsdnet_semaphore_release (); 254 } 255 256 rtems_id TaskWithSemaphore; 264 return 0; 265 } 266 257 267 /* 258 268 * Obtain network mutex … … 264 274 265 275 sc = rtems_semaphore_obtain (networkSemaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); 266 rtems_task_ident (RTEMS_SELF, 0, &TaskWithSemaphore);267 276 if (sc != RTEMS_SUCCESSFUL) 268 277 rtems_panic ("Can't obtain network semaphore: `%s'\n", rtems_status_text (sc)); … … 277 286 rtems_status_code sc; 278 287 279 TaskWithSemaphore = 0;280 288 sc = rtems_semaphore_release (networkSemaphore); 281 289 if (sc != RTEMS_SUCCESSFUL) … … 727 735 } 728 736 729 static void737 static int 730 738 rtems_bsdnet_setup (void) 731 739 { … … 771 779 */ 772 780 s = socket (AF_INET, SOCK_DGRAM, 0); 773 if (s < 0) 774 rtems_panic ("Can't create initial socket: %s", strerror (errno)); 781 if (s < 0) { 782 printf ("Can't create initial socket: %s\n", strerror (errno)); 783 return -1; 784 } 775 785 for (ifp = rtems_bsdnet_config.ifconfig ; ifp ; ifp = ifp->next) { 776 786 if (ifp->ip_address == NULL) … … 781 791 */ 782 792 strcpy (ifreq.ifr_name, ifp->name); 783 if (ioctl (s, SIOCGIFFLAGS, &ifreq) < 0) 784 rtems_panic ("Can't get %s flags: %s", ifp->name, strerror (errno)); 793 if (ioctl (s, SIOCGIFFLAGS, &ifreq) < 0) { 794 printf ("Can't get %s flags: %s\n", ifp->name, strerror (errno)); 795 return -1; 796 } 785 797 786 798 /* … … 788 800 */ 789 801 ifreq.ifr_flags |= IFF_UP; 790 if (ioctl (s, SIOCSIFFLAGS, &ifreq) < 0) 791 rtems_panic ("Can't bring %s up: %s", ifp->name, strerror (errno)); 802 if (ioctl (s, SIOCSIFFLAGS, &ifreq) < 0) { 803 printf ("Can't bring %s up: %s\n", ifp->name, strerror (errno)); 804 return -1; 805 } 792 806 793 807 /* … … 799 813 netmask.sin_addr.s_addr = inet_addr (ifp->ip_netmask); 800 814 memcpy (&ifreq.ifr_addr, &netmask, sizeof netmask); 801 if (ioctl (s, SIOCSIFNETMASK, &ifreq) < 0) 802 rtems_panic ("Can't set %s netmask: %s", ifp->name, strerror (errno)); 815 if (ioctl (s, SIOCSIFNETMASK, &ifreq) < 0) { 816 printf ("Can't set %s netmask: %s\n", ifp->name, strerror (errno)); 817 return -1; 818 } 803 819 804 820 /* … … 810 826 address.sin_addr.s_addr = inet_addr (ifp->ip_address); 811 827 memcpy (&ifreq.ifr_addr, &address, sizeof address); 812 if (ioctl (s, SIOCSIFADDR, &ifreq) < 0) 813 rtems_panic ("Can't set %s address: %s", ifp->name, strerror (errno)); 828 if (ioctl (s, SIOCSIFADDR, &ifreq) < 0) { 829 printf ("Can't set %s address: %s\n", ifp->name, strerror (errno)); 830 return -1; 831 } 814 832 815 833 /* … … 845 863 (struct sockaddr *)&gateway, 846 864 (struct sockaddr *)&netmask, 847 (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL) < 0) 848 rtems_panic ("Can't set default route: %s", strerror (errno)); 849 } 865 (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL) < 0) { 866 printf ("Can't set default route: %s\n", strerror (errno)); 867 return -1; 868 } 869 } 870 return 0; 850 871 } 851 872 … … 862 883 * Initialize BSD network data structures. 863 884 */ 864 rtems_bsdnet_initialize (); 885 if (rtems_bsdnet_initialize () < 0) 886 return -1; 865 887 866 888 /* … … 876 898 * Bring up the network 877 899 */ 878 rtems_bsdnet_setup (); 900 if (rtems_bsdnet_setup () < 0) 901 return -1; 879 902 if (rtems_bsdnet_config.bootp) 880 903 (*rtems_bsdnet_config.bootp)(); … … 893 916 894 917 if (cp == NULL) { 895 printf ("No network driver name ");918 printf ("No network driver name.\n"); 896 919 return -1; 897 920 } … … 907 930 char *unitName = malloc (len); 908 931 if (unitName == NULL) { 909 printf ("No memory ");932 printf ("No memory.\n"); 910 933 return -1; 911 934 } … … 921 944 } 922 945 } 923 printf ("Bad network driver name `%s' ", config->name);946 printf ("Bad network driver name `%s'.\n", config->name); 924 947 return -1; 925 948 }
Note: See TracChangeset
for help on using the changeset viewer.