ifmedia.c (124560) | ifmedia.c (138593) |
---|---|
1/* $NetBSD: ifconfig.c,v 1.34 1997/04/21 01:17:58 lukem Exp $ */ | 1/* $NetBSD: ifconfig.c,v 1.34 1997/04/21 01:17:58 lukem Exp $ */ |
2/* $FreeBSD: head/sbin/ifconfig/ifmedia.c 124560 2004-01-15 15:19:19Z sam $ */ | 2/* $FreeBSD: head/sbin/ifconfig/ifmedia.c 138593 2004-12-08 19:18:07Z sam $ */ |
3 4/* 5 * Copyright (c) 1997 Jason R. Thorpe. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 86 unchanged lines hidden (view full) --- 97static void print_media_word(int, int); 98static void print_media_word_ifconfig(int); 99 100static struct ifmedia_description *get_toptype_desc(int); 101static struct ifmedia_type_to_subtype *get_toptype_ttos(int); 102static struct ifmedia_description *get_subtype_desc(int, 103 struct ifmedia_type_to_subtype *ttos); 104 | 3 4/* 5 * Copyright (c) 1997 Jason R. Thorpe. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 86 unchanged lines hidden (view full) --- 97static void print_media_word(int, int); 98static void print_media_word_ifconfig(int); 99 100static struct ifmedia_description *get_toptype_desc(int); 101static struct ifmedia_type_to_subtype *get_toptype_ttos(int); 102static struct ifmedia_description *get_subtype_desc(int, 103 struct ifmedia_type_to_subtype *ttos); 104 |
105void 106media_status(int s, struct rt_addrinfo *info __unused) | 105static void 106media_status(int s, const struct rt_addrinfo *info __unused) |
107{ 108 struct ifmediareq ifmr; 109 int *media_list, i; 110 111 (void) memset(&ifmr, 0, sizeof(ifmr)); 112 (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); 113 114 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { --- 70 unchanged lines hidden (view full) --- 185 print_media_word_ifconfig(media_list[i]); 186 putchar('\n'); 187 } 188 } 189 190 free(media_list); 191} 192 | 107{ 108 struct ifmediareq ifmr; 109 int *media_list, i; 110 111 (void) memset(&ifmr, 0, sizeof(ifmr)); 112 (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); 113 114 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { --- 70 unchanged lines hidden (view full) --- 185 print_media_word_ifconfig(media_list[i]); 186 putchar('\n'); 187 } 188 } 189 190 free(media_list); 191} 192 |
193void | 193static void |
194setmedia(const char *val, int d, int s, const struct afswtch *afp) 195{ 196 struct ifmediareq ifmr; 197 int first_type, subtype; 198 199 (void) memset(&ifmr, 0, sizeof(ifmr)); 200 (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); 201 --- 25 unchanged lines hidden (view full) --- 227 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); 228 ifr.ifr_media = (ifmr.ifm_current & ~(IFM_NMASK|IFM_TMASK)) | 229 IFM_TYPE(first_type) | subtype; 230 231 if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0) 232 err(1, "SIOCSIFMEDIA (media)"); 233} 234 | 194setmedia(const char *val, int d, int s, const struct afswtch *afp) 195{ 196 struct ifmediareq ifmr; 197 int first_type, subtype; 198 199 (void) memset(&ifmr, 0, sizeof(ifmr)); 200 (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); 201 --- 25 unchanged lines hidden (view full) --- 227 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); 228 ifr.ifr_media = (ifmr.ifm_current & ~(IFM_NMASK|IFM_TMASK)) | 229 IFM_TYPE(first_type) | subtype; 230 231 if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0) 232 err(1, "SIOCSIFMEDIA (media)"); 233} 234 |
235void | 235static void |
236setmediaopt(const char *val, int d, int s, const struct afswtch *afp) 237{ 238 239 domediaopt(val, 0, s); 240} 241 | 236setmediaopt(const char *val, int d, int s, const struct afswtch *afp) 237{ 238 239 domediaopt(val, 0, s); 240} 241 |
242void | 242static void |
243unsetmediaopt(const char *val, int d, int s, const struct afswtch *afp) 244{ 245 246 domediaopt(val, 1, s); 247} 248 249static void 250domediaopt(const char *val, int clear, int s) --- 35 unchanged lines hidden (view full) --- 286 else 287 ifr.ifr_media |= options; 288 289 if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0) 290 err(1, "SIOCSIFMEDIA (mediaopt)"); 291} 292 293 | 243unsetmediaopt(const char *val, int d, int s, const struct afswtch *afp) 244{ 245 246 domediaopt(val, 1, s); 247} 248 249static void 250domediaopt(const char *val, int clear, int s) --- 35 unchanged lines hidden (view full) --- 286 else 287 ifr.ifr_media |= options; 288 289 if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0) 290 err(1, "SIOCSIFMEDIA (mediaopt)"); 291} 292 293 |
294void | 294static void |
295setmediamode(const char *val, int d, int s, const struct afswtch *afp) 296{ 297 struct ifmediareq ifmr; 298 int *mwords, mode; 299 300 (void) memset(&ifmr, 0, sizeof(ifmr)); 301 (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); 302 --- 469 unchanged lines hidden (view full) --- 772 } 773 } 774 } 775} 776 777/********************************************************************** 778 * ...until here. 779 **********************************************************************/ | 295setmediamode(const char *val, int d, int s, const struct afswtch *afp) 296{ 297 struct ifmediareq ifmr; 298 int *mwords, mode; 299 300 (void) memset(&ifmr, 0, sizeof(ifmr)); 301 (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); 302 --- 469 unchanged lines hidden (view full) --- 772 } 773 } 774 } 775} 776 777/********************************************************************** 778 * ...until here. 779 **********************************************************************/ |
780 781static struct cmd media_cmds[] = { 782 DEF_CMD_ARG("media", setmedia), 783 DEF_CMD_ARG("mode", setmediamode), 784 DEF_CMD_ARG("mediaopt", setmediaopt), 785 DEF_CMD_ARG("-mediaopt",unsetmediaopt), 786}; 787static struct afswtch af_media = { 788 .af_name = "af_media", 789 .af_af = AF_UNSPEC, 790 .af_status = media_status, 791}; 792 793static __constructor void 794ifmedia_ctor(void) 795{ 796#define N(a) (sizeof(a) / sizeof(a[0])) 797 int i; 798 799 for (i = 0; i < N(media_cmds); i++) 800 cmd_register(&media_cmds[i]); 801 af_register(&af_media); 802#undef N 803} |
|